Drawing Primatives

New releases and general discussions.

Post » Fri Oct 15, 2010 3:03 am

Are there any ways to draw lines? Could someone show me how to create a function in python that does drawline((x1,y1), (x2,y2))?
B
1
G
2
Posts: 8
Reputation: 641

Post » Fri Oct 15, 2010 10:22 am

Construct comes with a line object and the canvas object has a action to draw lines.
B
79
S
24
G
54
Posts: 4,754
Reputation: 40,771

Post » Fri Oct 15, 2010 4:15 pm

I guess I will have to experiment with Line. The exposed interface isn't very intuitive.
B
1
G
2
Posts: 8
Reputation: 641

Post » Fri Oct 15, 2010 5:28 pm

What are you trying to do? If you're trying to connect two objects with a line, the Line object is the way to go, since all you have to do is update its start and end position. If you want to draw a picture consisting of many lines, you probably want to use the Canvas object, which is better suited to procedural drawing.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,620

Post » Fri Oct 15, 2010 5:38 pm

I want to be able to do all of the above. I'm not really clear on what the canvas object does. Would you have to make it the size of the application window in order to draw anywhere on the screen? Would you be willing to make a cap that demonstrates what you are talking about? I'm sorry if I seem dense but it seems to me to make the line object useful to me I would have to make some python wrapper methods.
B
1
G
2
Posts: 8
Reputation: 641

Post » Fri Oct 15, 2010 6:59 pm

Maybe the better path to take is describe exactly what you want to do. For example a real project situation, and some of the bright minds here might be able can give you direction.
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Fri Oct 15, 2010 7:35 pm

The line object, and canvas object "draw line" work the same. (x1,y1,x2,y2).
The only difference is line uses window coordinates, and canvas uses its dimensions.
Thing is there is no way to get correct collision detection with line, but you can with canvas.
As far as primitives go there's no way to fill in either case. Also Python cant draw directly to the Construct window, you can only make calls to Construct objects, like sprite.
Sprite BTW can make filled primitives out of a distort map, but there's no collision detection on it, unless you paste it into a canvas.

Good times.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Fri Oct 15, 2010 8:36 pm

I stole a little time from work and tested it out. I wasn't looking in the right place before. I forget sometimes that most useful actions aren't available until you call them from an even (such as mouse clicked).

Thanks for putting up with my mental slowness.
B
1
G
2
Posts: 8
Reputation: 641


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron