Color + Alpha is killing me.... (Language Help)

by Jim ⌂ @, Russell, KY, Wednesday, February 06, 2013, 02:14 (1508 days ago) @ Jim

Here is your program written for 0.9.9.45. Much easier without all of that binary stuff. Thinking about your program I do not think it would have worked if alpha had been less than 128.

The next release will allow you to do.


#color value decomposition and recreation
#*****************************************
if version < 90945 then
print "requires version 0.9.9.45 or better"
end
end if

clg
cls
graphsize 300,300
fastgraphics
dim col(20)
col={black,white,red,darkred,green,darkgreen,blue,darkblue, cyan,darkcyan,purple, darkpurple,yellow,darkyellow,orange, darkorange, grey,darkgrey}

for i = 0 to 16 step 2
colorid=col[i]
coloridb = blauw(colorid)
coloridg = groen(colorid)
coloridr = rood(colorid)
colorida= alpha(colorid)
color colorid
rect ((i)*10),20,20,20
print coloridr + " " + coloridg + " " + coloridb + " " + colorida
color rgb(coloridr, coloridg, coloridb, colorida)
rect ((i)*10),100,20,20
refresh
cls
print "color as binary ="+ tobinary(colorid)
input "press 'enter' for the next color", foo$
refresh
next i

for i = 1 to 17 step 2
colorid=col[i]
color colorid
rect ((i-1)*10),40,20,20
liftcolor = pixel(((i-1)*10),40) # pick the color up from the screen
coloridb = blauw(liftcolor)
coloridg = groen(liftcolor)
coloridr = rood(liftcolor)
colorida= alpha(liftcolor)
color rgb(coloridr, coloridg, coloridb, colorida)
rect ((i-1)*10),120,20,20
refresh
cls
print "color as binary ="+ tobinary(colorid)
input "press 'enter' for the next color", foo$
refresh
next i
end

function alpha(hexcol)
alpha = hexcol/256/256/256%256
end function

function rood(hexcol)
rood = hexcol/256/256%256
end function

function groen(hexcol)
groen = hexcol/256%256
end function

function blauw(hexco)
blauw = hexco%256
end function


Complete thread:

 RSS Feed of thread

powered by my little forum