コード例 #1
0
ファイル: BezRectangle.java プロジェクト: plural/IgnoCodeLib
 // TODO consider how best to obtain and format this
 public float[] getCoords() {
   // include startPoint in the array
   float[] coords = new float[this.curves().size() * 2 + 2];
   int i = 0;
   coords[i++] = this.x();
   coords[i++] = this.y();
   for (Vertex2DINF pt : super.curves()) {
     coords[i++] = pt.x();
     coords[i++] = pt.y();
   }
   return coords;
 }
コード例 #2
0
ファイル: BezRectangle.java プロジェクト: plural/IgnoCodeLib
 /**
  * @param vt1 a LineVertex for interpolation
  * @param r1 a source rectangle for mapping
  * @param r2 a destination rectangle for mapping
  * @return a LineVertex mapped to the destination rectangle
  */
 public static Vertex2DINF map(Vertex2DINF vt1, BezRectangle r1, BezRectangle r2) {
   double x0 = vt1.x();
   double vlo = r1.getLeft();
   double vhi = r1.getRight();
   double dlo = r2.getLeft();
   double dhi = r2.getRight();
   double x1 = BezRectangle.map(x0, vlo, vhi, dlo, dhi);
   double y0 = vt1.y();
   vlo = r1.getTop();
   vhi = r1.getBottom();
   dlo = r2.getTop();
   dhi = r2.getBottom();
   double y1 = BezRectangle.map(y0, vlo, vhi, dlo, dhi);
   return new LineVertex((float) x1, (float) y1);
 }
コード例 #3
0
ファイル: BezRectangle.java プロジェクト: plural/IgnoCodeLib
 /**
  * Updates local tracking of rectangle top, left, bottom, right, width and height. Sets
  * needsUpdate to false. If the {@link #bounds(PApplet)} of this BezRectangle no longer
  * corresponds to the top, left, bottom and right, {@link #isAligned} will be set to false to flag
  * that the rectangle has been transformed out of alignment with the x and y axes of the world
  * system. Call after any geometric transformation of the points of this rectangle by your code.
  * Methods in this class that change geometry will call update for you.
  */
 public void update() {
   this.left = this.x();
   this.top = this.y();
   Vertex2DINF br = this.curves().get(1);
   this.right = br.x();
   this.bottom = br.y();
   this.width = this.right - this.left;
   this.height = this.bottom - this.top;
   this.needsUpdate = false;
   float[] box = super.bounds(parent);
   if (box[0] == this.left
       && box[1] == this.top
       && box[2] == this.right
       && box[3] == this.bottom) {
     this.isAligned = true;
   } else {
     this.isAligned = false;
   }
 }