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

Username:   Password: 
 RegisterRegister   
 All the Colours of Turing
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
@DRI@N




PostPosted: Tue May 25, 2004 4:56 pm   Post subject: All the Colours of Turing

This program displays all the numbers from 1 255 filled with their colour value
code:

% Black BackGround, All the Colours

colorback(black)
for row:1..25
    for col:1..80
    put" "..
    end for
end for

locate(1,1)
for Colours:1..255
put Colours," "..
color(Colours)
end for
   
Sponsor
Sponsor
Sponsor
sponsor
guruguru




PostPosted: Tue May 25, 2004 6:05 pm   Post subject: (No subject)

Post in source code. Lol this is count #2

EDIT: Heh sorry . It was fun counting to 4 . I'll stop now.
Paul




PostPosted: Tue May 25, 2004 6:13 pm   Post subject: (No subject)

hey! Stop taking advantage of his mistakes for your own post count!
code:

setscreen ("graphics:max;5000")
colorback(black)
locate(1,1)
for Colours:1..255
colorback (Colours)
put Colours
end for
   
Laughing Razz
AsianSensation




PostPosted: Tue May 25, 2004 9:53 pm   Post subject: (No subject)

2 things.

guruguru, we can keep track of how many stupid source he posts, thank you, most of us are not retarded, despite what some people think. So -10 bits, for the bits you earned by spamming in relevent sections.

Second, @DRI@N, please stop it with the below average codes. It is nice if you have interesting code to share with the rest of us. But simple stuff like this that my pet dog could even do just clogs the source section, making it harder to find relevent sources.
TheZsterBunny




PostPosted: Wed May 26, 2004 6:18 am   Post subject: (No subject)

I had this in my paint directory from my first project (Januaryish).

I managed to get it working this morning.

Use it in good health and with credits.

code:

% Zak Blacher 2003-2004
% set hugeness the the sqrt of the number of colors you want to show (not including b&w)
var hugeness : int := 256
setscreen ("graphics:" + intstr (hugeness + 5) + ";" + intstr (hugeness) + ",nobuttonbar,title: Color")
var tclr : int := 5
for j : 0 .. hugeness
    for i : 0 .. hugeness
        RGB.SetColor (tclr, j / hugeness, i / hugeness, (hugeness - i) / hugeness)
        drawdot (j, i, tclr)
    end for
end for
for i : 0 .. hugeness
    RGB.SetColor (tclr, i / hugeness, i / hugeness, i / hugeness)
    drawline (maxx - 5, i, maxx, i, tclr)
end for


oh, and the b&w was an afterthought, it doesn't blend well
the_short1




PostPosted: Wed May 26, 2004 8:23 pm   Post subject: (No subject)

wow zester... that lookz REALLY sweet!!!
using RGB vlues even better..


here is 2 bits... cuz that lookz nice... a nice add on would be a whatdorcolor at mouse click so u can find the COLOR number for each dot...
TheZsterBunny




PostPosted: Thu May 27, 2004 4:14 pm   Post subject: (No subject)

nice idea short (getting colors), reminds me why i scrapped the program.

whatdotcolor returns the closest turing color value to that pixel.

Here is what i mean:
code:

% Zak Blacher 2003-2004
% set hugeness the the sqrt of the number of colors you want to show (not including b&w)
var hugeness : int := 256
setscreen ("graphics:" + intstr (hugeness + 5) + ";" + intstr (hugeness + 50) + ",nobuttonbar,title: Color,offscreenonly")
var tclr : int := 4
for j : 0 .. hugeness
    for i : 0 .. hugeness
        RGB.SetColor (tclr, j / hugeness, i / hugeness, (hugeness - i) / hugeness)
        drawdot (j, i + 50, tclr)
    end for
end for
for i : 0 .. hugeness
    RGB.SetColor (tclr, i / hugeness, i / hugeness, i / hugeness)
    drawline (maxx - 5, i + 50, maxx, i + 50, tclr)
end for
View.Update

var mx, my, mb : int
var r, g, b : real
var c1, c2 : int
c1 := 0
c2 := 7
Mouse.ButtonChoose ("multibutton")
loop
    mousewhere (mx, my, mb)
    if mb not= 0 and mx >= 50 and mx <= maxx and my >= 0 and my <= maxy then
        RGB.GetColor (whatdotcolor (mx, my), r, g, b)
        if mb = 1 then
            RGB.SetColor (c1, r, g, b)
        elsif mb = 100 then
            RGB.SetColor (c2, r, g, b)
        end if
    end if
    drawfillbox (10, 0, 30, 20, c2)
    drawfillbox (0, 10, 20, 30, c1)
    drawbox (0,10,20,30,black)
    View.Update
end loop


It returns the closest color, which may fool some people, but try sampling towards the centre of the image. you get brown-grey colors.

I've just had an idea, and will attempt it. its cheap, but it may work.

--10 mins later--

hehe. it works to a point, and then it crashes.

I can't understand why it crashed (i do free the pics, but it tells me not so), but here is the updated code. Smile


code:

% Zak Blacher 2003-2004
% set hugeness the the sqrt of the number of colors you want to show (not including b&w)
var hugeness : int := 256
setscreen ("graphics:" + intstr (hugeness + 5) + ";" + intstr (hugeness + 50) + ",nobuttonbar,title: Color,offscreenonly")
var tclr : int := 4
for j : 0 .. hugeness
    for i : 0 .. hugeness
        RGB.SetColor (tclr, j / hugeness, i / hugeness, (hugeness - i) / hugeness)
        drawdot (j, i + 50, tclr)
    end for
end for
for i : 0 .. hugeness
    RGB.SetColor (tclr, i / hugeness, i / hugeness, i / hugeness)
    drawline (maxx - 5, i + 50, maxx, i + 50, tclr)
end for
View.Update
var mx, my, mb : int
var r, g, b : real
var c1, c2 : int
c1 := Pic.New (0, 0, 1, 1)
c2 := Pic.New (maxx, 50, maxx - 1, 51)
Mouse.ButtonChoose ("multibutton")
Pic.Draw (Pic.Scale (c2, 20, 20), 10, 0, picCopy)
Pic.Draw (Pic.Scale (c1, 20, 20), 0, 10, picCopy)
drawbox (0, 10, 20, 30, 7)
loop
    mousewhere (mx, my, mb)
    if mb not= 0 and mx > 50 and mx <= maxx and my >= 0 and my <= maxy then
        if mb = 1 then
            Pic.Free (c1)
            delay (1)
            c1 := Pic.New (mx, my, mx, my)
            Pic.Draw (Pic.Scale (c1, 20, 20), 0, 10, picCopy)
            drawbox (0, 10, 20, 30, 7)
        elsif mb = 100 then
            Pic.Free (c2)
            delay (1)
            c2 := Pic.New (mx, my, mx, my)
            Pic.Draw (Pic.Scale (c2, 20, 20), 10, 0, picCopy)
            drawbox (10, 0, 30, 20, 7)
            Pic.Draw (Pic.Scale (c1, 20, 20), 0, 10, picCopy)
            drawbox (0, 10, 20, 30, 7)
        end if
    end if
    View.Update
end loop


suggestions on fixing second code are welcome.
recap: using pictures b/c cannot get color

-Z

p.s. short_1, no first 'e'
TheZsterBunny




PostPosted: Thu May 27, 2004 9:54 pm   Post subject: (No subject)

this is seperate, as to draw attention.

ATTN: DODGE_TOMAHAWK (WHATDOTCOLOR WARRIOR)!


There is a serious limitation with the whatdotcolor command.

It cannot pick up non-standard turing colors. I found this when using the first code I posted last message.

:p. I await your defense, because Pic.New (x,y,x,y) is soooo much better.


-Z
guruguru




PostPosted: Thu May 27, 2004 10:18 pm   Post subject: (No subject)

Wow that looks and works awsome. I don't know why it creates an error either... I've heard a couple other people having the same problems evern when freeing the picutres. Cummon... just be rough color values in.
TheZsterBunny




PostPosted: Fri May 28, 2004 7:15 am   Post subject: (No subject)

gg,

using rough color values defeats the whole purpose of this program. this was not an attempt at drawing pretty pictures of fading colors, this was an attempt at getting all colors, not only the ugly turing ones.

In other news, i've begun working on custom draw____ commands, and would appreciate assistance with drawline and drawarc. I'm not a very mathematical person.

-Z
the_short1




PostPosted: Fri May 28, 2004 7:25 am   Post subject: (No subject)

whay are u using pictures in ur code???
beard0




PostPosted: Fri May 28, 2004 1:01 pm   Post subject: (No subject)

Here's a little add-on to TheZsterBunny's first program, it tells you the RGB value of any color you click, in decimal, and hex (very useful for those who make web pages). This is how I would find the colour again afterwards - not by using pictures - it just goes back to the way the colors were formed originally - if you know the co-ordinates, you know the color.
code:
var hugeness : int := 255
setscreen ("graphics:" + intstr (hugeness) + ";" + intstr (hugeness + 30) + ",nobuttonbar,title: Color")
var tclr : int := 5
for j : 0 .. hugeness
    for i : 0 .. hugeness
        RGB.SetColor (tclr, j / hugeness, i / hugeness, (hugeness - i) / hugeness)
        drawdot (j, i, tclr)
    end for
end for
var x, y, bu : int
function tohex (n : int) : string
    var res : string := ""
    if n div 16 < 10 then
        res += intstr (n div 16)
    else
        res += chr (n div 16 + 55)
    end if
    if n mod 16 < 10 then
        res += intstr (n mod 16)
    else
        res += chr (n mod 16 + 55)
    end if
    result res
end tohex
loop
    mousewhere (x, y, bu)
    if bu > 0 and x >= 0 and x <= hugeness and y >= 0 and y <= hugeness then
        locate (1, 1)
        put intstr (x) : 4, intstr (y) : 4, intstr (hugeness - y) : 4 % I just changed these to string to get them left aligned
        put tohex (x) : 4, tohex (y) : 4, tohex (hugeness - y) : 4
    end if
end loop
TheZsterBunny




PostPosted: Fri May 28, 2004 5:20 pm   Post subject: (No subject)

Nicely done. it doesn't get the color value at all, but the coords.

Cool, this may be a way to fix my problem

-- 10 mins later--

fixed! thanks beardo.

code:

% Zak Blacher 2003-2004
% set hugeness the the sqrt of the number of colors you want to show (not including b&w)
var hugeness : int := 256
setscreen ("graphics:" + intstr (hugeness + 5) + ";" + intstr (hugeness + 50) + ",nobuttonbar,title: Color,offscreenonly")
var tclr : int := 4
for j : 0 .. hugeness
    for i : 0 .. hugeness
        RGB.SetColor (tclr, j / hugeness, i / hugeness, (hugeness - i) / hugeness)
        drawdot (j, i + 50, tclr)
    end for
end for
for i : 0 .. hugeness
    RGB.SetColor (tclr, i / hugeness, i / hugeness, i / hugeness)
    drawline (maxx - 5, i + 50, maxx, i + 50, tclr)
end for
View.Update
var mx, my, mb : int
var r, g, b : real
var c1, c2 : int
c1 := 244
c2 := 245
drawfillbox (10, 0, 30, 20, 7)
drawbox (10, 0, 30, 20, 7)
drawfillbox (0, 10, 20, 30, 0)
drawbox (0, 10, 20, 30, 7)
Mouse.ButtonChoose ("multibutton")
drawbox (0, 10, 20, 30, 7)
loop
    mousewhere (mx, my, mb)
    if mb not= 0 and mx >= 0 and mx < maxx - 5 and my >= 50 and my <= maxy and Window.GetActive = defWinID then
        if mb = 1 then
            RGB.SetColor (c1, mx / hugeness, (my - 50) / hugeness, (hugeness - (my - 50)) / hugeness)
            drawfillbox (0, 10, 20, 30, c1)
            drawbox (0, 10, 20, 30, 7)
        elsif mb = 100 then
            RGB.SetColor (c2, mx / hugeness, (my - 50) / hugeness, (hugeness - (my - 50)) / hugeness)
            drawfillbox (10, 0, 30, 20, c2)
            drawbox (10, 0, 30, 20, 7)
            drawfillbox (0, 10, 20, 30, c1)
            drawbox (0, 10, 20, 30, 7)
        end if
    elsif mb not= 0 and mx >= maxx - 5 and mx <= maxx and my >= 50 and my <= maxy and Window.GetActive = defWinID then
        if mb = 1 then
            RGB.SetColor (c1, (my - 50) / hugeness, (my - 50) / hugeness, (my - 50) / hugeness)
            drawfillbox (0, 10, 20, 30, c1)
            drawbox (0, 10, 20, 30, 7)
        elsif mb = 100 then
            RGB.SetColor (c2, (my - 50) / hugeness, (my - 50) / hugeness, (my - 50) / hugeness)
            drawfillbox (10, 0, 30, 20, c2)
            drawbox (10, 0, 30, 20, 7)
            drawfillbox (0, 10, 20, 30, c1)
            drawbox (0, 10, 20, 30, 7)
        end if
    end if
    View.Update
end loop


oh, and i had something else to post...

a hex color converter, from my early days of RGBdom

code:

var hexcode : string
put "Enter the Hex Code for your desired color: " ..
get hexcode
if strint (hexcode, 16) >= 0 and strint (hexcode, 16) <= (256 ** 3) then
    drawfillbox (50, 50, 100, 100, RGB.AddColor (strint (hexcode (1 .. 2), 16) / 256, strint (hexcode (3 .. 4), 16) / 256, strint (hexcode (5 .. 6), 16) / 256))
end if



I used that quite a bit for the massey web-pages

thank you
-Z
the_short1




PostPosted: Fri May 28, 2004 11:11 pm   Post subject: (No subject)

please/// if ts over 200-300 lines of code please POST as .t


its so anoying to scrool..... Sad


thanks!!



wow.... zster... ur program is really sweet now.. and thanks..,. ui kinda needed taht for my website...

but then today i just found the perfect hex chart!...
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  [ 14 Posts ]
Jump to:   


Style:  
Search: