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

Username:   Password: 
 RegisterRegister   
 Fixing the paint bucket in paint program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Asian Brian




PostPosted: Thu Mar 03, 2005 7:29 pm   Post subject: Fixing the paint bucket in paint program

Hey all, its me who created the program betaPAINTER ++...
I have listen to some suggestions and had created a better version of my program. The only thing that still bothers me is my paint bucket. as of right now i only have a simple drawfill command. Can somebody help me?

4 tools to go... all will be based with the paint bucket.
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Thu Mar 03, 2005 8:07 pm   Post subject: (No subject)

its actually quite a simple program... all you need is a simple recursion around the points... here is the code

Turing:

setscreen ("graphics:300;300,nobuttonbar")
drawstar (0, 0, 300, 300, blue)

var mx, my, mb : int

proc fill2 (x, y, clr, oclr : int)
    if x >= 0 and y >= 0 and x <= maxx and y <= maxy then
        drawdot (x, y, clr)
        for i : -1 .. 1
            for j : -1 .. 1
                if abs (i) not= abs (j) and whatdotcolor (x + i, y + j) = oclr then
                    fill2 (x + i, y + j, clr, oclr)
                end if
            end for
        end for
    end if
end fill2

proc fill (x, y, clr : int)
    if whatdotcolor (x, y) not= clr then
        setscreen ("offscreenonly")
        fill2 (x, y, clr, whatdotcolor (x, y))
        setscreen ("nooffscreenonly")
    end if
end fill

loop
    mousewhere (mx, my, mb)
    if mb = 1 then
        fill (mx, my, red)
    end if
end loop


also, do you have a spray paint program? heres mine

Turing:

proc spray (x, y, radius, clr : int)
    var tempx, tempy : int
    randint (tempx, -radius, radius)
    randint (tempy, -radius, radius)
    if (tempx ** 2 + tempy ** 2) < radius ** 2 then
        drawdot (tempx + x, tempy + y, clr)
    end if
end spray

var mx, my, mb : int
var count := 0
loop
    mousewhere (mx, my, mb)
    if mb = 1 then
        spray (mx, my, 20, blue)
        count += 1
        if count = 10 then
            count := 0
            delay (1)
        end if
    else
        count := 0
    end if
end loop
Asian Brian




PostPosted: Thu Mar 03, 2005 9:27 pm   Post subject: (No subject)

sorry to say, but this code is not efficient for my program... by itself, it works perfectly... but in my paint program i doesn't.
Andy




PostPosted: Fri Mar 04, 2005 3:43 pm   Post subject: (No subject)

when is this project due? maybe i'll write a more efficient one later
Asian Brian




PostPosted: Fri Mar 04, 2005 5:28 pm   Post subject: (No subject)

monday...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: