GIMP Chat http://gimpchat.com/ |
|
Drawing arc path using Python. http://gimpchat.com/viewtopic.php?f=9&t=14638 |
Page 1 of 1 |
Author: | MareroQ [ Tue Sep 27, 2016 10:51 am ] | ||
Post subject: | Drawing arc path using Python. | ||
I want to draw a heart using Python. It consists of eight arcs. What will be the code to draw the path of the arc AB? Data: the radius (r) and point A (x1, y2) and B (x2, y1). Please piece of code or clue.
|
Author: | ofnuts [ Tue Sep 27, 2016 11:46 am ] |
Post subject: | Re: Drawing arc path using Python. |
Get my ofn-path-to-shape script, it's in there somewhere. Basically you create two horizontal/vertical tangents, and the best approximation to a circle is when the distance of the tangent handle to the anchor is radius*kappa, where "kappa" is a constant (kappa=4*(math.sqrt(2)-1)/3). But if you want a heart that looks good, you'll have to do a bit more math and look into tangent circles of different diameters. Nothing earth-shattering... There may even be a simple construction using path-to-shape (and mirror-path, because I'm lazy). |
Author: | MareroQ [ Tue Sep 27, 2016 2:10 pm ] |
Post subject: | Re: Drawing arc path using Python. |
Thank You Ofnuts for the quick reply. Ofn-path-to-shape.py - this 838 lines of code. It's too hard - for a beginner to learn about creating shapes paths in Python. The heart is the only example of using a bow to create assorted figures (through symmetry, rotation and flip - the problem is the arc). |
Author: | trandoductin [ Tue Sep 27, 2016 2:42 pm ] |
Post subject: | Re: Drawing arc path using Python. |
try this one Attachment: reference source: how to create circle with bezier curves |
Author: | ofnuts [ Tue Sep 27, 2016 2:52 pm ] |
Post subject: | Re: Drawing arc path using Python. |
MareroQ wrote: Thank You Ofnuts for the quick reply. Ofn-path-to-shape.py - this 838 lines of code. It's too hard - for a beginner to learn about creating shapes paths in Python. The heart is the only example of using a bow to create assorted figures (through symmetry, rotation and flip - the problem is the arc). You didn't really search, did you? Of course this code constructs a full circle with an arbitrary orientation of its four control points Code: Select all def pointAtRhoThetaFromOrigin(origin,rho,theta): Besides, neither you nor Disnasset are beginners. This is more high school math than code, and the last time I did math seriously was about 35 yeas ago. You just have to believe in yourself and dive. PS: Current O-P-2-S is 861 lines, so you must have an old version. |
Author: | ofnuts [ Tue Sep 27, 2016 2:55 pm ] |
Post subject: | Re: Drawing arc path using Python. |
PPS: http://serge.mehl.free.fr/anx/coeur.html And "6ème" is for kids 11-12 years. |
Author: | ofnuts [ Tue Sep 27, 2016 2:59 pm ] |
Post subject: | Re: Drawing arc path using Python. |
trandoductin wrote: By the way, I have never seen a convincing proof that this is the best fit to the circle. IIRC it just makes sure that the middle point of the arc is on the circle. Hmmm. Following one comment leads to a better proof with a slightly different constant (that you used in your code). Good to know. |
Author: | trandoductin [ Tue Sep 27, 2016 3:54 pm ] |
Post subject: | Re: Drawing arc path using Python. |
i didn't scroll that far I guess that is a better constant with formula of how they got it and all. |
Author: | MareroQ [ Tue Sep 27, 2016 4:33 pm ] | |||
Post subject: | Re: Drawing arc path using Python. | |||
@ Trandoductin Your code works very well. Thank you very much. @ Ofnuts Thank you very much for pointing out the code and example (perhaps the most beautiful heart and simple dependencies).
|
Author: | trandoductin [ Tue Sep 27, 2016 5:23 pm ] |
Post subject: | Re: Drawing arc path using Python. |
oh that bottom part of the heart looks trickier than my script provided. |
Author: | Pat625 [ Wed Sep 28, 2016 10:43 pm ] |
Post subject: | Re: Drawing arc path using Python. |
I don't know anything about the math involved re making the perfect heart but after seeing that last diagram, I will definitely remember that the next time I have to draw a heart. Very nifty! |
Author: | trandoductin [ Wed Sep 28, 2016 11:51 pm ] |
Post subject: | Re: Drawing arc path using Python. |
or this shape Pat Attachment: heart_05.png [ 23.24 KiB | Viewed 1055 times ] |
Author: | MareroQ [ Thu Sep 29, 2016 2:45 am ] | ||
Post subject: | Re: Drawing arc path using Python. | ||
This heart has a classic look - if You wrote code? One more parameter - the dependence of H For me, a long way to learn.
|
Author: | ofnuts [ Thu Sep 29, 2016 6:47 am ] |
Post subject: | Re: Drawing arc path using Python. |
See the "tangents to circle" options in ofn-path-to-shape |
Author: | trandoductin [ Thu Sep 29, 2016 11:29 am ] |
Post subject: | Re: Drawing arc path using Python. |
oh man you guys are advanced...i just did it by using snap to guides and snap to active path. wouldn't know how to do it in code with more research |
Author: | mahvin [ Thu Sep 29, 2016 2:04 pm ] |
Post subject: | Re: Drawing arc path using Python. |
For me, I would simplify the math using a triangle as the start point. Good ole trig and a set of compass points. (This is intended to be funny, and I realize it might not get the desired result). |
Author: | trandoductin [ Thu Sep 29, 2016 2:06 pm ] |
Post subject: | Re: Drawing arc path using Python. |
mahvin, we all intend things to be funny, no harm in trying. |
Page 1 of 1 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |