hogesonline / svg_play Goto Github PK
View Code? Open in Web Editor NEWMaking pretty generated SVGs in Python
Making pretty generated SVGs in Python
Hi,
thanks for your programs. They are fun and interesting.
I noted some small problems:
a_bit_mondrian.py
Running it in python 3 gives an error in the random.choice function because colors is an iterable and not a list.
By changing line 14 to:
colors = list(color_nums.keys())
the problem is resolved.
double_pendulum.py
1- the PATH directive is not terminated properly which gives an XML error.
to correct simply change line 116 from:
path+= '" style="fill-opacity: 0; stroke-width: 2; stroke: green; filter: url(#glow);"'
to
path+= '" style="fill-opacity: 0; stroke-width: 2; stroke: green; filter: url(#glow);" />'
2- the filter is not applied because the tags in the filter definition are in lowercase instead of camelcase:
fegaussianblur must be change to feGaussianBlur
stddeviation to stdDeviation
femerge to feMerge
femergenode to feMergeNode
Funny thing, the lowercase tags works in a Jupyter notebook.
Speaking of Jupyter notebook, I put all your programs in a single Jupyter notebook to facilitate experimentation.
I included the notebook and a sample pdf file in the attached files.
python 'a_bit_mondrian.py'
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
Traceback (most recent call last):
File "a_bit_mondrian.py", line 37, in <module>
draw_mondrian(500, 500, COLORNUMS)
File "a_bit_mondrian.py", line 18, in draw_mondrian
col = random.choice(colors)
File "/usr/lib/python3.6/random.py", line 261, in choice
return seq[i]
TypeError: 'dict_keys' object does not support indexing
Hi Amanda,
I think the issue you had with this might be a simple fix...
line 29
n = random.randint(0,4) should be=> n = random.randint(0,3)
I've been playing around with your SVG ideas this week, I might have a fun little app (all Python) to share with you.
Pete
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.