您的位置:首页 > 移动开发 > Android开发

android.graphics.PorterDuff,android.graphics.Insets注释翻译

2015-08-08 17:51 375 查看
package android.graphics;

public class PorterDuff {

// these value must match their native equivalents. See SkPorterDuff.h
public enum Mode {
/** [0, 0] */
//所绘制不会提交到画布上。
CLEAR       (0),
/** [Sa, Sc] */
//显示上层绘制图片
SRC         (1),
/** [Da, Dc] */
//显示下层绘制图片
DST         (2),
/** [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc] */
//正常绘制显示,上下层绘制叠盖。
SRC_OVER    (3),
/** [Sa + (1 - Sa)*Da, Rc = Dc + (1 - Da)*Sc] */
//上下层都显示。下层居上显示。
DST_OVER    (4),
/** [Sa * Da, Sc * Da] */
//取两层绘制交集。显示上层。
SRC_IN      (5),
/** [Sa * Da, Sa * Dc] */
//取两层绘制交集。显示下层。
DST_IN      (6),
/** [Sa * (1 - Da), Sc * (1 - Da)] */
//取上层绘制非交集部分。
SRC_OUT     (7),
/** [Da * (1 - Sa), Dc * (1 - Sa)] */
//取下层绘制非交集部分。
DST_OUT     (8),
/** [Da, Sc * Da + (1 - Sa) * Dc] */
//取下层非交集部分与上层交集部分
SRC_ATOP    (9),
/** [Sa, Sa * Dc + Sc * (1 - Da)] */
//取上层非交集部分与下层交集部分
DST_ATOP    (10),
/** [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc] */
//异或:去除两图层交集部分
XOR         (11),
/** [Sa + Da - Sa*Da,
Sc*(1 - Da) + Dc*(1 - Sa) + min(Sc, Dc)] */
//取两图层全部区域,交集部分颜色加深
DARKEN      (12),
/** [Sa + Da - Sa*Da,
Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)] */
//取两图层全部,点亮交集部分颜色
LIGHTEN     (13),
/** [Sa * Da, Sc * Dc] */
//取两图层交集部分叠加后颜色
MULTIPLY    (14),
/** [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] */
//取两图层全部区域,交集部分变为透明色
SCREEN      (15),
/** Saturate(S + D) */
ADD         (16),
OVERLAY     (17);

Mode(int nativeInt) {
this.nativeInt = nativeInt;
}

/**
* @hide
*/
public final int nativeInt;
}
}


效果如下:



package android.graphics;

/**
* An Insets instance holds four integer offsets which describe changes to the four
* edges of a Rectangle. By convention, positive values move edges towards the
* centre of the rectangle.
* 一个持有四个整数偏移量的插入物,描述了矩形四边的变化。按照惯例,正值朝着矩形中心移动边缘。
* <p>
* Insets are immutable so may be treated as values.
* 插入物是不可改变的,所以可以把它当成值对待。
* @hide
*/
public class Insets {
public static final Insets NONE = new Insets(0, 0, 0, 0);

public final int left;
public final int top;
public final int right;
public final int bottom;

private Insets(int left, int top, int right, int bottom) {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}

// Factory methods

/**
* Return an Insets instance with the appropriate values.
* 根据合理的值返回插入物
* @param left the left inset
* @param top the top inset
* @param right the right inset
* @param bottom the bottom inset
*
* @return Insets instance with the appropriate values
*/
public static Insets of(int left, int top, int right, int bottom) {
if (left == 0 && top == 0 && right == 0 && bottom == 0) {
return NONE;
}
return new Insets(left, top, right, bottom);
}

/**
* Return an Insets instance with the appropriate values.
* 根据合理的值返回插入物
* @param r the rectangle from which to take the values
*
* @return an Insets instance with the appropriate values
*/
public static Insets of(Rect r) {
return (r == null) ? NONE : of(r.left, r.top, r.right, r.bottom);
}

/**
* Two Insets instances are equal if they belong to the same class and their fields are
* pairwise equal.
* 如果两个插入物具有成对相同的值,判断相等。
* @param o the object to compare this instance with.
*
* @return true iff this object is equal {@code o}
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Insets insets = (Insets) o;

if (bottom != insets.bottom) return false;
if (left != insets.left) return false;
if (right != insets.right) return false;
if (top != insets.top) return false;

return true;
}

@Override
public int hashCode() {
int result = left;
result = 31 * result + top;
result = 31 * result + right;
result = 31 * result + bottom;
return result;
}

@Override
public String toString() {
return "Insets{" +
"left=" + left +
", top=" + top +
", right=" + right +
", bottom=" + bottom +
'}';
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: