News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Simple colorpicker

Started by stef, January 12, 2006, 11:44:44 AM

Previous topic - Next topic

stef

Hi!

a simple colorpicker for demostration

made with v1.089z


PlayBASIC Code: [Select]
; PROJECT : colorpicker
; AUTHOR : stef
; CREATED : 11.01.2006
; EDITED : 11.01.2006
; ---------------------------------------------------------------------

;made with V1.089z

screenw=1024
screenh=768
openscreen screenw,screenh,32,1

constant c=255
constant c1=256

dim col#(c1*4,3)
for x=0 to c

col#(x,1)=c
col#(x,2)=x
col#(x,3)=0
col#(x+c1,1)=c-x
col#(x+c1,2)=c
col#(x+c1,3)=x
col#(x+c1*2,1)=0
col#(x+c1*2,2)=c-x
col#(x+c1*2,3)=c
col#(x+c1*3,1)=x
col#(x+c1*3,2)=0
col#(x+c1*3,3)=c-x

next
lockbuffer
colorim= newimage(screenw,screenh)
rendertoimage colorim

for ypos#= 0 to c
for xpos = 0 to screenw

r=col#(xpos,1)*(ypos#/255.0)
g=col#(xpos,2)*(ypos#/255.0)
b=col#(xpos,3)*(ypos#/255.0)

dotc xpos,ypos#,rgb(r,g,b)

r=col#(xpos,1)+ypos#
g=col#(xpos,2)+ypos#
b=col#(xpos,3)+ypos#
If r>c Then r=c
If g>c Then g=c
If b>c Then b=c

dotc xpos,ypos#+c1,rgb(r,g,b)
Next
Next
unlockbuffer

do
rendertoscreen
cls 0
drawimage colorim,0,0,1
if mousey()>=0 and mousey()<=512
color=Point(mousex(),mousey())
else color=0

endif

setcursor 0,530
ink rgb(c,c,c)
print Hex$(color)
print color
print "r= "+str$(r)
print "g= "+str$(g)
print "b= "+str$(b)

ink color
r=GetInkR()
g=GetInkg()
b=GetInkb()

boxc screenw/2-200,540,screenw/2+200,600,1,color
sync
if esckey()=true then end
loop



Digital Awakening

It's a bit big perhaps but all you need are buttons to copy the color info the user wants into memory.
Wisit my site at: DigitalAwakening.net

stef

Hi!

Of course it's a bit big, but this isn't really an application!
It shows how to handle colorpicking in codes.
(with colorpicking you can do very complicated operations!)

For app I would make it probably in a different way!

Greetings
stef

Ian Price

I came. I saw. I played some Nintendo.