I have attached a video showing my selection rectangle with handles.
Graphics are drawn using a BGRABitmap BGLVirtualScreen.
with an ANGLE of 0 degreesAs can be seen, when the left side handle 'LS' is moved, the rectangle grows in width whilst the right side remains in a fixed position as I require.
The same can be seen when the Rightside RS handles is moved as is expected, and the Corner sizers NW,NE,SW,SE.
Also, The rotator arm works and the rectangle can be rotated using the mouse. All good thus far.
However, when the Angle is not Zero, I cannot get the opposite side to stay in place. As can be seen it moves so does not stay fixed (Fixed:=The hoped for outcome)!
The Rectangle is positioned using its Centre Position.
When at a non zero ANGLE (degrees), as the rectangle changes size, how can I work out the new centre position based upon a corner position?
CURRENTLY:
Sizing is done as follows:
1] Rotate to Zero Degrees
2] Size the Rectangle
3] Rotate Back to require Degrees
4] Draw
This is how I represent the Selector Rectangle:
aSpr = record
//SprImg: TBGLBitmap;
SprImg: TBGRABitmap;
Spr:IBGLTexture;
iCXPos, iCYPos: single;
end;
//My Selector Type
aSelect = record
Centre: aVec2F; //Centre Point Or Local Origin
//Size of Obj Select Rect
iW: integer; //Dims of Select Rectangle
iH: integer;
//Size of Sizer Sprs
iSizerSize: integer;
//Corner Sizers
NW: aSpr; //Top Left Corner Sizer
NE: aSpr; //Top Right Corner Sizer
SW: aSpr; //Bottom Left Corner Sizer
SE: aSpr; //Bottom Right Corner Selector
//Edge Sizers
LS: aSpr; //Left Sizer (Mid Height Left)
TS: aSpr; //Top Sizer (Mid Width Top)
RS: aSpr; //Right Sizer (Mid Height Right)
BS: aSpr; //Bottom Sizer (Mid Width Bottom)
//Rotator
Rotator: aSpr; //Handle to Rotate with
fAngle: single; //Angle to draw at
bVisible: boolean; //Is it Visible?
//Standard Colours
tSelectorCol: TBGRAPixel;
tLineColor: TBGRAPixel;
//Locked Colours (unable to size/move/rotate)
end;
Getting Balder (pulling hair out) by the minute!!