How to draw curve?

Non-platform specific questions.

How to draw curve?

Postby sportmaster » Sat Nov 27, 2010 1:24 pm

How to draw curve from point to point with canvas ? I also would like to know how to draw sine wave and of course circle, and maybe sphere with gradient filling.
User avatar
sportmaster
 
Posts: 32
Joined: Thu Jun 25, 2009 8:29 pm
Score: 0 Give a positive score

Re: How to draw curve?

Postby Bee-Ant » Sat Nov 27, 2010 2:16 pm

For wide circle, it seems you can't draw it with solid line...only with dotted line...
Here's the code if I'm not mistaken...
Code: Select all
int i,xx,yy,R=100;
erase(0,0,0,1);
for(i=0;i<360;i++)
{
    xx=cos(degtorad(i))*R;
    yy=sin(degtorad(i))*R;
    setpen(255,255,255,0,1);
    putpixel(width/2+xx,height/2+yy);
}
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: How to draw curve?

Postby sportmaster » Sat Nov 27, 2010 6:55 pm

The circle looks... so, so, but the code is smart :o and I can't deny it is a circle, and what about just one curve line ? Is it possible to draw solid ?
User avatar
sportmaster
 
Posts: 32
Joined: Thu Jun 25, 2009 8:29 pm
Score: 0 Give a positive score

Re: How to draw curve?

Postby lcl » Sun Nov 28, 2010 2:43 pm

You can make is smoother by adding another one, little bit larger and transparent circle under it.
Like this:
Code: Select all
int i, xx, yy, R = 100;
erase(0, 0, 0, 1);

for (i = 0; i < 360; i ++)
{
    xx = cos(degtorad(i)) * R;
    yy = sin(degtorad(i)) * R;
    setpen(255, 255, 255, 0.5, 4);
    putpixel(width / 2 + xx, height / 2 + yy);
}
for (i = 0; i < 360; i ++)
{
    xx = cos(degtorad(i)) * R;
    yy = sin(degtorad(i)) * R;
    setpen(255, 255, 255, 0, 2);
    putpixel(width / 2 + xx, height / 2 + yy);
}

Just edited Bee-Ant's code. :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: How to draw curve?

Postby jimmynewguy » Sun Nov 28, 2010 3:13 pm

Kall's brother showed us a way of counting a circle path a whiles back, i just put that code in a canvas and you don't get a pixley one. But he wants a curved line so this doesn't help. Guess I'll make another one if i find time in the next couple of minutes :)
Attachments
circling.zip
(1.23 KiB) Downloaded 104 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: How to draw curve?

Postby Bee-Ant » Sun Nov 28, 2010 3:30 pm

jimmynewguy wrote:Kall's brother

Kall's brother?you mean Kalladdolf's???
Who's he?
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: How to draw curve?

Postby jimmynewguy » Sun Nov 28, 2010 9:23 pm

Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: How to draw curve?

Postby Bee-Ant » Sun Nov 28, 2010 11:15 pm

jimmynewguy wrote:yea, you were in this discussion bee!
viewtopic.php?f=5&t=4600&hilit=counting+a+circle+path&start=15

Owh, what an old topic...no wonder I forgot it :P
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: How to draw curve?

Postby sportmaster » Mon Nov 29, 2010 2:48 am

lcl improved Bee - Ant's circle but Jimmy's looks better because it's clear but I probably can't get collision with that line so it's only visaul effect. The advantage of lcl's is that I can add physicall response with canvas. Thanks to you I know two ways to draw circle but I still don't know how to make a curve line from point to point. I need to know how to display by canvas lines with various curvature for my next game so I'm counting on you :)
Attachments
example.png
User avatar
sportmaster
 
Posts: 32
Joined: Thu Jun 25, 2009 8:29 pm
Score: 0 Give a positive score

Re: How to draw curve?

Postby Bee-Ant » Mon Nov 29, 2010 7:27 am

Something like this???
http://dl.dropbox.com/u/3997355/Curve.ged

Well, basically you just need an array to store all the y point value.
Then connect them using moveto() and lineto()
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: How to draw curve?

Postby sportmaster » Mon Nov 29, 2010 8:59 am

Yeaaach!! Another point for Beeee - Aaant :D :D :D !
User avatar
sportmaster
 
Posts: 32
Joined: Thu Jun 25, 2009 8:29 pm
Score: 0 Give a positive score

Re: How to draw curve?

Postby Bee-Ant » Mon Nov 29, 2010 10:22 am

Thanks. Glad I could help :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest