DIR Return Create A Forum - Home
---------------------------------------------------------
techno game dev forum
HTML https://technogamedevforum.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: General Discussion
*****************************************************
#Post#: 118--------------------------------------------------
EXACT Colours
By: mr why Date: May 24, 2012, 3:36 am
---------------------------------------------------------
This gets you the colours you want and you know what you are
getting.
It is a "colour picker" and no matter which screen or monitor
you use you get the colour you pick. (The next thing you draw is
thet colour and none other. No theory; no broken promises!)
The chart below show all the colours that YOUR monitor screen is
ABLE to show.
Run it in qb64 nd you will see them all:
[code]
DIM colour&(32), r(400, 480), B(400, 480), g(400, 480)
SCREEN _NEWIMAGE(640, 480, 32)
WINDOW (-440, -240)-(439, 239)
_FULLSCREEN
kk = 90
kkc = 130
kkd = 100
kky = 105
kkg = 130
kkb = 150
FOR x = -200 TO 200
xx = x + 200
FOR y = -200 TO 200
yy = y + 200
GOSUB quickcalc
r(xx, yy) = 320 * EXP(-ABS(x / kkc) - ABS(y - 200) /
kkc)
B(xx, yy) = 335 * EXP(-ABS(x - 200) / kkb - ABS(y) /
kkb)
g(xx, yy) = 320 * EXP(-ABS(x / kkg) - ABS(y + 200) /
kkg)
r(xx, yy) = r(xx, yy) + 310 * EXP(-ABS(x + 200) / kky -
ABS(y) / kky)
g(xx, yy) = g(xx, yy) + 310 * EXP(-ABS(x + 200) / kky -
ABS(y) / kky)
'xx,yy from 0 to 400,
r(xx, yy) = r(xx, yy) + (255 - r(xx, yy)) * calc1
g(xx, yy) = g(xx, yy) + (255 - g(xx, yy)) * calc1
B(xx, yy) = B(xx, yy) + (255 - B(xx, yy)) * calc1
r(xx, yy) = r(xx, yy) + (255 - r(xx, yy)) * calc2
g(xx, yy) = g(xx, yy) + (255 - g(xx, yy)) * calc2
B(xx, yy) = B(xx, yy) + (255 - B(xx, yy)) * calc2
r(xx, yy) = r(xx, yy) + (255 - r(xx, yy)) * calc3
g(xx, yy) = g(xx, yy) + (255 - g(xx, yy)) * calc3
B(xx, yy) = B(xx, yy) + (255 - B(xx, yy)) * calc3
r(xx, yy) = r(xx, yy) + (255 - r(xx, yy)) * calc4
g(xx, yy) = g(xx, yy) + (255 - g(xx, yy)) * calc4
B(xx, yy) = B(xx, yy) + (255 - B(xx, yy)) * calc4
r(xx, yy) = r(xx, yy) * calc5
g(xx, yy) = g(xx, yy) * calc5
B(xx, yy) = B(xx, yy) * calc5
PSET (x, y), _RGB32(r(xx, yy), g(xx, yy), B(xx, yy))
NEXT y
NEXT x
END
quickcalc:
calc1 = EXP(-(((ABS(xx) + ABS(yy))) / kk))
calc2 = EXP(-(((ABS(xx - 400) + ABS(yy - 400))) / kk))
calc3 = EXP(-(((ABS(xx - 400) + ABS(yy))) / kk))
calc4 = EXP(-(((ABS(xx) + ABS(yy - 400))) / kk))
calc5 = (1 - EXP(-(((ABS(x) + ABS(y))) / (kkd))))
RETURN
[/code]
Now in QB64 Wiki is "explained" how you slide your mouse over
the chart and pick exactly the colour you want. Now you see WHY
it is useful, give it a try!
With so many millions of coulors it is made a bit complicated.
Each colour is made by a recipe of 0 to 255 tots of the 3
primary colours, giving "as dark as your screen gets" to bright
white via all colours in between.
But this chart gets rid of all that fuss and bother (inventing
colours NOT those actually on YOUR screen).
And the command that tells you the state-of-screen at the point
where you have put the mouse is well worth knowing and useful
for other purposes!
Have FUN
Mr Why
*****************************************************