Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [SOURCE] Colour palette/chooser
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
s_climax




PostPosted: Sun May 16, 2004 9:39 pm   Post subject: [SOURCE] Colour palette/chooser

code:

setscreen ("graphics:270,240")
var start, finished : boolean := true
var mx, my, mb, col : int
const xsize : int := 15
const ysize : int := 15
loop
    mousewhere (mx, my, mb)
    for x : 1 .. 17
        for y : 1 .. 15
            if start = true then
                drawfillbox (x * xsize, y * ysize, (x + xsize) * xsize, (ysize + y) * ysize, x * y)
            end if
        end for
    end for
    start := false
    if mb = 1 and (mx div xsize) * (my div ysize)<=255 then
        col := (mx div xsize) * (my div ysize)
        finished := false
    end if
    exit when finished = false
end loop
colorback (col)
cls
color (7)
locate(8,15)
put col
color (0)
locate(9,15)
put col
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Mon May 17, 2004 5:18 pm   Post subject: (No subject)

Add RGB to that. Will be more useful.
Pickles




PostPosted: Mon May 17, 2004 5:58 pm   Post subject: ...

heres mine i used for me paint program, i know theres a better way of doing it (i just drew 16 rows 16 times, cause im lazy.)

basically the same thing

code:


View.Set("graphics:351;351,nocursor,nobuttonbar,title:Custom Colours")

var xc, yc, xc2, yc2, xcfill, ycfill, clr, x, y, z, button : int
var font1 := Font.New ("ariel:14")
assert font1>0

xc := 0
yc := 0
xc2 := 20
yc2 := 20
clr := 0

xcfill := xc + 1
ycfill := yc + 1


for a : 0 .. 15

    for b : 0 .. 15

        Draw.Box (xc, yc, xc2, yc2, black)
        Draw.Fill (xcfill, ycfill, clr, black)

        xc += 22
        xc2 += 22
       
        clr += 1

        xcfill := xc + 1
        ycfill := yc + 1
    end for

    xc := 0
    xc2 := 20
    yc += 22
    yc2 += 22

    xcfill := xc + 1
    ycfill := yc + 1

end for

loop

    exit when clr <= 255

    Mouse.Where (x, y, button)

    if button = 1 then

        clr := ((x div 22) + ((y div 22) * 16))

        if clr <= 255 then
            cls
            Draw.FillBox (0, 0, maxx, maxy, clr)
            Draw.FillBox (maxx div 2 - 20, maxy div 2 - 20, maxx div 2 + 20, maxy div 2 + 20, white)
            var clrstring := intstr (clr)
            Font.Draw (clrstring, maxx div 2 - 15, maxy div 2, font1, black)

        end if

    end if

end loop
the_short1




PostPosted: Mon May 24, 2004 6:36 pm   Post subject: (No subject)

very cool.... would be nice for a restart button so i didn;'t have to keep re running the program..!!

good job!




%% fior the guy that just posted for that paint progy
why dsid u use drawfill??? u can use draw.fillbox instead !!

Thinking

but that lookz cool
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: