|
|
Home » Extra libraries, Code snippets, applications etc. » Applications created with U++ » GeoFun -- Plot Spirograph
GeoFun -- Plot Spirograph [message #39212] |
Thu, 28 February 2013 16:38  |
 |
deep
Messages: 267 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
Hi,
I have made small program to plot spirographs.
These are Roulette (curves).
Program can save image(png/jpg), Autocad script (scr) and print.
Sample image attached.
Have some fun.
I am attaching the programs here for download. And also program is available from sourceforge.
Program can be downloaded from
GeoFun
Epitrochoid image

Warm Regards
Deepak
[Updated on: Fri, 01 March 2013 13:34] Report message to a moderator
|
|
|
Re: GeoFun -- Plot Spirograph [message #39222 is a reply to message #39212] |
Fri, 01 March 2013 13:39   |
 |
deep
Messages: 267 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
I am attaching the programs for download here.
Linux program -- after download set execute bit (file permissions) to run.
V0.26 available.
New features 'plot animation' and save as SVG file.
This is now new version with Animation of curve draw.
Warm Regards
Deepak
[Updated on: Wed, 13 March 2013 09:38] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: GeoFun -- Plot Spirograph [message #43749 is a reply to message #43734] |
Wed, 01 October 2014 23:30   |
 |
Klugier
Messages: 1099 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello deep,
A small note on your code, you should never use following statement in your header file:
This is definitly bad practice and it can lead to mistakes in the future.
You can improve your code quality by simply using:
// In header file (.h):
NAMESPACE_UPP
#define IMAGECLASS GFImg
#define IMAGEFILE <GeoFun/GeoFun.iml>
#include <Draw/iml_header.h>
// ...
END_UPP_NAMESPACE
// In implementation file (.cpp)
#include "GeoFun.h"
using namespace Upp;
Sincerely,
Klugier
U++ - one framework to rule them all.
[Updated on: Wed, 01 October 2014 23:30] Report message to a moderator
|
|
|
Re: GeoFun -- Plot Spirograph [message #43757 is a reply to message #43720] |
Fri, 03 October 2014 17:25   |
ManfredHerr
Messages: 67 Registered: February 2013 Location: Germany
|
Member |
|
|
Hi Deepak,
on my UBUNTU 14.04 I tried your new export as SVG. Neither SVG-viewer of mine (Emacs, Firefox, etc.) did show a roulette curve but garbage.
A short examination of your code revealed that you try to export the points in float format rather than integer. Applying the following change
for ( int j = 0; j < p.GetCount(); j++ )
// sXML << Format ( "%0.4f", p[j].x ) << "," << Format ( "%0.4f", p[j].y ) << " ";
sXML << Format ( "%d,%d ", p[j].x, p[j].y );
produced a file that shows a part of the curve at least. It is one (4.) quadrant only because the shift of the origin is missing.
I hope this is of some help to you.
Manfred
|
|
|
Re: GeoFun -- Plot Spirograph [message #43771 is a reply to message #43757] |
Wed, 08 October 2014 17:01   |
 |
deep
Messages: 267 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
Hi Manfred,
As per "SVG" specifications number is type float. Curves smoothness will be hampered if I change number to 'int' when image is scaled.
Thank you for your suggestions. Will check in Linux. If problem is there then will change the number format to 'int' for Linux compilation.
interface SVGNumber {
attribute float value setraises(DOMException);
};
SVGNumber
InkScape opens the present saved image. Full image shown.
I checked in windows with Firefox, Chrome and IE all are showing the image. It is 1/4 ( positive quadrant). By default internet browsers expect SVG image with all positive values. My calculated path is in all 4 quadrants.
I have made required change to shift image to have all positive values in exported image. Full image is visible in Windows browsers.
Thanks for your suggestion Klugier
Quote:
A small note on your code, you should never use following statement in your header file:
using namespace Upp;
Made changes suggested by you. It includes origin shift also.
-
Attachment: GeoFun.7z
(Size: 339.79KB, Downloaded 304 times)
Warm Regards
Deepak
[Updated on: Wed, 08 October 2014 17:02] Report message to a moderator
|
|
|
Re: GeoFun -- Plot Spirograph [message #43772 is a reply to message #43771] |
Wed, 08 October 2014 18:42  |
ManfredHerr
Messages: 67 Registered: February 2013 Location: Germany
|
Member |
|
|
Hi Deepak,
I think the problem in Linux is that your Format code produces floats with a comma rather than a point. So, the SVG interpreter sees four integers seperated by comma rather than two floats that are intended.
BTW, Point in UPP has integer coordinates as far as I know. To store them as floats or double does not increase the resolution.
Greets
Manfred
Edit:
The reason, why I generate floats with a comma rather than a point, is my LOCALE setting: it is GERMAN.
If I include
setlocale(LC_NUMERIC,"C"); // C-Standard
in GUI_APP_MAIN then I also produce a SVG file with floating point values that can be interpreted by SVG viewers.
[Updated on: Wed, 08 October 2014 22:05] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Apr 28 23:22:04 CEST 2025
Total time taken to generate the page: 0.01411 seconds
|
|
|