
-----------------------------------
neufelni
Mon Apr 25, 2005 12:33 pm

colour guide program
-----------------------------------
Here is a program that gives the number and shows the colour of all 256 Turing colours.

 

%Nick
%April, 22/2005
%Colour Guide

var col := 0
var do : string (1)

loop
    put col
    Draw.FillBox (100, 100, 300, 300, col)
    getch (do)
    if do = (KEY_RIGHT_ARROW) then
        col := col + 1
        cls
    elsif do = (KEY_LEFT_ARROW) then
        col := col - 1
        cls
    end if
end loop

-----------------------------------
jamonathin
Mon Apr 25, 2005 1:31 pm


-----------------------------------
What if i wanna know what color 254 is?  don't wanna have to wait that long.  Try and make a program that's much faster, and displays all colors and numbers.  There's a few of these types of programs on this site as well.

-----------------------------------
Shyfire
Tue Apr 26, 2005 1:23 pm


-----------------------------------
you could make it faster

-----------------------------------
dann_west
Thu Apr 28, 2005 1:32 pm

Re: colour guide program
-----------------------------------
Pretty Good Nick but it is a slow program.You show make it so you type in a # and it shows the colour.

-----------------------------------
DarkAng
Thu May 12, 2005 3:30 pm

colour
-----------------------------------
here is one that i made that will be faster and lets u choose a colour
%Colour display program.
var window : int := Window.Open ("graphics:max;max")
var typeChoice, colourChoice, backgroundChoice : int
setscreen ("buttonbar")
%Two different modes.
procedure choice (number : int)

    %Displays colours one at a time.
    if number = 1 then
        for colours : 1 .. 255
            colourback (colours)
            put colours, "     ", colours, "     ", colours, "     ", colours, "     ", colours, "     ", colours, "     ", colours, "     ", colours
            delay (50)
        end for

        %Displays the chosen colour.
    else
        put "Enter the number of the colour you wish to view."
        loop
            get backgroundChoice
            colourback (backgroundChoice)
            cls
        end loop
    end if

end choice

%Asks what how the user wants the colours displayed.
put "Would you like to see the colours one by one, or would you like to pick a number?"
put "1 : show colours one at a time"
put "2 : pick number and display colour"
get typeChoice
choice (typeChoice)

-----------------------------------
neufelni
Wed May 25, 2005 11:05 am


-----------------------------------
A few problems with DarkAng's program. First of all, if you choose to go through the colours one at a time, it goes way too fast to view the colours and the number, and you can't go back up, so you can't view the top colours again unless you restart the program. Secondly, because the numbers are in black you can't see what number the darker colours are.

-----------------------------------
DarkAng
Wed May 25, 2005 3:37 pm


-----------------------------------
A few problems with DarkAng's program. First of all, if you choose to go through the colours one at a time, it goes way too fast to view the colours and the number, and you can't go back up, so you can't view the top colours again unless you restart the program. Secondly, because the numbers are in black you can't see what number the darker colours are.

yes thats true but you can pause the program  thats what the
setscreen ("buttonbar") is for.
+ if you want to slow it down you can just increase the delay near the beginning of the program.  i purposely made it faster so i could just scan through the colours

-----------------------------------
Flikerator
Thu May 26, 2005 1:20 pm


-----------------------------------
For the second option you may want to error trap it so that if a number > 255 is entered then it doesn't exit the program.  :)

-----------------------------------
neufelni
Thu May 26, 2005 2:03 pm


-----------------------------------
I made a better colour guide program so that you can see the number and you can easily view all the colours. Here it is :
var number, choose : int
put "1. Go through all the colours."
put "2. Choose a number to view the colour."
get choose
cls
if choose = 1 then
    View.Set ("graphics:800;4600")
    for c : 0 .. 255
        colourback (c)
        colour (black)
        put c, "     " ..
        colour (white)
        put c
    end for
elsif choose = 2 then
    View.Set ("graphics:600;400")
    loop
        colour (black)
        put "Enter a number to view the colour."
        colour (white)
        put "Enter a number to view the colour."
        get number 
        colourback (number)
        cls
    end loop
end if

-----------------------------------
the_binary_soul
Fri May 27, 2005 9:36 am


-----------------------------------
here is my version I did last year. Probably could be made shorter... meh

(did this last year I believe)


setscreen ("graphics")


var KEY : string (1)
var SEARCH : int
var POINT : int
var i : int := 0



proc START
    cls
    put " enter colour number to start scrolling from, press enter to return"
    color (55)
    put " use arrow keys to scroll up or down, press ESC to exit"
    get POINT
    i := POINT
end START


proc DISPLAY
    loop

        if i = -1 then
            i := 255
        elsif i > 255 then
            i := 0
        end if


        color (i)
        Draw.FillBox (1, 400, 500, 300, i)
        put "colour "
        color (255)
        put i

        getch (KEY)
        if ord (KEY) = 10 then
            START
        elsif ord (KEY) = 200 then
            i += 1
        elsif ord (KEY) = 208 then
            i -= 1
        end if
        cls


        if i = 255 then
            i := 0
        end if

        exit when ord (KEY) = 27
    end loop

end DISPLAY





START
DISPLAY



-----------------------------------
RaPsCaLLioN
Fri May 27, 2005 10:12 am


-----------------------------------
Here's my version.

var iWindow : int := Window.Open ("graphics:svga, noecho, nocursor")
for i : 0 .. 86
    drawfillbox (i * 6, 1, i * 6 + 6, 100, i)
end for
for i : 0 .. 86
    drawfillbox (i * 6, 105, i * 6 + 6, 205, i + 86)
end for
for i : 0 .. 86
    drawfillbox (i * 6, 210, i * 6 + 6, 310, i + 86 + 83)
end for
var x, y, b : int
loop
    mousewhere (x, y, b)
    put "Color Default ID Number: ", whatdotcolour (x, y)
    locate (1, 1)
    exit when buttonmoved ("down")
end loop
Window.Close (iWindow)

-----------------------------------
the_binary_soul
Fri May 27, 2005 10:27 am


-----------------------------------
damn, I'm beat.... only. How come black at the end shows up as 7. Should it not be 255?

-----------------------------------
RaPsCaLLioN
Fri May 27, 2005 1:33 pm


-----------------------------------
meh... black is black

-----------------------------------
jamonathin
Fri May 27, 2005 4:54 pm


-----------------------------------
Guys, keep it simple.  A color-guide program is something you can make fast, on the spot, not have to look it up and load it.

try this.

for i: 1 .. maxcolor
color(i)
put i, " " ..
end for

And for better color results just put

colorback(black)
cls before the proggy.

-----------------------------------
Cervantes
Fri May 27, 2005 5:53 pm


-----------------------------------
Except, it's a lot harder to use that.  Each colour only appears as text and doesn't really allow you to see much about that colour.  The light colours barely show up against white, and the dark colours barely show up against black.  
Also, there's no reason to not make this more complex.  I agree, there are much better complex programs to spend time on. But that should not deter doing this; it should just bump it down the to do list.  :wink:
I prefer:

View.Set ("graphics:max;4120")
for i : 0 .. 255
    colourback (i)
    put i
end for



How come black at the end shows up as 7. Should it not be 255?


http://www.compsci.ca/v2/viewtopic.php?p=74095

-----------------------------------
bored_hacker
Sun May 29, 2005 4:42 pm


-----------------------------------
I made this version the day after my compsci class started graphics. The teacher was impressed. (I added the Draw.Text, intstr, and offscreenonly later)

View.Set ("graphics: 510, 400; offscreenonly; nobuttonbar")
var x, y, b : int
var font := Font.New ("Serif:24")
for i : 0 .. 510 by 2
    Draw.ThickLine (i, 0, i, 300, 2, i div 2)
end for
View.Update
loop
    Mouse.Where (x, y, b)
    Draw.FillBox (0, 300, maxx, maxy, whatdotcolour (x, y))
    Draw.FillBox (245, 345, 300, 375, 0)
    Draw.Box (245, 345, 300, 375, 7)
    Draw.Text (intstr (whatdotcolour (x, y)), 250, 350, font, 7)
    View.Update
    exit when b = 1
