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

Username:   Password: 
 RegisterRegister   
 Paintbucket in paint program doesn't work proper
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
creepforever




PostPosted: Fri Apr 29, 2016 9:13 am   Post subject: Paintbucket in paint program doesn't work proper

What is it you are trying to achieve?
I'm working on a paint program for my grade 10 paint program.


What is the problem you are having?
The paintbucket procedure won't fill in the color that I want it to .

Describe what you have tried to solve this problem
I tried making the fill color parameter in the Draw.Fill Procedure a variable which can be assigned a value depending on which color box you click but it won't work.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




Turing:


var mx, my, button: int
var premx, premy : int
var pencili: int
var eraseri: int
var paintbucketi: int
var linei: int
var font: int
var clr1, clr2, clr3, clr4, clr5, clr6: int
var n: int



pencili:= Pic.FileNew ("pencil.jpg")
eraseri:= Pic.FileNew ("eraser.jpg")
paintbucketi:= Pic.FileNew ("paintbucket.jpg")
font:= Font.New ("Times New Roman:15")
n:= black
clr1:= 40
clr2:= 52
clr3:= 10
clr4:= 14
clr5:= black
clr6:= 151

setscreen ("graphics: 1200, 640")


procedure pencil
loop
mousewhere (mx, my, button)
if mx>10 and mx<30 and my>480 and my<500 and button=1 then
 n:=clr1
 elsif mx>10 and mx<30 and my>450 and my<470 and button = 1 then
 n:=clr2
 elsif mx>10 and mx<30 and my>420 and my<440 and button = 1 then
 n:=clr3
 elsif mx>10 and mx<30 and my>390 and my<410 and button = 1 then
 n:=clr4
 elsif mx>10 and mx<30 and my>360 and my<380 and button = 1 then
 n:=clr5
 elsif mx>10 and mx<30 and my>330 and my<350 and button = 1 then
 n:= clr6
 else
end if
if mx> 70 and mx<maxx and my>0 and my<520 and button=1 then
    Draw.FillOval (mx, my, 5,5,n)
    Draw.Oval (mx, my, 5, 5, black)
    else
end if
if mx>110 and my>530 and my<600 and button=1 then
exit
end if
end loop
end pencil

procedure eraser
loop
mousewhere (mx, my, button)
if mx> 70 and mx<maxx and my>0 and my<520 and button=1 then
    Draw.FillOval (mx, my, 5, 5,white)
    else
end if
if mx<120 or mx>277 and my>530 and my<600 and button=1 then
exit
end if
end loop
end eraser

procedure paintbucket
loop
mousewhere (mx, my, button)
if mx>10 and mx<30 and my>480 and my<500 and button=1 then
 n:=clr1
 elsif mx>10 and mx<30 and my>450 and my<470 and button = 1 then
 n:=clr2
 elsif mx>10 and mx<30 and my>420 and my<440 and button = 1 then
 n:=clr3
 elsif mx>10 and mx<30 and my>390 and my<410 and button = 1 then
 n:=clr4
 elsif mx>10 and mx<30 and my>360 and my<380 and button = 1 then
 n:=clr5
 elsif mx>10 and mx<30 and my>330 and my<350 and button = 1 then
 n:= clr6
end if
if n = n then
    n:= n
    else
end if
if mx> 70 and mx<maxx and my>0 and my<520 and button=1 then
    Draw.Fill (mx, my, n, black)
    Draw.Box (70, 0, maxx, 535, 151)
    Draw.Box (71, 0, maxx, 534, 40)
    Draw.Box (72, 0, maxx, 533, 52)
    Draw.Box (73, 0, maxx, 532, 10)
    Draw.Box (74, 0, maxx, 531, 14)
    Draw.Box (75, 0, maxx, 530, black)
    else
end if
if mx<270 or mx>420 and my>530 and my<600 and button=1 then
exit
end if
end loop
end paintbucket

procedure line
loop
mousewhere (mx, my, button)
    if mx> 70 and mx<maxx and my>0 and my<520 and button=1 then
        premx:= mx
        premy:= my
        loop
        mousewhere (mx, my, button)
            if mx> 70 and mx<maxx and my>0 and my<520 and button=1 then
            Draw.Line (premx, premy, mx, my, black)
            end if
        end loop
    else
    end if
    if mx<270 or mx>420 and my>530 and my<600 and button=1 then
exit
end if
end loop
end line




%Start Screen
Draw.Box (70, 0, maxx, 535, 151)
Draw.Box (71, 0, maxx, 534, 40)
Draw.Box (72, 0, maxx, 533, 52)
Draw.Box (73, 0, maxx, 532, 10)
Draw.Box (74, 0, maxx, 531, 14)
Draw.Box (75, 0, maxx, 530, black)


Pic.Draw (pencili, 10, 540, picMerge)
Pic.Draw (eraseri, 120, 540, picMerge)
Pic.Draw (paintbucketi, 240, 540, picMerge)
Draw.ThickLine (350, 545, 430, 595, 2, black)
Draw.Text ("CLEAR SCREEN", 1050, 570, font, black)


procedure boxes
Draw.FillBox (10, 480, 30, 500, 40)
Draw.Box (10, 480, 30, 500, black)
Draw.FillBox (10, 450, 30, 470, 52)
Draw.Box (10, 450, 30, 470, black)
Draw.FillBox (10, 420, 30, 440, 10)
Draw.Box (10, 420, 30, 440, black)
Draw.FillBox (10, 390, 30, 410, 14)
Draw.Box (10, 390, 30, 410, black)
Draw.FillBox (10, 360, 30, 380, black)
Draw.Box (10, 360, 30, 380, black)
Draw.FillBox (10, 330, 30, 350, 151)
Draw.Box (10, 330, 30, 350, black)
end boxes

boxes


loop
mousewhere (mx, my, button)
if mx> 10 and mx<110 and my> 530 and my<600 and button=1 then
pencil
elsif mx> 120 and mx<240 and my>530 and my<600 and button=1 then
eraser
elsif mx>240 and mx<350 and my>540 and my<600 and button=1 then
paintbucket
elsif mx>390 and mx<480 and my>545 and my<595 and button = 1 then
line
elsif mx>1050 and mx<1200 and my>570 and my<600 and button = 1 then
cls
Draw.Box (70, 0, maxx, 535, 151)
Draw.Box (71, 0, maxx, 534, 40)
Draw.Box (72, 0, maxx, 533, 52)
Draw.Box (73, 0, maxx, 532, 10)
Draw.Box (74, 0, maxx, 531, 14)
Draw.Box (75, 0, maxx, 530, black)
Pic.Draw (pencili, 10, 540, picMerge)
Pic.Draw (eraseri, 120, 540, picMerge)
Pic.Draw (paintbucketi,240, 540, picMerge)
Draw.ThickLine (390, 545, 480, 595, 3, black)
Draw.Text ("CLEAR SCREEN", 1050, 570, font, black)
boxes
else
end if
end loop



Please specify what version of Turing you are using
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Fri Apr 29, 2016 12:45 pm   Post subject: RE:Paintbucket in paint program doesn\'t work proper

What does this line do?
code:
if mx<270 or mx>420 and my>530 and my<600 and button=1 then


Also, I'm seeing some really strange stuff in here. What's this code supposed to do?
code:
if n = n then
    n:= n
    else
end if
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  [ 2 Posts ]
Jump to:   


Style:  
Search: