예제 #1
0
 protected final synchronized void checkPoints() {
   if (pointsDirty) {
     createPoints();
     findCenter();
     calculateRadius();
     if (points == null) {
       return;
     }
     synchronized (points) {
       final int size = points.length;
       if (size > 0) {
         maxX = points[0];
         maxY = points[1];
         minX = points[0];
         minY = points[1];
         for (int i = 0; i < size / 2; i++) {
           maxX = MathUtils.max(points[i * 2], maxX);
           maxY = MathUtils.max(points[(i * 2) + 1], maxY);
           minX = MathUtils.min(points[i * 2], minX);
           minY = MathUtils.min(points[(i * 2) + 1], minY);
         }
       }
       pointsDirty = false;
       trianglesDirty = true;
     }
   }
 }
예제 #2
0
  public static final Cycle getSample(
      int type,
      float srcWidth,
      float srcHeight,
      float width,
      float height,
      float offset,
      int padding) {

    Cycle cycle = new Cycle();
    float s = 1;
    if (srcWidth > srcHeight) {
      s = MathUtils.max(srcWidth / width, srcHeight / height);
    } else {
      s = MathUtils.min(srcWidth / width, srcHeight / height);
    }
    final float scale = s;
    switch (type) {
      case 0:
        cycle =
            new Cycle() {

              private static final long serialVersionUID = 1L;

              private Path path;

              public void step(
                  GLEx g,
                  float x,
                  float y,
                  float progress,
                  int index,
                  int frame,
                  GLColor color,
                  float alpha) {
                float cx = this.padding + 50,
                    cy = this.padding + 50,
                    angle = (MathUtils.PI / 180) * (progress * 360),
                    innerRadius = index == 1 ? 10 : 25;
                if (path == null) {
                  path = new Path(getX() + x * scale, getY() + y * scale);
                } else {
                  path.clear();
                  path.set(getX() + x * scale, getY() + y * scale);
                }
                path.lineTo(
                    getX() + ((MathUtils.cos(angle) * innerRadius) + cx) * scale,
                    getY() + ((MathUtils.sin(angle) * innerRadius) + cy) * scale);
                path.close();
                g.draw(path);
              }
            };
        cycle.setLineWidth(5);
        cycle.setDelay(45);
        cycle.setColor(0xFF2E82);
        cycle.setStepType(4);
        cycle.setStepsPerFrame(1);
        cycle.setTrailLength(1);
        cycle.setPointDistance(0.05f);
        cycle.addPath(Cycle.ARC, 50, 50, 40, 0, 360);
        break;
      case 1:
        cycle.setColor(0xFF7B24);
        cycle.setStepsPerFrame(1);
        cycle.setTrailLength(1);
        cycle.setPointDistance(0.10f);
        cycle.setMultiplier(2);
        cycle.addPath(Cycle.ARC, 10 * scale, 10 * scale, 10 * scale, -270, -90);
        cycle.addPath(
            Cycle.BEZIER,
            10 * scale,
            0 * scale,
            40 * scale,
            20 * scale,
            20 * scale,
            0,
            30 * scale,
            20 * scale);
        cycle.addPath(Cycle.ARC, 40 * scale, 10 * scale, 10 * scale, 90, -90);
        cycle.addPath(
            Cycle.BEZIER,
            40 * scale,
            0 * scale,
            10 * scale,
            20 * scale,
            30 * scale,
            0,
            20 * scale,
            20 * scale);
        break;
      case 2:
        cycle.setColor(0xD4FF00);
        cycle.setStepType(1);
        cycle.setDelay(55);
        cycle.setStepsPerFrame(2);
        cycle.setTrailLength(0.3f);
        cycle.setPointDistance(0.1f);
        cycle.addPath(Cycle.LINE, 0, 0, 30 * scale, 0);
        cycle.addPath(Cycle.LINE, 30 * scale, 0 * scale, 30 * scale, 30 * scale);
        cycle.addPath(Cycle.LINE, 30 * scale, 30 * scale, 0, 30 * scale);
        cycle.addPath(Cycle.LINE, 0, 30 * scale, 0, 0);
        break;
      case 3:
        cycle =
            new Cycle() {

              private static final long serialVersionUID = 1L;

              private Path path;

              public void step(
                  GLEx g,
                  float x,
                  float y,
                  float progress,
                  int index,
                  int frame,
                  GLColor color,
                  float alpha) {

                float cx = this.padding + 50,
                    cy = this.padding + 50,
                    angle = (MathUtils.PI / 180) * (progress * 360);
                alpha = MathUtils.max(0.5f, alpha);
                g.setAlpha(alpha);
                if (path == null) {
                  path = new Path(getX() + x * scale, getY() + y * scale);
                } else {
                  path.clear();
                  path.set(getX() + x * scale, getY() + y * scale);
                }
                path.lineTo(
                    getX() + ((MathUtils.cos(angle) * 35) + cx) * scale,
                    getY() + ((MathUtils.sin(angle) * 35) + cy) * scale);
                path.close();
                g.draw(path);
                if (path == null) {
                  path =
                      new Path(
                          getX() + ((MathUtils.cos(-angle) * 32) + cx) * scale,
                          getY() + ((MathUtils.sin(-angle) * 32) + cy) * scale);
                } else {
                  path.clear();
                  path.set(
                      getX() + ((MathUtils.cos(-angle) * 32) + cx) * scale,
                      getY() + ((MathUtils.sin(-angle) * 32) + cy) * scale);
                }
                path.lineTo(
                    getX() + ((MathUtils.cos(-angle) * 27) + cx) * scale,
                    getY() + ((MathUtils.sin(-angle) * 27) + cy) * scale);
                path.close();
                g.draw(path);
                g.setAlpha(1);
              }
            };
        cycle.setColor(0x05E2FF);
        cycle.setLineWidth(2);
        cycle.setStepType(4);
        cycle.setStepsPerFrame(1);
        cycle.setTrailLength(1);
        cycle.setPointDistance(0.025f);
        cycle.addPath(Cycle.ARC, 50, 50, 40, 0, 360);
        break;
      case 4:
        cycle.setColor(0xFFA50000);
        cycle.setStepsPerFrame(1);
        cycle.setTrailLength(1);
        cycle.setPointDistance(0.025f);
        cycle.addPath(Cycle.ARC, 50 * scale, 50 * scale, 40 * scale, 0, 360);
        break;
      case 5:
        cycle.setColor(0xFF2E82);
        cycle.setDelay(60);
        cycle.setStepType(1);
        cycle.setStepsPerFrame(1);
        cycle.setTrailLength(1);
        cycle.setPointDistance(0.1f);
        cycle.addPath(Cycle.LINE, 0, 20 * scale, 100 * scale, 20 * scale);
        cycle.addPath(Cycle.LINE, 100 * scale, 20 * scale, 0, 20 * scale);
        break;
      case 6:
        cycle.setStepsPerFrame(7);
        cycle.setTrailLength(0.7f);
        cycle.setPointDistance(0.01f);
        cycle.setDelay(35);
        cycle.setLineWidth(10);
        cycle.addPath(Cycle.LINE, 20 * scale, 70 * scale, 50 * scale, 20 * scale);
        cycle.addPath(Cycle.LINE, 50 * scale, 20 * scale, 80 * scale, 70 * scale);
        cycle.addPath(Cycle.LINE, 80 * scale, 70 * scale, 20 * scale, 70 * scale);
        break;
      case 7:
        cycle.setColor(0xD4FF00);
        cycle.setStepsPerFrame(3);
        cycle.setTrailLength(1);
        cycle.setPointDistance(0.01f);
        cycle.setLineWidth(6);
        cycle.setPadding(0);
        cycle.addPath(Cycle.ARC, 50 * scale, 50 * scale, 20 * scale, 360, 0);
        break;
      case 8:
        cycle.setColor(0x05E2FF);
        cycle.setStepsPerFrame(1);
        cycle.setTrailLength(1);
        cycle.setPointDistance(0.02f);
        cycle.addPath(Cycle.ARC, 50 * scale, 50 * scale, 30 * scale, 0, 360);
        break;
      case 9:
        cycle.setStepType(1);
        cycle.setColor(GLColor.yellow);
        cycle.addPath(Cycle.LINE, 10 * scale, 10 * scale, 90 * scale, 10 * scale);
        cycle.addPath(Cycle.LINE, 90 * scale, 10 * scale, 90 * scale, 90 * scale);
        cycle.addPath(Cycle.LINE, 90 * scale, 90 * scale, 10 * scale, 90 * scale);
        cycle.addPath(Cycle.LINE, 10 * scale, 90 * scale, 10 * scale, 10 * scale);
        break;
    }
    float size =
        MathUtils.min(
            srcWidth / (1 / cycle.getPointDistance()), srcHeight / (1 / cycle.getPointDistance()));
    cycle.setPadding(padding);
    cycle.setBlockWidth(size + offset);
    cycle.setBlockHeight(size + offset);
    cycle.setWidth(width * scale);
    cycle.setHeight(height * scale);
    return cycle;
  }