Skip to content

MWE using Gaussian blur filter #96

Answered by cduck
enricofacca asked this question in Q&A
Discussion options

You must be logged in to vote

This is a good question. Filters can be a bit tricky. Here is that example translated to drawsvg:

d = draw.Drawing(230, 120)

# Circle
d.append(draw.Circle(60, 60, 50, fill='green'))

# Blurred circle
blur = draw.Filter()
blur.append(draw.FilterItem('feGaussianBlur', in_='SourceGraphic', stdDeviation=5))
d.append(draw.Circle(170, 60, 50, fill='green', filter=blur))

d.save_svg('out.svg')
d

SVG file content (from print(d.as_svg())):

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
     width="230" height="120" viewBox="0 0 230 120">
<defs>
<filter id="d0">
<feGaussianBlur in="SourceGraphic" stdDeviation="5"></feGauss…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@enricofacca
Comment options

Answer selected by cduck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants