コード例 #1
0
  public void updateOffset() {
    final float width = width();
    final float height = height();
    final float regionScaleX = width / region.width * scaleX;
    final float regionScaleY = height / region.height * scaleY;
    final float localX = -width * 0.5f * scaleX + region.offsetX * regionScaleX;
    final float localY = -height * 0.5f * scaleY + region.offsetY * regionScaleY;
    final float localX2 = localX + region.width * regionScaleX;
    final float localY2 = localY + region.height * regionScaleY;
    final float radians = MathUtil.degToRad(rotation);
    final float cos = MathUtil.cos(radians);
    final float sin = MathUtil.sin(radians);
    final float localXCos = localX * cos + x;
    final float localXSin = localX * sin;
    final float localYCos = localY * cos + y;
    final float localYSin = localY * sin;
    final float localX2Cos = localX2 * cos + x;
    final float localX2Sin = localX2 * sin;
    final float localY2Cos = localY2 * cos + y;
    final float localY2Sin = localY2 * sin;

    offset[BOTTOM_LEFT_X] = localXCos - localYSin;
    offset[BOTTOM_LEFT_Y] = localYCos + localXSin;
    offset[TOP_LEFT_X] = localXCos - localY2Sin;
    offset[TOP_LEFT_Y] = localY2Cos + localXSin;
    offset[TOP_RIGHT_X] = localX2Cos - localY2Sin;
    offset[TOP_RIGHT_Y] = localY2Cos + localX2Sin;
    offset[BOTTOM_RIGHT_X] = localX2Cos - localYSin;
    offset[BOTTOM_RIGHT_Y] = localYCos + localX2Sin;
  }
コード例 #2
0
 public void color(final float r, final float g, final float b, final float a) {
   this.r = MathUtil.clamp(r, 0.0f, 1.0f);
   this.g = MathUtil.clamp(g, 0.0f, 1.0f);
   this.b = MathUtil.clamp(b, 0.0f, 1.0f);
   this.a = MathUtil.clamp(a, 0.0f, 1.0f);
 }