Draw a "perfect" heart shape using Parametric Curves

Share your Inkscape tricks and tutorials here.
User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Draw a "perfect" heart shape using Parametric Curves

Postby ragstian » Tue Oct 23, 2012 3:51 am

Hi.

Created a guide for making heart shapes: Image

Guide: Image

Feedback appreciated! :)

RGDS Ragnar
Last edited by ragstian on Sat Jan 24, 2015 1:45 am, edited 3 times in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

DCH
Posts: 1
Joined: Thu Nov 01, 2012 11:34 pm

Re: Draw a perfect heart shape using Parametric Curves

Postby DCH » Thu Nov 01, 2012 11:40 pm

Works like a charm...
Very useful, thank you !

Didier

User avatar
flamingolady
Posts: 687
Joined: Wed Jun 10, 2009 1:40 pm

Re: Draw a perfect heart shape using Parametric Curves

Postby flamingolady » Thu May 02, 2013 2:17 pm

hi Ragnar,
I was able to make the perfect heart - yay, love this.
Of course I am getting errors in doing the growing heart - can't figure out what I'm doing wrong (oh lawdy, here we go again). Here's the numbers I'm using for growing:
13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)))*exp(t0.001)
(16(sin(t)*sin(t)*sin(t)))*exp(t*0.001)
I'm getting back an error notice. any ideas?
EDIT: here's the error notice:

Traceback (most recent call last):
File "param_curves.py", line 249, in <module>
e.affect()
File "C:\Program Files (x86)\Inkscape\share\extensions\inkex.py", line 215, in affect
self.effect()
File "param_curves.py", line 233, in effect
self.options.drawaxis)))
File "param_curves.py", line 70, in drawfunction
f1 = eval('lambda t: ' + fx.strip('"'))
File "<string>", line 1
lambda t: 16(sin(t)*sin(t)*sin(t)))*exp(t*0.001)
SyntaxError: invalid syntax

thanks,
dee

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Draw a perfect heart shape using Parametric Curves

Postby ragstian » Thu May 02, 2013 11:28 pm

Hi dee

Yes I got an idéa (or two);
- 1. First of all my guide might be a little "unpolished" - sorry for that - it's now updated - go download again.
- 2. Secondly you got two "typos" in your equation for the y-Function.
( Unfortunately - Inkscape (and programming in general) are quite unforgiving dealing with those kind of errors :) )
Errors with missing characters in red; (13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)))*exp(t*0.001)
To find such errors start reading the "tail" (last part) of the error message for clues.

Try this;
("Cut and paste" the blue text directly from this page)

x-Function; (16*(sin(t)*sin(t)*sin(t)))*exp(t*0.01)
y-Function; (13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t))*exp(t*0.01)

Set;
start t-value; 0
end t-value; 50

x-value of rectangle's left;-250
x-value of rectangle's right; 250
y-value of rectangle's bottom;-210
y-value of rectangle's top; 210

Samples; 1000
Stroke on original rectangle to; 0.5 px.

Some examples of what the "regular" heart can be used for;

Image
Click image for larger version.

Twist of "Family bumper sticker" - popular here in the states;
Image
Click image for larger version.

Guess how many kids in our family?
A clue here; Kids

Good Luck Drawing Hearts!

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: Draw a "perfect" heart shape using Parametric Curves

Postby Ailurus » Fri May 03, 2013 6:47 am

Nice tutorial Ragnar! However, if I would have to start from scratch with such an object, I would just use the Bézier tool to draw a rough version of either the left or right part of the heart. Then I would clone the path, flip it horizontally, and snap it to the other half. Modifying the original will then result in a nice symmetrical heart shape :).

By the way, I just noticed how strange it is that the clones are not updated in real time — when I move a node of the original, the corresponding node of the clone is moved only after I release the original node. We can therefore actually snap a node of the original to a node of one of its clones — but after releasing it, the node of the clone moves to its new position and is therefore not connected to the original node anymore :D.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Draw a "perfect" heart shape using Parametric Curves

Postby ragstian » Fri May 03, 2013 6:52 am

Hi.
Nice tutorial Ragnar! However, if I would have to start from scratch with such an object,
I would just use the Bézier tool to draw a rough version of either the left or right part of the heart.
Then I would clone the path, flip it horizontally, and snap it to the other half. Modifying the original will then result in a nice symmetrical heart shape :).

You should have stopped reading the tutorial after the second line! :D
Two first lines of the tutorial:

Ever tried to draw a “perfect heart” in Inkscape?
I can’t do it – your mileage might vary!


Doing it manually - with inferior result - I would have done it your way as well! :)

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

User avatar
flamingolady
Posts: 687
Joined: Wed Jun 10, 2009 1:40 pm

Re: Draw a "perfect" heart shape using Parametric Curves

Postby flamingolady » Fri May 03, 2013 7:50 am

