Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(src.getRotationInDegrees() != 0)
- {
- int pivotX = textLocationX;
- int pivotY = textLocationY;
- cardGfx.drawOval(pivotX - 1, pivotY - 1, 3, 3);
- cardGfx.rotate(src.getRotationInDegrees() * Math.PI / 180.0,
- PivotX,
- PivotY);
- }
- textLocationX -= (hAlign == Horizontal.left ? 0 : hAlign == Horizontal.middle ? (textWidth / 2) : textWidth);
- textLocationY -= (vAlign == Vertical.top ? 0 : vAlign == Vertical .middle ? (textHeight / 2) : textHeight);
- textLocationY += textAdjustmentForHeight;
- With this, the the Pivot is at the top of the text's ... rectangle? if vAlign is top, middle if it's middle, and bottom if it's bottom. It's also at the left if hAlign is left, middle if middle, and right if right.
- drawOval draws an oval (x, y, width, height), and I use it to show where the pivot is.
- cardGfx.rotate applies a transform to the graphics object affecting all future operations. The text is rotated and any points passed such as the drawing point is rotated around the passed pivot X & Y. Actually drawing the text is handled later in the method.
- textAdjustmentForHeight is just an bit of moving down to compensate for the fact that text is drawn with the coörds being the bottom-left rather than the top-left.
- I want pivot(X/Y) to be at the centre of the text regardless of the values of hAlign and vAlign. I have a rotatePoint function that takes a pivot point, point to rotate, and degrees to rotate the point around the pivot point by - my solution that didn't work used this function.
- I asked flare, but apparently, this isn't "Mathsy" enough for him.
Add Comment
Please, Sign In to add comment