_TITLE "fTiltEllipse tests" 'b+ 2019-12-15 'test code from "Draw megaphone Test, click 4 points in clockwise direction first pair is one opening and 2nd is 2nd." 'B+ 2019-12-15
CONST xmax
= 800, ymax
= 600
WHILE pi
< 4 'get 4 mouse clicks pi = pi + 1
LINE (mx
(2), my
(2))-(mx
(3), my
(3)) LINE (mx
(4), my
(4))-(mx
(1), my
(1)) ang1
= _ATAN2(my
(2) - my
(1), mx
(2) - mx
(1)) maj1
= (_HYPOT(mx
(1) - mx
(2), my
(1) - my
(2))) / 2 min1 = .1 * maj1
cx1 = (mx(1) + mx(2)) / 2
cy1 = (my(1) + my(2)) / 2
EllipseTilt cx1, cy1, maj1, min1, ang1, &HFFFFFFFF
ang2
= _ATAN2(my
(3) - my
(4), mx
(3) - mx
(4)) maj2
= (_HYPOT(mx
(3) - mx
(4), my
(3) - my
(4))) / 2 min2 = .1 * maj2
cx2 = (mx(3) + mx(4)) / 2
cy2 = (my(3) + my(4)) / 2
EllipseTilt cx2, cy2, maj2, min2, ang2, &HFFFFFFFF
_PRINTSTRING (5, 5), "Sleeping, wake with click or keypress..." 'fTiltEllipse 0, cx2, cy2, maj2, min2, ang2, &H880000FF 'check trnasparency
TiltedEllipseFill 0, cx2, cy2, maj2, min2, ang2, &HFF0000FF 'check trnasparency <<< Toolbox fill
fquad mx(1), my(1), mx(2), my(2), mx(3), my(3), mx(4), my(4), &H880000FF
'fTiltEllipse 0, cx1, cy1, maj1, min1, ang1, &H88FFFF00
TiltedEllipseFill 0, cx1, cy1, maj1, min1, ang1, &HFFFFFF00 '<<<<<<<<<<<<<<<<<<<<<<< Toolbox fill
cSleep 45
pi = 0 'point index
'thanks STxAxTIC from Toolbox
' CX = center x coordinate
' CY = center y coordinate
' a = semimajor axis major radius
' b = semiminor axis minor radius
' ang = clockwise orientation of semimajor axis in radians (0 default)
' C = fill color
FOR k
= 0 TO 6.283185307179586 + .025 STEP .025 i = i + CX
j = -j + CY
'relace broken toolbax code
'this needs RotoZoom3 to rotate image BUT it can now scale it also!
'setup isolated area, draw fFlatEllipse and then RotoZoom the image into destination
'ox, oy is center of ellipse
'majorRadius is 1/2 the lonest axis
'minorRadius is 1/2 the short axis
'radianAngle is the Radian Angle of Tilt
'c is of course color
temp&
= _NEWIMAGE(2 * majorRadius
, 2 * minorRadius
, 32) fEllipse majorRadius, minorRadius, majorRadius, minorRadius, c
RotoZoom3 ox, oy, temp&, 1, 1, radianAngle
'modified 2019-12-15 _seamless added, rotation convert to radians
px(0) = -W& / 2: py(0) = -H& / 2: px(1) = -W& / 2: py(1) = H& / 2
px(2) = W& / 2: py(2) = H& / 2: px(3) = W& / 2: py(3) = -H& / 2
sinr!
= SIN(-radianRotation
): cosr!
= COS(-radianRotation
) x2& = (px(i&) * cosr! + sinr! * py(i&)) + X * xScale: y2& = (py(i&) * cosr! - px(i&) * sinr!) + Y * yScale
px(i&) = x2&: py(i&) = y2&
'this seems to work as well as any
scale = yRadius / xRadius
LINE (CX
, CY
- yRadius
)-(CX
, CY
+ yRadius
), c
, BF
y
= scale
* SQR(xRadius
* xRadius
- x
* x
) LINE (CX
+ x
, CY
- y
)-(CX
+ x
, CY
+ y
), c
, BF
LINE (CX
- x
, CY
- y
)-(CX
- x
, CY
+ y
), c
, BF
' found at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]: http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=14425.0
'2019-11-20 Steve saves some time with STATIC and saves and restores last dest
'need 4 non linear points (not all on 1 line) list them clockwise so x2, y2 is opposite of x4, y4
ftri x1, y1, x2, y2, x4, y4, K
ftri x3, y3, x2, y2, x4, y4, K
SUB cSleep
(secsWait
AS DOUBLE) 'wait for keypress or mouseclick, solves midnight problem nicely I think
wayt = 1
oldMouse
= _MOUSEBUTTON(1) ' <<< this is Steve's cool way to get clear of mouse click IF TIMER + 24 * 60 * 60 - startTime
> secsWait
THEN wayt
= 0
prc
= _RGB32(255, 255, 255, 255) mx2 = max + max
_SOURCE tef&
'point wont read without this! LINE (lasti
, lastj
)-(i
, j
), prc
lasti = i: lastj = j
x = 0
x = x + 1
xleft(y) = x
x = x + 1
x = x + 1
IF x
= mx2
THEN xright
(y
) = xleft
(y
) ELSE xright
(y
) = x
IF xleft
(y
) <> mx2
THEN LINE (xleft
(y
) + x0
- max
, y
+ y0
- max
)-(xright
(y
) + x0
- max
, y
+ y0
- max
), c
, BF