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

Username:   Password: 
 RegisterRegister   
 Drawfill
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jolly50




PostPosted: Sat Nov 03, 2007 6:33 am   Post subject: Drawfill

Hey,

I'm trying to learn about drawfill. So I printed a house and i'm trying to fill the house with colors, my problem is that i cannot fill the roof where I used lines instead of boxes.

So here is my code:

code:


setscreen ("graphics")


% The House Foundation
drawbox (250,250,350,100,2)
drawfill (275,200,2,2)

% The House Roof
drawline (250,250,300,310,2)
drawline (300,310,350,250,2)

% The House Door
drawbox (280,100,310,150,2)

% The House Windows
drawbox (275,200,295,225,2)
drawbox (315,200,335,225,2)

% The House Chimney
drawline (325,281,325,291,2)
drawline (335,291,335,267,2)
drawline (325,291,335,291,2)
%Smoke
drawline (328,293,328,303,2)
drawline (332,305,332,315,2)
drawline (329,316,329,326,2)



Should I keep the lines or is there another way to draw a triangle?
Sponsor
Sponsor
Sponsor
sponsor
HeavenAgain




PostPosted: Sat Nov 03, 2007 11:33 am   Post subject: RE:Drawfill

theres something called drawfillbox, you can look that up, it bascially just ... draw and fill the box
code:
setscreen ("graphics")


% The House Foundation
drawfillbox (250,250,350,100,2)


% The House Roof
drawline (250,250,300,310,2)
drawline (300,310,350,250,2)

% The House Door
drawbox (280,100,310,150,2)

% The House Windows
drawbox (275,200,295,225,2)
drawbox (315,200,335,225,2)

% The House Chimney
drawline (325,281,325,291,2)
drawline (335,291,335,267,2)
drawline (325,291,335,291,2)
drawfill (275,275,1,2)
%Smoke
drawline (328,293,328,303,2)
drawline (332,305,332,315,2)
drawline (329,316,329,326,2)

Rolling Eyes
CodeMonkey2000




PostPosted: Sat Nov 03, 2007 11:38 am   Post subject: RE:Drawfill

Is this an assignment or are you doing this for fun? I remember way back in grade 9 we had to draw animate a stupid clown winking using turing's draw module. What the hell does that have to do with proper programming concepts? It's just pointless.
Supernal




PostPosted: Sat Nov 03, 2007 11:40 am   Post subject: RE:Drawfill

I had to do this exact same project in Grd. 9.
As well as a space ship blasting off, then we finally started with simple calculators and stuff.
jolly50




PostPosted: Sat Nov 03, 2007 12:30 pm   Post subject: RE:Drawfill

ok I'm trying to fill the chimney and make it red, but somethings wrong......

code:

setscreen ("graphics")


% The House Foundation
drawfillbox (250,250,350,100,2)

% The House Roof
drawline (250,250,300,310,2)
drawline (300,310,350,250,2)
drawfill (275,275,yellow,2)

% The House Door
drawfillbox (280,100,310,150,6)


% The House Windows
drawfillbox (275,200,295,225,6)
drawfillbox (315,200,335,225,6)

% The House Chimney
drawline (325,281,325,291,2)
drawline (335,291,335,267,2)
drawline (325,291,335,291,2)
drawfill (330,286,4,7)
%Smoke
drawline (328,293,328,303,8)
drawline (332,305,332,315,8)
drawline (329,316,329,326,8)



what am i doing wrong
CodeMonkey2000




PostPosted: Sat Nov 03, 2007 12:36 pm   Post subject: RE:Drawfill

Use the drawfillpolygon procedure.
jolly50




PostPosted: Sat Nov 03, 2007 1:20 pm   Post subject: RE:Drawfill

can you put down an example of a drawfillpolygon because the help menu doesnt really help me
CodeMonkey2000




PostPosted: Sat Nov 03, 2007 3:04 pm   Post subject: Re: Drawfill

Basically you have two parallel arrays with the same dimensions. The first array contains all your x coordinates, the second contains the y. So X(1) and Y(1) together make one coordinate. Now you pass these in to drawfillpolygon, then you pass in how many sides your polygon has (this is generally equivalent to the upper bounds of the arrays). For you it's:
code:
var x : array 1 .. 4 of int := init (325, 325, 335, 335)
var y : array 1 .. 4 of int := init (281, 291, 291, 267)
Draw.FillPolygon (x, y, 4, brightblue)
Sponsor
Sponsor
Sponsor
sponsor
jolly50




PostPosted: Sat Nov 03, 2007 8:49 pm   Post subject: RE:Drawfill

ok... that makes more sense then the help menu... thanks
Clayton




PostPosted: Sun Nov 04, 2007 9:04 am   Post subject: RE:Drawfill

The arrays don't necessarily have to be parrallel Wink

Turing:

var pentagon :
    record
        x : array 1 .. 5 of int
        y : array 1 .. 5 of int
    end record

//assign variables

Draw.FillPolygon (pentagon.x, pentagon.y, upper (pentagon.x), red)


Smile
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  [ 10 Posts ]
Jump to:   


Style:  
Search: