Computer Science Canada

Colour detector..easy!

Author:  Ashi_Mashi2 [ Sat Mar 05, 2005 12:04 pm ]
Post subject:  Colour detector..easy!

Hi, i wrote this program many months ago...thought it might be useful for those who need it..anyway..here it is:

code:

setscreen ("graphics:vga")

var y, xm, ym, b, t : int
var key : string (1)

locate (2, 27)
color (12)
put "Please Wait While Scanning"
for x : 1 .. 120
    drawfillbox (5 + (x * 5 + 5), 240, 5 + (x * 5 + 10), 340, x)
end for

for x : 1 .. 120
    y := x + 120
    drawfillbox (5 + (x * 5 + 5), 120, 5 + (x * 5 + 10), 220, y)
end for

for x : 1 .. 15
    y := x + 240
    drawfillbox (5 + (x * 5 + 5), 10, 5 + (x * 5 + 10), 100, y)
end for

locate (2, 1)
put ""
color (1)
locate (1, 74)
put "Exit"
drawbox (maxx - 60, maxy - 15, maxx - 20, maxy, 1)
loop
    mousewhere (xm, ym, b)

    for z : 1 .. 120
        if xm >= 5 + (z * 5 + 5) and xm <= 5 + (z * 5 + 10) and ym >= 240 and ym <= 340 then
            locate (2, 6)
            put "The Selected Colour: " ..
            put z
        end if
    end for

    for u : 1 .. 120
        t := 120 + u
        if xm >= 5 + (u * 5 + 5) and xm <= 5 + (u * 5 + 10) and ym >= 120 and ym <= 220 then
            locate (2, 6)
            put "The Selected Colour: " ..
            put t
        end if
    end for

    for u : 1 .. 15
        t := 240 + u
        if xm >= 5 + (u * 5 + 5) and xm <= 5 + (u * 5 + 10) and ym >= 10 and ym <= 100 then
            locate (2, 6)
            put "The Selected Colour: " ..
            put t
        end if
    end for

    if xm >= maxx - 60 and xm <= maxx - 15 and ym >= maxy - 15 and ym <= maxy and b = 1 then
        cls
        exit
    end if
end loop

Author:  Andy [ Sat Mar 05, 2005 12:44 pm ]
Post subject: 

errr... or you could simply use
code:

loop
    mousewhere (xm, ym, b)
    locate (1, 1)
    put whatdotcolor (xm, ym)

end loop

Author:  AsianSensation [ Sun Mar 06, 2005 11:33 am ]
Post subject: 

zomg! whatdotcolor was actually more efficient than another program? WTF?

Trust the herald of whatdotcolor to come up with that one.

Author:  endusto [ Sun Mar 06, 2005 1:50 pm ]
Post subject: 

Andy wrote:
errr... or you could simply use
code:

loop
    mousewhere (xm, ym, b)
    locate (1, 1)
    put whatdotcolor (xm, ym)

end loop

but thats all glitched, for example, move your mouse over colour 52. that same thing happens in many places

Author:  Bacchus [ Sun Mar 06, 2005 6:48 pm ]
Post subject: 

wats wrong with it, you get 11? which is the same as 52. the colors at the beginning (1,2,3,4,etc) are just there for convienence, they appear again in a later number


: