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

Username:   Password: 
 RegisterRegister   
 [source] paintish proggy
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
zylum




PostPosted: Fri Mar 12, 2004 7:59 pm   Post subject: [source] paintish proggy

i dunno if this has been posted before but im too lazy to check... anyways... here's a paint style program... we just the pencil and bucket tools... first you draw a shape by clicking once and then drawing the shape... when you release, then the line will automatically draw its self back to the starting point... then the next click fills in that shape (bucket) and then the program repeats itself...

code:
var mx, my, md : int

proc fill (x, y : int)
    drawdot (x, y, 7)
    if whatdotcolor (x + 1, y) = 0 and x < maxx then
        fill (x + 1, y)
    end if
    if whatdotcolor (x - 1, y) = 0 and x > 0 then
        fill (x - 1, y)
    end if
    if whatdotcolor (x, y + 1) = 0 and y < maxy then
        fill (x, y + 1)
    end if
    if whatdotcolor (x, y - 1) = 0 and y > 0 then
        fill (x, y - 1)
    end if
end fill

proc fillShape
    loop
        mousewhere (mx, my, md)
        exit when md = 1
    end loop
    fill (mx, my)
end fillShape

proc drawShape
    var x, y, oldx, oldy, startx, starty : int
    loop
        mousewhere (mx, my, md)
        exit when md = 1
    end loop
    oldx := mx
    oldy := my
    startx := mx
    starty := my
    loop
        mousewhere (mx, my, md)
        exit when md = 0
        x := mx
        y := my
        drawline (oldx, oldy, x, y, 7)
        oldx := x
        oldy := y
    end loop
    drawline (x, y, startx, starty, 7)
end drawShape

loop
    drawShape
    fillShape
end loop


-zylum
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Fri Mar 12, 2004 8:49 pm   Post subject: (No subject)

Quote:

end loop


Nice zylum, real nice.
zylum




PostPosted: Fri Mar 12, 2004 8:59 pm   Post subject: (No subject)

oops lol Laughing
SuperGenius




PostPosted: Fri Mar 19, 2004 2:33 pm   Post subject: (No subject)

i tried out your little prog, but i have some complaints, not to be nasty but for improvements sake. I drew a line that overlapped, resulting in two ajacent closed figures, kind of like an " 8 ". When i clicked inside of one part, it filled the screen around the shape, and not inside the part that I clicked on.
AsianSensation




PostPosted: Fri Mar 19, 2004 10:01 pm   Post subject: (No subject)

haha should have came up with this earlier, when all the people at my school were desperate for the recursive source code that would let them do drawfill. I had to help some many people with this same exact function, only if this was earlier, I'd give more bits, but oh well.

+10 bits
sport




PostPosted: Mon Mar 22, 2004 3:23 pm   Post subject: (No subject)

Nice program, a light color would brighten up your program a lot.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: