spakin / SimpInkScr

Simple Inkscape Scripting
https://inkscape.org/~pakin/%E2%98%85simple-inkscape-scripting
GNU General Public License v3.0
321 stars 32 forks source link

speedometer demo looks strange #22

Closed peterennis closed 2 years ago

peterennis commented 2 years ago
  1. Load speedometer, Apply
  2. It looks strange, so I added a new layer below with a yellow box to view it
  3. Ticks are not line ticks

Screenshot 2021-12-31 200348

I changed some code parameters and can get this result:

Screenshot 2021-12-31 202308

Commit here: https://github.com/peterennis/SimpInkScr/commit/324d0e37177d13cb963ab93d4d8707f78dcfd736

spakin commented 2 years ago

Could you post your default Inkscape document? (For example, create a new document and immediately save it.) I wonder if the problems you're seeing here and in #24 stem from your having a very different default page size from what I'm using. Here's what the speedometer looks like on my system:

speedometer

peterennis commented 2 years ago
  1. Open new instance of Inkscape (no other instance is running)
  2. Save As new_drawing.svg (Save does not seem to do anything with no changes in the app)
  3. File attached as new_drawing.zip

new_drawing.zip

spakin commented 2 years ago

Aha! I was able to reproduce the strange-looking speedometer using new_drawing.svg. Further investigation revealed the source of the discrepancy: All Simple Inkscape Scripting examples work in terms of user-space units, which are typically SVG pixels (@ ~3.5px/mm). However, new_drawing.svg sets the view box such that one user-space unit is 1mm, making all Simple Inkscape Scripting coordinates, distances, and thicknesses 3.5x larger. Here's what my Document Properties, Page tab looks like for A4 paper:

doc-props

Note in particular the scale of 3.77 user units/mm where your document has a scale of 1 user unit/mm. (I don't know why mine isn't 3.5, though.)

I don't believe this is something that needs to be "fixed", as a Simple Inkscape Scripting user may actually want his scripts to work in terms of millimeters or other coordinates. (SVG even supports different horizontal and vertical scaling.) It does imply that user-space units much different from 1 per pixel will lead to some odd renderings of the example scripts, though.