Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request]basic shapes 'triangle' element #954

Open
xga-cga opened this issue Sep 19, 2024 · 6 comments
Open

[feature request]basic shapes 'triangle' element #954

xga-cga opened this issue Sep 19, 2024 · 6 comments

Comments

@xga-cga
Copy link

xga-cga commented Sep 19, 2024

Greetings;
Intro:
I am requesting a basic shape similiar to the line element. Stated here: https://www.w3.org/TR/SVG2/shapes.html#LineElement
Proposal: have a triangle element with 3 x,y svg coordinates. connected.
Thanks.

@herrstrietzel
Copy link

herrstrietzel commented Dec 20, 2024

That's basically the <polygon> element.
Sure, a built-in element for regular polygons could be nice but I think that's rather the domain of helper libraries.
You just need to calculate multiple points around a specified center point with specified angles (according to the number of vertices) and there you go. See codepen example.

All in all – I don't think we need an additional element for this.

@xga-cga
Copy link
Author

xga-cga commented Dec 21, 2024

Appreciate the reply and thank you for your time.
There are flaws with that polygon code all through the internet. Even in inkscape 1.4 (an SVG program); GNUplot--outputs to SVG; python turtle: 1. Without looking at the code in the polygon library, but it's output, a 360 side polygon is not a circle.
2. A. Triangles may result in neater code. B. Some graphics cards use them for rasterizing and other things.
The output of the code is invalid (not code). Part of the problem are the polygon programs don't seem to account for the size of the canvas as well. Try at least (1000px by 1000px; I did 90 dots because it didn't fit on a 1080p screen and had to zoom in/out, etc) I am uploading a practice PDF with 90 points to practice with a pencil or pen and a list of 90 imperfect points to practice . People can make it bigger. It also matters what coordinate system you use. Cartesian for example are rectangular.
gear90cxy.pdf
gear90cxy.txt

I do not know how helper libraries write the code to the browser and cannot help with this.

Steps to get plot points:

I originally used openboard to plot the points and used a CAD file of a 360 tooth gear. I then plotted points 90/91 in between a fourth of the gear with a mouse. Then used a spreadsheet to put the points in and transcribe them. (you can also create a scatterplot chart) A cartesian coordinate system or a pixel coordinate system may give you problems.

@xga-cga
Copy link
Author

xga-cga commented Dec 22, 2024

herrstrietzel -- "All in all – I don't think we need an additional element for this." You may be right, it may be a math problem. I was hoping to use SVG to do other things with SVG such as A. help solve math problems B. movie format C. Screensavers. D. video games I know these have different systems, standards and requirements. So this may be a huge error on my part. Carry on then.

@herrstrietzel
Copy link

I'm not sure I got you right. Frankly I don't quite understand how a native SVG <triangle> could solve your described problems.
You may instead ask for help on Stackoverflow or Math Exchange – when it comes to geometry.
What's safe to say: most (if not all) CAD related applications export terrible SVGs – mostly a mess of ten thousands of single disconnected <line> elements. Béziers? Arcs? Shapes? Usually not used despite being available since day 1.
So I don't think there is anything wrong with the <polygon> or <polyline> element (you may need to flip the Y-axis to get the translation to a traditional Cartesian coordinate system) but pretty much everything wrong with CAD related SVG exports=)

@xga-cga
Copy link
Author

xga-cga commented Dec 22, 2024

but pretty much everything wrong with CAD related SVG exports=)

Example comparing analog to digital
When people use pencil it's analog (like a dial 1-9)... not 1 and 0 (like an on off switch). openboard is a whiteboard for drawing... and acts more analog... I'm not saying there are problems with polygon as it probably does what it's programmed to do. If you used a different algorithm such as having a single origin for 360 triangles. Then you may be able to do the problem easier.

Other algorithm for polygon: number of triangles=number of sides

but pretty much everything wrong with CAD related SVG exports=)

have to agree a lot!!! :-)

I have tried writing code manually... in SVG it still looks bad and it still looks like a circle, got partially done you have to scroll down on the test file. Didn't plot a full 360 polygon. it is a demo. svgtest.html.txt without .txt is an SVG file viewable in a browser. svgtest.html.txt is an SVG file of 360 dots, possibly outputted from Inkscape. Some people use AWK (linux) to help
start3.svg.txt
svgtest.html.txt
Caution: code not intended for mission critical or life saving systems.

The reason why I didn't show a lot of work is because I didn't want to confuse people here and I make mistakes...
I don't know how to solve? I have more data if needed. Thanks for trying.

@herrstrietzel
Copy link

A Q&A platform like stackexchange/stackoverflow or reddit is definitely more suitable to find a solution.
I still don't see how a new SVG element could help here and frankly I don't see any usage of triangles. I think your main problem is to find the right translation from your input data to the desired SVG rendering which is certainly doable. So please consider posting a question on the aforementioned platforms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants