_TITLE "Trippy Bedsheet Swing With Morphing Colors" 'translated from SmallBASIC: Goldwave by johnno copied and mod by bplus 2018-01-28
'trippy bedsheet mod by fellippeheitor 2018-03-14
'_FULLSCREEN _SQUAREPIXELS , _SMOOTH
' compare fill triangle subs: one uses very simple _MAPTRIANGLE opt = 1
' 2nd uses primative line graphic0s opt <> 1
opt = 1 ' << opt 1 uses _MAPTRIANGLE to fill triangles, any other uses line filled triangles
ccc = hsb(angle, 127, 127, 255)
angle = angle + 10
x = (12 * (24 - x1)) + (12 * y1)
y = (-6 * (24 - x1)) + (6 * y1) + 300
d = ((10 - x1) ^ 2 + (10 - y1) ^ 2) ^ .5
h
= 60 * SIN(x1
/ 4 + t
) + 65 IF t
> 20 AND t
< 30 THEN h
= 60 * SIN((x1
- y1
) / 4 + t
) + 65 IF t
> 30 AND t
< 40 THEN h
= 30 * SIN(x1
/ 2 + t
) + 30 * SIN(y1
/ 2 + t
) + 65 IF t
> 40 AND t
< 50 THEN h
= 60 * SIN((x1
+ y1
) / 4 + t
) + 65 'TOP
filltri x, y - h, x + 10, y + 5 - h, x + 20, y - h, Shade(ccc, h)
filltri x, y - h, x + 10, y - 5 - h, x + 20, y - h, Shade(ccc, h)
''FRONT-LEFT
'filltri x, y - h, x + 10, y + 5 - h, x + 10, y, Shade(ccc, h * .4)
'filltri x, y - h, x, y - 5, x + 10, y, Shade(ccc, h * .4)
''FRONT-RIGHT
'filltri x + 10, y + 5 - h, x + 10, y, x + 20, y - 5, Shade(ccc, h * 1.2)
'filltri x + 10, y + 5 - h, x + 20, y - h, x + 20, y - 5, Shade(ccc, h * 1.2)
filltri2 x, y - h, x + 10, y + 5 - h, x + 20, y - h
filltri2 x, y - h, x + 10, y - 5 - h, x + 20, y - h
'FRONT-LEFT
filltri2 x, y - h, x + 10, y + 5 - h, x + 10, y
filltri2 x, y - h, x, y - 5, x + 10, y
filltri2 x + 10, y + 5 - h, x + 10, y, x + 20, y - 5
filltri2 x + 10, y + 5 - h, x + 20, y - h, x + 20, y - 5
'Andy Amaya's modified FillTriangle
SUB filltri2
(xx1
, yy1
, xx2
, yy2
, xx3
, yy3
) 'make copies before swapping
x1 = xx1: y1 = yy1: x2 = xx2: y2 = yy2: x3 = xx3: y3 = yy3
'thanks Andy Amaya!
'triangle coordinates must be ordered: where x1 < x2 < x3
IF x1
<> x3
THEN slope1
= (y3
- y1
) / (x3
- x1
)
'draw the first half of the triangle
length = x2 - x1
slope2 = (y2 - y1) / (x2 - x1)
'lastx2% = lastx%
'draw the second half of the triangle
y = length * slope1 + y1: length = x3 - x2
slope3 = (y3 - y2) / (x3 - x2)
'IF INT(x + x2) <> lastx% AND INT(x + x2) <> lastx2% THEN 'works! but need 2nd? check
' 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
FUNCTION Shade~&
(WhichColor~&
, ByHowMuch%
) Shade~&
= _RGB32(_RED32(WhichColor~&
) * (ByHowMuch%
/ 100), _GREEN32(WhichColor~&
) * (ByHowMuch%
/ 100), _BLUE32(WhichColor~&
) * (ByHowMuch%
/ 100))
'Functions below come from p5js.bas
H = map(__H, 0, 255, 0, 360)
S = map(__S, 0, 255, 0, 1)
B = map(__B, 0, 255, 0, 1)
hsb~&
= _RGBA32(B
* 255, B
* 255, B
* 255, A
)
fmx = B - (B * S) + S
fmn = B + (B * S) - S
fmx = B + (B * S)
fmn = B - (B * S)
H = H - 360
H = H / 60
H
= H
- (2 * INT(((iSextant
+ 1) MOD 6) / 2))
fmd = (H * (fmx - fmn)) + fmn
fmd = fmn - (H * (fmx - fmn))
FUNCTION map!
(value!
, minRange!
, maxRange!
, newMinRange!
, newMaxRange!
) map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!