Git Product home page Git Product logo

svg_play's Introduction

svg_play

Making pretty generated SVGs in Python

I am giving a talk at PyconAU 2019 showng how to build SVG and using generative art as a motivator.

This is where I'm puytting all my code so people can have a look, have a play and maybe even give advice (particularly on dumb if statements when I should be using clever maths).

Everything is available to steal and play with . Please share alike.

svg_play's People

Contributors

hogesonline avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

svg_play's Issues

Corrections and a Jupyter notebook

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.

sample.pdf
svg_play_notebook.zip

convert to python 3

 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

arcs.py - simple fix

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.