How can I draw a curved line ?

0 favourites
  • 9 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hi...

    Does anybody know if its possible to draw a curved line in C2 ?

    <img src="http://dl.dropbox.com/u/22173473/drawline.png" border="0" />

    Can the usual method for drawing a line in the following example, be modified to achieve it?

    Mouse left button is down-

    Beam-Set width to distance(start.X, start.Y, Mouse.X, Mouse.Y)

    Thanks in advance

    <img src="smileys/smiley5.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can with r0j0hound's canvas plugin.

  • Arimaipu@   You can with r0j0hound's canvas plugin.

    Thanks....will check it out.

    I was hoping there might be a way to do it without having to

    to use a plugin.

  • Well you can always have a 'cursor' or 'pencil' that creates static duplicates of itself every tick / few milliseconds as it moves, creating a "line". You can then use lerp(),qarp(),or cubic() to move the pencil how you want.

    Maybe not the best idea but if you insist on not using plugins there ya go :P

  • C2 doesn't have qarp or cubic yet.

  • To get a formula for cubic look on the wikipedia page for "bezier curves".

    Here's an implementation:

    dropbox.com/s/lr1irx5ntjfp0kl/cubicCurve.capx

    You will get better results with the canvas plugin though, which won't have breaks in the curve.

  • Tokinsom@

    Well you can always have a 'cursor' or 'pencil' that creates static duplicates of itself every tick / few milliseconds as it moves, creating a "line". You can then use lerp(),qarp(),or cubic() to move the pencil how you want.

    Maybe not the best idea but if you insist on not using plugins there ya go :P

    Sounds a bit technical for me! Thanks for help.

    R0J0hound@

    To get a formula for cubic look on the wikipedia page for "bezier curves".

    Here's an implementation:

    dl.dropbox.com/u/5426011/examples%208/cubicCurve.capx

    You will get better results with the canvas plugin though, which won't have breaks in the curve.

    Brilliant example as ever.....i will also check out the Canvas plugin.

    Many thanks.

    Note:

    Does the Canvas allow me to draw a curved line, if for example i left mouse click and move the cursor away to another position and release the mouse?

  • Does the Canvas allow me to draw a curved line, if for example i left mouse click and move the cursor away to another position and release the mouse?

    Yeah, you would have to set up a counter, and some variables for each click, like on click one set start xy to mouse xy, on click two set end xy to mouse xy, then on click 3 set offset to mouse xy.

    Then on mouse release draw using the variables.

    Or you could set up your own spline with handles, but that's way more complicated.

  • > Does the Canvas allow me to draw a curved line, if for example i left mouse click and move the cursor away to another position and release the mouse?

    Yeah, you would have to set up a counter, and some variables for each click, like on click one set start xy to mouse xy, on click two set end xy to mouse xy, then on click 3 set offset to mouse xy.

    Then on mouse release draw using the variables.

    Or you could set up your own spline with handles, but that's way more complicated.

    Thanks newt...I will see if i can get this to work.

    (not the spline with handles part though!)

    <img src="smileys/smiley1.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)