' 2019-12-16 updates to my Toolbox Listing
'2019-12-16 fix by Steve saves some time with STATIC and saves and restores last dest
_BLEND a&
'<<<< new 2019-12-16 fix
'update 2019-12-16 needs updated fTri 2019-12-16 I like this ordering of points better
'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, x3, y3, K
ftri x3, y3, x4, y4, x1, y1, K
' 2019-12-16 this should have been in here earlier
' CX = center x coordinate
' CY = center y coordinate
' a = semimajor axis
' b = semiminor axis
' C = fill color
w2 = a * a
h2 = b * b
h2w2 = h2 * w2
LINE (CX
- a
, CY
)-(CX
+ a
, CY
), C
, BF
y = y + 1
x
= SQR((h2w2
- y
* y
* w2
) \ h2
) LINE (CX
- x
, CY
+ y
)-(CX
+ x
, CY
+ y
), C
, BF
LINE (CX
- x
, CY
- y
)-(CX
+ x
, CY
- y
), C
, BF
'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 'not sure about the stepper it should depend on a and b i = i + CX
j = -j + CY
'relace toolbox code 2019-12-16
'this needs RotoZoom3 to rotate image and EllipseFill to make the 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
EllipseFill majorRadius, minorRadius, majorRadius, minorRadius, c
RotoZoom3 ox, oy, temp&, 1, 1, radianAngle
' this assumes you have set your drawing location with _dest or default to screen
' X, Y is where you want to put the middle of the image
' Image is the handle assigned with _LOADIMAGE
' xScale, yScale are shrinkage < 1 or magnification > 1 on the given axis
' radianRotation is the Angle in Radian units to rotate the image
DIM W&
, H&
, sinr!
, cosr!
, i&
, x2&
, y2&
' variables for image manipulation px(0) = -W& / 2: py(0) = -H& / 2 'left top corner
px(1) = -W& / 2: py(1) = H& / 2 ' left bottom corner
px(2) = W& / 2: py(2) = H& / 2 ' right bottom
px(3) = W& / 2: py(3) = -H& / 2 ' right top
sinr!
= SIN(-radianRotation
): cosr!
= COS(-radianRotation
) ' rotation helpers FOR i&
= 0 TO 3 ' calc new point locations with rotation and zoom x2& = xScale * (px(i&) * cosr! + sinr! * py(i&)) + X: y2& = yScale * (py(i&) * cosr! - px(i&) * sinr!) + Y
px(i&) = x2&: py(i&) = y2&
'=================================================================================================================== String stuff
'---------------------------------------------------------------------
'RhoSigma keeps saying final version but then...
'here is reference: https://www.qb64.org/forum/index.php?topic=1933.msg112096#msg112096
'Function: Convert any given dec/hex/oct number into a binary string.
' Can handle positive and negative values and works in that
' similar to the QB64 built-in HEX$ and OCT$ functions.
'
'Synopsis: binary$ = BIN$ (value&&)
'
'Result: binary$ --> the binary representation string of the given
' number without leading zeros for positive values
' and either 8/16/32 or 64 chars for negatives,
' depending on the input size
'
'Inputs: value&& --> the pos./neg. number to convert, may also be
' given as &H or &O prefixed value
'
'Notes: You may also pass in floating point values, as long as its
' represented value fits into the _INTEGER64 (&&) input, hence
' approx. -9.223372036854776E+18 to 9.223372036854776E+18.
' Different from HEX$ and OCT$, BIN$ won't throw an overflow
' error, if this range is exceeded, but the result is probably
' wrong in such a case.
'---------------------------------------------------------------------
'--- option _explicit requirements ---
DIM temp~&&
, charPos%
, highPos%
'--- init ---
temp~&& = value&&
BIN$
= STRING$(64, "0"): charPos%
= 64: highPos%
= 64'--- convert ---
IF (temp~&&
AND 1) THEN MID$(BIN$
, charPos%
, 1) = "1": highPos%
= charPos%
charPos% = charPos% - 1: temp~&& = temp~&& \ 2
'--- adjust negative size ---
IF -value&&
< &HFFFFFFFF~&
THEN highPos%
= 33 IF -value&&
< &H0000FFFF~&
THEN highPos%
= 49 IF -value&&
< &H000000FF~&
THEN highPos%
= 57 IF -value&&
< &H00000000~&
THEN highPos%
= 1 '--- set result ---
BIN$
= MID$(BIN$
, highPos%
)
'update 2019-12-16 in ...test\graphics\fTri tests.bas SLEEP with a click
SUB cSleep
(secsWait
AS DOUBLE) 'wait for keypress or mouseclick, solves midnight problem nicely I think oldMouse = -1 '2019-12-16 2nd fix today assume an old mouse click is still active
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