end loop

-----------------------------------
neufelni
Mon May 30, 2005 10:44 am


-----------------------------------
Pretty impresive, bored_hacker. I think that this is the best one I have seen.

-----------------------------------
DarkAng
Mon May 30, 2005 5:12 pm


-----------------------------------
wow that blows mine away lol .. nice job .. its short too!

-----------------------------------
TheOneTrueGod
Mon May 30, 2005 10:10 pm

Heres my version...
-----------------------------------
heres a version I made... 
Click to "save" a colour.

setscreen ("graphics:712,512,nobuttonbar")
var clr, x, y, button, num : int := 0
num := 0
for count : 1 .. 512 by 32
    for count2 : 1 .. 512 by 32
        drawfillbox (count, count2, count + 32, count2 + 32, clr)
        clr += 1
    end for
end for
loop
    mousewhere (x, y, button)
    locate (1, 68)
    if x < 512 and y < 512 and x > 0 and y > 0 then
        put y div 32 + (((x div 32) * 16))
        if button = 1 then
            num += 1
            if num > 14 then
                num := 1
            end if
            drawfillbox (512 + 32, num * 32, 512 + 64, (num * 32) + 32, y div 32 + (((x div 32) * 16)))
            locatexy (576 + 64, num * 32)
            put y div 32 + (((x div 32) * 16))
            delay (100)
        end if
    end if
end loop


-----------------------------------
jamonathin
Tue May 31, 2005 8:04 am

Re: Heres my version...
-----------------------------------
heres a version I made... 
Click to "save" a colour.


Don't you mean, Click to "close program due to programming error"

-----------------------------------
phuong
Tue May 31, 2005 11:16 am


-----------------------------------
gah.... you guys are going so high tech with this. just look at my SIMPLE color file. ^^

-----------------------------------
GlobeTrotter
Tue May 31, 2005 3:14 pm

Re: Heres my version...
-----------------------------------
OneTrueGod, here's a little mod of your program so that multiple boxes don't come up if you hold down the mouse.


setscreen ("graphics:712,512,nobuttonbar") 
var clr, x, y, button, num : int := 0 
num := 0 
for count : 1 .. 512 by 32 
    for count2 : 1 .. 512 by 32 
        drawfillbox (count, count2, count + 32, count2 + 32, clr) 
        clr += 1 
    end for 
end for 
loop 
    mousewhere (x, y, button) 
    locate (1, 68) 
    if x < 512 and y < 512 and x > 0 and y > 0 then 
        put y div 32 + (((x div 32) * 16)) 
        if button = 1 then 
            num += 1 
            if num > 14 then 
                num := 1 
            end if 
            drawfillbox (512 + 32, num * 32, 512 + 64, (num * 32) + 32, y div 32 + (((x div 32) * 16))) 
            locatexy (576 + 64, num * 32) 
            put y div 32 + (((x div 32) * 16)) 
            loop
                mousewhere(x,y,button)
                exit when button = 0
            end loop
        end if 
    end if 
end loop 


-----------------------------------
phuong
Wed Jun 01, 2005 9:31 am


-----------------------------------
so how's my colour file?

-----------------------------------
jamonathin
Wed Jun 01, 2005 8:19 pm


-----------------------------------
so how's my colour file?
Its not bad.  Just too much code.  I've said this before in previous topic such as this, cuz there's like 20 this year on em.  Color-guide proggy's should be short and simple.  

A colorguide program should be when you're sitting there programming your game, and you need a color, so you hit CTRL + N and juss whip together one in about 5 seconds.  It shouldn't be any more than 6-7 lines.
The one I use is only 4  :?

-----------------------------------
phuong
Thu Jun 02, 2005 11:03 am


-----------------------------------
gah... i'm a newbe. not really actually. i've been in comp. sci. [class] for at least  5 months. well ok that's not that long and i still haven't learnt much. but hey. that's what i could come up with. check out my blackjack program. the topic title is: New Blackjack
