Recent

Author Topic: Sierpiński gasket or Sierpiński sieve: Now saving to SVG  (Read 1099 times)

Boleeman

  • Hero Member
  • *****
  • Posts: 1141
Sierpiński gasket or Sierpiński sieve: Now saving to SVG
« on: July 23, 2025, 10:52:20 am »
Sierpiński gasket or Sierpiński sieve: Now saving to SVG

Go to later reply for the download


Saving SVG has fractal points data but cannot be Viewed in a Browser

Hi All.

I made a fractal program that works well and got it to save to svg but the saved svg file does not display the saved points in a web browser.

The svg file contains the points but something seems to be missing to display the svg in a web browser (not really sure?)

Here is the contents of a level 2 curve saved to svg:

Code: Pascal  [Select][+][-]
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <svg width="1620" xmlns="http://www.w3.org/2000/svg" height="20">
  3.   <path d="M-190 10 210 10 410 10 610 10 810 10 1010 10 1210 10 1410 10 1610 10" fill="none" stroke="#FFFF00" stroke-width="1.5px"/>
  4. </svg>

Any help from the SVG gurus greatly appreciated ?


Also the size of the original curve canvas is 840 pixels wide by 800 pixels high but I seem to get svg width="1620" and height="20" but I am not sure why?
« Last Edit: July 24, 2025, 01:58:22 pm by Boleeman »

Boleeman

  • Hero Member
  • *****
  • Posts: 1141
Re: Saving SVG has points data but cannot be Viewed in a Browser
« Reply #1 on: July 23, 2025, 11:27:44 am »
I was looking at and comparing this svg which makes a simple rectangle:

Code: Pascal  [Select][+][-]
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
  3.  
  4. <path fill="#000000" d="M235.7,25.4v205.2H20.3V25.4H235.7 M244.1,15.2H11.9c-1.1,0-1.9,0.9-1.9,1.9v221.8c0,1.1,0.9,1.9,1.9,1.9h232.1c1.1,0,1.9-0.9,1.9-1.9V17.1C246,16,245.1,15.2,244.1,15.2L244.1,15.2z"/>
  5. </svg>

Khrys

  • Sr. Member
  • ****
  • Posts: 421
Re: Saving SVG has points data but cannot be Viewed in a Browser
« Reply #2 on: July 24, 2025, 06:51:54 am »
The SVG displays just fine, but the path data is wrong; the points all have the same  y  coordinate:

Code: XML  [Select][+][-]
  1. <path d="M -190  10
  2.             210  10
  3.             410  10
  4.             610  10
  5.             810  10
  6.             1010 10
  7.             1210 10
  8.             1410 10
  9.             1610 10"
  10.       fill="none"
  11.       stroke="#FFFF00"
  12.       stroke-width="1.5px"/>

The result is a thin horizontal line at the top of the viewport, and on a white background the bright yellow makes it really hard to see.

Boleeman

  • Hero Member
  • *****
  • Posts: 1141
Re: Saving SVG has points data but cannot be Viewed in a Browser
« Reply #3 on: July 24, 2025, 01:56:28 pm »
Thank you Khrys. That observation was a great help.

I was not getting any color earlier and then was losing direction with those constant point values.

Now have finally got it working and saving to svg and displaying in Firefox correctly.

Yay. My first save to svg.

 

TinyPortal © 2005-2018