public static Affine flip(boolean horiz, boolean vert) { return new Affine(horiz ? -1 : 1, 0, 0, vert ? -1 : 1, 0, 0); }
public float multiply_px(float x, float y) { return x * a + y * c + e; }
public float multiply_py(float x, float y) { return x * b + y * d + f; }
+ public boolean equalsIgnoringTranslation(Affine x) { return a == x.a && b == x.b && c == x.c && d == x.d; }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof Affine)) return false;
+ Affine x = (Affine)o;
+ return a == x.a && b == x.b && c == x.c && d == x.d && e == x.e && f == x.f;
+ }
public static Affine rotate(float degrees) {
float s = (float)Math.sin(degrees * (float)(Math.PI / 180.0));
static final byte TYPE_CUBIC = 3;
static final byte TYPE_QUADRADIC = 4;
- // FEATURE: make this faster and cache it; also deal with negative coordinates
- public int boundingBoxWidth() {
- int ret = 0;
- for(int i=0; i<numvertices; i++) ret = Math.max(ret, (int)Math.ceil(x[i]));
- return ret;
- }
-
- // FEATURE: make this faster and cache it; also deal with negative coordinates
- public int boundingBoxHeight() {
- int ret = 0;
- for(int i=0; i<numvertices; i++) ret = Math.max(ret, (int)Math.ceil(y[i]));
- return ret;
- }
-
/** Creates a concrete vector path transformed through the given matrix. */
public RasterPath realize(Affine a) {
int[] edges = new int[DEFAULT_PATHLEN];
int numedges = 0;
+ /** translate a rasterized path */
+ public void translate(int dx, int dy) { for(int i=0; i<numvertices; i++) { x[i] += dx; y[i] += dy; } }
+
/** simple quicksort, from http://sourceforge.net/snippet/detail.php?type=snippet&id=100240 */
int sort(int left, int right, boolean partition) {
if (partition) {
} while(pos < segmentLength);
}
}
+
+ // FEATURE: make this faster and cache it; also deal with negative coordinates
+ public int boundingBoxWidth() {
+ int ret = 0;
+ for(int i=0; i<numvertices; i++) ret = Math.max(ret, x[i]);
+ return ret;
+ }
+
+ // FEATURE: make this faster and cache it; also deal with negative coordinates
+ public int boundingBoxHeight() {
+ int ret = 0;
+ for(int i=0; i<numvertices; i++) ret = Math.max(ret, y[i]);
+ return ret;
+ }
}