Computer Science Canada

this wont fill in the triangle help me out?

Author:  Genisis [ Wed Oct 19, 2005 7:32 am ]
Post subject:  this wont fill in the triangle help me out?

i dont know why this isnt filling in the roof of the house can someone tell me why?

[code]
colorback (black)
cls

% the sky%
drawfilloval (575, 300, 50, 50, yellow)
drawfilloval (560, 305, 50, 50, black)
drawfillstar (500, 300, 510, 310, yellow)
drawfillstar (300, 320, 310, 330, yellow)
drawfillstar (450, 350, 455, 345, yellow)

%ground
drawfillbox (0, 0, maxx, 5, 120)

%mailbox
drawfillbox (500, 6, 520, 55, 113)
drawfillbox (470, 56, 520, 76, white)
drawfillbox (480, 66, 490, 70, red)

%house base and roof
drawfillbox (50, 6, 300, 200, green)
drawline (25, 200, 175, 275, green)
drawline (175, 275, 325, 200, green)
drawline (25, 200, 325, 200, green)
drawfill (175, 200, 191, green)

% door,window and steps
drawfillbox (300, 6, 250, 10, grey)
drawfillbox (250, 6, 200, 20, grey)
drawfillbox (200, 6, 150, 30, grey)
drawfillbox (150, 6, 75, 40, grey)
drawfillbox (140, 41, 80, 150, blue)
drawfilloval (90, 85, 3, 3, 10)
drawfillbox (200, 100, 275, 150, 10)
drawfillbox (200, 122, 275, 127, black)
drawfillbox (237, 100, 242, 150, black)

%gaurd rails
drawline (74, 80, 74, 6, black)
drawline (78, 80, 78, 6, black)
drawline (82, 80, 82, 6, black)
drawline (86, 80, 86, 6, black)
drawline (90, 80, 90, 6, black)
drawline (94, 80, 94, 6, black)
drawline (98, 80, 98, 6, black)
drawline (102, 80, 102, 6, black)
drawline (106, 80, 106, 6, black)
drawline (110, 80, 110, 6, black)
drawline (114, 80, 114, 6, black)
drawline (118, 80, 118, 6, black)
drawline (122, 80, 122, 6, black)
drawline (126, 80, 126, 6, black)
drawline (130, 80, 130, 6, black)
drawline (134, 80, 134, 6, black)
drawline (138, 80, 138, 6, black)
drawline (142, 80, 142, 6, black)
drawline (146, 80, 146, 6, black)
drawline (150, 80, 150, 6, black)
drawline (74, 80, 150, 80, black)
drawfillbox (73, 80, 154, 76, black)

delay (10000)
cls

Draw.Arc (320, 240, 30, 30, 0, 180, white)
Draw.Line (290, 240, 287, 150, white)
Draw.Line (350, 240, 357, 150, white)
Draw.Line (287, 150, 300, 160, white)
Draw.Line (300, 160, 320, 150, white)
Draw.Line (320, 150, 340, 160, white)
Draw.Line (340, 160, 357, 150, white)

Draw.Oval (310, 240, 10, 5, white)
Draw.FillOval (310, 240, 5, 5, white)
Draw.Oval (330, 240, 10, 5, white)
Draw.FillOval (330, 240, 5, 5, white)
delay (100)
cls

Draw.Arc (320, 240, 30, 30, 0, 180, white)
Draw.Line (290, 240, 287, 150, white)
Draw.Line (350, 240, 357, 150, white)
Draw.Line (287, 150, 300, 160, white)
Draw.Line (300, 160, 320, 150, white)
Draw.Line (320, 150, 340, 160, white)
Draw.Line (340, 160, 357, 150, white)

Draw.Oval (310, 240, 10, 5, white)
Draw.FillOval (310, 240, 5, 5, white)
Draw.Oval (330, 240, 10, 5, white)
Draw.FillOval (330, 240, 5, 5, white)
delay (100)
cls

Draw.Arc (320, 240, 30, 30, 0, 180, white)
Draw.Line (290, 240, 287, 150, white)
Draw.Line (350, 240, 357, 150, white)
Draw.Line (287, 150, 300, 160, white)
Draw.Line (300, 160, 320, 150, white)
Draw.Line (320, 150, 340, 160, white)
Draw.Line (340, 160, 357, 150, white)

Draw.Oval (310, 240, 10, 5, white)
Draw.FillOval (310, 240, 5, 5, white)
Draw.Oval (330, 240, 10, 5, white)
Draw.FillOval (330, 240, 5, 5, white)
delay (100)
cls

Draw.Arc (320, 240, 30, 30, 0, 180, white)
Draw.Line (290, 240, 287, 150, white)
Draw.Line (350, 240, 357, 150, white)
Draw.Line (287, 150, 300, 160, white)
Draw.Line (300, 160, 320, 150, white)
Draw.Line (320, 150, 340, 160, white)
Draw.Line (340, 160, 357, 150, white)

Draw.Oval (310, 240, 10, 5, white)
Draw.FillOval (310, 240, 5, 5, white)
Draw.Oval (330, 240, 10, 5, white)
Draw.FillOval (330, 240, 5, 5, white)
delay (100)
cls

Draw.Arc (320, 240, 30, 30, 0, 180, white)
Draw.Line (290, 240, 287, 150, white)
Draw.Line (350, 240, 357, 150, white)
Draw.Line (287, 150, 300, 160, white)
Draw.Line (300, 160, 320, 150, white)
Draw.Line (320, 150, 340, 160, white)
Draw.Line (340, 160, 357, 150, white)

Draw.Oval (310, 240, 10, 5, white)
Draw.FillOval (310, 240, 5, 5, white)
Draw.Oval (330, 240, 10, 5, white)
Draw.FillOval (330, 240, 5, 5, white)
delay (100)
cls

[/code]

Author:  bass_maniac [ Wed Oct 19, 2005 8:37 am ]
Post subject: 

I'm not sure what's wrong with what you've got, but when you have a weird shape like a triangle, try using drawfillpolygon. At the top of your prog add,
code:
var x : array 1 .. 3 of int := init (25, 175, 325)
var y : array 1 .. 3 of int := init (200, 275, 200)

then replace the roof code with,
code:
drawfillpolygon (x, y, 3, 191)

Author:  jamonathin [ Wed Oct 19, 2005 11:47 am ]
Post subject: 

Or you could use Draw.Fill. Here's an example of how to fill a triangle.

code:
drawline (100, 100, 200, 200, black)
drawline (300, 100, 200, 200, black)
drawline (100, 100, 300, 100, black)
%
delay (500)
put "Fill!"
delay (250)
Draw.Fill (200, 150, brightgreen, black)
%200 - xvalue inside area
%150 - yvalue inside area
%brighgreen - color to fillwith
%black - color to stop at

Author:  beard0 [ Wed Oct 19, 2005 1:53 pm ]
Post subject: 

Genisis: For your drawfill, you had the point to start filling from be on the baseline of the roof. You need to place it inside the triangle.

If you change
Turing:
drawfill (175, 200, 191, green)
to
Turing:
drawfill (175, 201, 191, green)


you'll find that it works perfectly. Smile


...and for both Genisis and jamonathin: please don't mix draw[whatever] statements and Draw.[Whatever] statements in the same program. Pick one and stick with it. It's just more readable.


: