'Simple Fire Effect coded By Ashish. Just for Practice :D
'http://lodev.org/cgtutor/fire.html
'creating our palette for fire
IF i
<= 255 AND i
>= 200 THEN 'white to yellow colorPal
(i
) = _RGB(map
(i
, 255, 200, 255, 255), map
(i
, 255, 200, 255, 242), map
(i
, 255, 200, 255, 0)) colorPal
(i
) = _RGB(map
(i
, 201, 90, 255, 221), map
(i
, 201, 90, 242, 140), map
(i
, 201, 90, 0, 0)) colorPal
(i
) = _RGB(map
(i
, 89, 79, 221, 183), map
(i
, 89, 79, 140, 45), map
(i
, 89, 79, 0, 0)) colorPal
(i
) = _RGB(map
(i
, 78, 48, 183, 10), map
(i
, 78, 48, 45, 10), map
(i
, 78, 48, 0, 10)) colorPal
(i
) = _RGBA(map
(i
, 47, 27, 10, 40), map
(i
, 47, 27, 10, 40), map
(i
, 47, 27, 10, 40), map
(i
, 47, 27, 255, 100)) colorPal
(i
) = _RGBA(map
(i
, 26, 0, 40, 0), map
(i
, 26, 0, 40, 0), map
(i
, 26, 0, 40, 0), map
(i
, 26, 0, 100, 0))'creating an image, placing a text, and storing the white pixel in an array
DIM textPixelPosX
(n
), textPixelPosY
(n
) n = 1
IF POINT(j
, i
) = _RGB(255, 255, 255) THEN textPixelPosX
(n
) = j: textPixelPosY
(n
) = i: n
= n
+ 1
xOff = p5random(-100, 100)
yOff = p5random(-70, 70)
'using stored pixel array to display fire text
xx = textPixelPosX(i) + xOff
yy = textPixelPosY(i) + yOff
fireBuffer
(x
, _HEIGHT - 1) = p5random
(10, 255) fireBuffer(x, y) = (fireBuffer(x - 1, y + 1) + fireBuffer(x, y + 1) + fireBuffer(x + 1, y + 1) + fireBuffer(x, y + 2)) * .2441
PSET (x
, y
), colorPal
(INT(fireBuffer
(x
, y
)))
'taken from p5js.bas
'https://bit.ly/p5jsbas
FUNCTION map!
(value!
, minRange!
, maxRange!
, newMinRange!
, newMaxRange!
) map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
p5random!
= RND * (mx!
- mn!
) + mn!