public void readjustSize() { RectangleX frame = _texture.frame; float w = frame != null ? frame.width : texture.width; float h = frame != null ? frame.height : texture.height; vertices[0] = new Vector3X(0, 0); vertices[1] = new Vector3X(w, 0); vertices[2] = new Vector3X(w, h); vertices[3] = new Vector3X(0, h); }
protected void init(float w, float h) { vertices = new Vector3X[4]; translatorVertices = new Vector3X[4]; uvs = new Vector2X[4]; vertices[0] = new Vector3X(0, 0); vertices[1] = new Vector3X(w, 0); vertices[2] = new Vector3X(w, h); vertices[3] = new Vector3X(0, h); uvs[0] = new Vector2X(0, 0); uvs[1] = new Vector2X(1, 0); uvs[2] = new Vector2X(1, -1); uvs[3] = new Vector2X(0, -1); }
internal override Vector3X[] adjustVertices(Vector3X[] vertices, Vector3X[] result = null) { float deltaRight = mFrame.width + mFrame.x - mWidth; float deltaBottom = mFrame.height + mFrame.y - mHeight; if (result == null) { result = new Vector3X[4]; } float[] deltaX = new float[] { -mFrame.x, -deltaRight, -deltaRight, -mFrame.x }; float[] deltaY = new float[] { -mFrame.y, -mFrame.y, -deltaBottom, -deltaBottom }; Vector3X temp; for (int i = 0; i < 4; i++) { temp = vertices[i]; result[i] = new Vector3X(temp.x + deltaX[i], temp.y + deltaY[i]); } return(result); }
public override RectangleX getBounds(DisplayObjectX targetSpace) { RectangleX resultRect = new RectangleX(); if (targetSpace == this) // optimization { resultRect.setTo(0.0f, 0.0f, vertices[2].x, vertices[2].y); } else if (targetSpace == parent && rotation == 0.0) // optimization { float scaleX = this.scaleX; float scaleY = this.scaleY; Vector3X v = vertices[2]; resultRect.setTo(x - pivotX * scaleX, y - pivotY * scaleY, v.x * scaleX, v.y * scaleY); if (scaleX < 0) { resultRect.width *= -1; resultRect.x -= resultRect.width; } if (scaleY < 0) { resultRect.height *= -1; resultRect.y -= resultRect.height; } } else { getTransformationMatrix(targetSpace, sHelperTransform); float minX = float.MaxValue; float maxX = -float.MaxValue; float minY = float.MinValue; float maxY = -float.MinValue; int len = vertices.Length; for (int i = 0; i < len; i++) { Vector3X v = sHelperTransform.transformVector(vertices[i]); if (minX > v.x) { minX = v.x; } if (maxX < v.x) { maxX = v.x; } if (minY > v.y) { minY = v.y; } if (maxY < v.y) { maxY = v.y; } } resultRect.setTo(minX, minY, maxX - minX, maxY - minY); } return(resultRect); }
public Vector3 Randomize() { return(Vector3X.RandomUniform(minScale, maxScale)); }