Ragnar,
hmm, still can't quite get the growing heart, here's the latest denial:
Traceback (most recent call last):
File "param_curves.py", line 249, in <module>
e.affect()
File "C:\Program Files (x86)\Inkscape\share\extensions\inkex.py", line 215, in affect
self.effect()
File "param_curves.py", line 233, in effect
self.options.drawaxis)))
File "param_curves.py", line 95, in drawfunction
x0 = f1(t_start)
File "<string>", line 1, in <lambda>
TypeError: 'int' object is not callable

I've never been able to draw a perfect heart either, usually use Ailurus's method, but still have to get the ends to match, so this is a good method for me.

Ragnar - oh gee, 5 kids! wow, and 4 girls, you're outnumbered by women, lol (and they have beautiful hair and braids too). I do like your bumper sticker of hearts and your winged heart too.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Draw a "perfect" heart shape using Parametric Curves

Postby ragstian » Fri May 03, 2013 8:37 am

Hi dee

Never give up!

You are (most likely) missing a "times operator" - " * " - multiplication sign!

Most likely after the first 16 in the x-Function - your line;

(16(sin(t)*sin(t)*sin(t)))*exp(t*0.01)

My line;

(16*(sin(t)*sin(t)*sin(t)))*exp(t*0.01)

Good Luck again!!

your winged heart too.

This again proves that I'am not an artist - it was supposed to look like two swans!! :D

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

User avatar
flamingolady
Posts: 687
Joined: Wed Jun 10, 2009 1:40 pm

Re: Draw a "perfect" heart shape using Parametric Curves

Postby flamingolady » Fri May 03, 2013 11:25 am

yep, that was the culprit. not sure how it happened though because I copied your text, oh well. Love the result of the growing hearts!

ok, I do see the swans now that you mentioned it. I think if the wings went a little closer to the heart that it would look a little more like a swan from the start. I'm never good with trying to figure these things out though, so I'm not a good judge of it!
thanks again,
dee

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Draw a "perfect" heart shape using Parametric Curves

Postby ragstian » Fri May 03, 2013 11:49 am

Hi.
Glad you got it working! :D
The x-Function can be simplified to; 16*pow(sin(t),3)*exp(t*0.01)
Could not get it to work the first time I tried, not sure why.

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Draw a "perfect" heart shape using Parametric Curves

Postby brynn » Fri May 03, 2013 10:48 pm

Off topic:
Oh Ragnar, when you showed the photo of the braided ponytails, I somehow missed the caption ("our girls"). 4 girls -- my, my! And a son too, it looks like. What a nice family Image :D

Wow Dee, look at you with all that complex math, lol! I love how you're always up for a challenge!

User avatar
flamingolady
Posts: 687
Joined: Wed Jun 10, 2009 1:40 pm

Re: Draw a "perfect" heart shape using Parametric Curves

Postby flamingolady » Sat May 04, 2013 2:54 am

still off topic - yeah, I missed 'our girls' too, quite a nice family!
Brynn - I have no idea what it all means, totally forgot all the sine, cosine, stuff, it makes me crazy, but, I am able to copy the numbers, lol. Wish I understood more of which number makes the left part of the heart fat, vs which part makes it longer, which part is the right side, etc! But yes, I don't mind asking even if
I look foolish (why change it up at this point in life afterall, lol).

artgeek
Posts: 3
Joined: Fri Aug 23, 2013 8:20 pm

Re: Draw a "perfect" heart shape using Parametric Curves

Postby artgeek » Sat Sep 28, 2013 5:15 am

I followed the instructions but when I hit apply nothing happened.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Draw a "perfect" heart shape using Parametric Curves

Postby Lazur » Tue Oct 01, 2013 10:52 am

Something should have happened.

You drew a rectangle, then if you applied the extension,
at least it got erased right?

So what if you click on the "view all"- icon? Can it be that you were zoomed out?

Or what if the stroke and fill is totally transparent/white that you use?
Switch to outlines only and see if there is anything on the canvas.

If neither works, try to use different sized rectangles for the extension -maybe you used a too small one?

Or you just typed in the right functions to be applied with a typo?
Last edited by Lazur URH on Tue Oct 01, 2013 11:48 am, edited 2 times in total.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Draw a "perfect" heart shape using Parametric Curves

Postby ragstian » Tue Oct 01, 2013 11:35 am

Hi artgeek

When you say "nothing" happened do you mean you did not get a heart shape or no error messages etc?

Make sure the square box is selected. A very common mistake in using parametric curves is typing mistakes, ( I do them all the time!),
to avoid these try cut & paste the formula from the PDF file to the Inkscape. (or copy (CTRL-C) from this thread and paste (CTRL-V))

If you look further down in this post you will see that omitting just a multiplication sign in the x-Function input field causes this to fail.

Good Luck.

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar


Return to “Tricks & Tutorials”