examples from "svg essentials" #83
Replies: 2 comments 3 replies
-
Those examples look nice so far. They could make a good basis for additional documentation pages. DrawingDef
Implement a new element of this type like this: class MyCustomDef(DrawingDef):
TAG_NAME = 'customDef'
def __init__(self, ..., **kwargs):
...
super().__init__(...=..., **kwargs) # All arguments to super().__init__ become SVG attributes RawUse d.append(draw.Raw('''<someTag>...</someTag>''')) Symbol and other elements not provided by drawSvgIf the SVG tag can contain child tags: class Symbol(DrawingParentElement):
TAG_NAME = 'symbol'
def __init__(self, ..., **kwargs):
...
super().__init__(...=..., **kwargs) # All arguments to super().__init__ become SVG attributes If the SVG tag will never contain child tags: class MyCustomTag(DrawingBasicElement):
TAG_NAME = 'customTag'
def __init__(self, ..., **kwargs):
...
super().__init__(...=..., **kwargs) # All arguments to super().__init__ become SVG attributes Using the above: d = draw.Drawing(...)
sym1 = Symbol(...)
sym1.append(draw.Circle(0, 0, r))
d.append(draw.Use(sym1, x, y))
d.append(draw.Use(sym1, x2, y2)) my_parent_tag = MyParentTag(...)
my_parent_tag.append(draw.Circle(...))
d.append(my_parent_tag)
d.append(MyCustomTag(...)) Note: [The d = draw.Drawing(...)
sym1 = draw.Group()
sym1.append(draw.Circle(0, 0, r))
d.append(draw.Use(sym1, x, y))
d.append(draw.Use(sym1, x2, y2)) |
Beta Was this translation helpful? Give feedback.
-
ah that's great --- thanks for informing me.
i did some documentation based on draw2Svg. i will update this, and
send you a pull request. better to keep this all in one place.
is there anywhere a simple example how to insert a statement in the SVG
<defs> tag? this wold be very helpful. i know it should be done with
draw.DrawingDef, but i don't understand how.
…On 26/02/2023 10:46, Casey Duckering wrote:
Thanks for the feedback! I hope you check out the newly released version 2.
—
Reply to this email directly, view it on GitHub
<#83 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAQYHKW2GB5FOGLL5MPYZ23WZMQ6PANCNFSM6AAAAAATDCXBMY>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
as i am learning svg, and would like to use it with drawSvg, i started to convert the examples from david eisenberg's "svg essentials" to drawSvg code in my fork.
if you are interested in adding them to your examples, i can send you a pull request, after i finished.
for some topics i would need some help though. i am not really able to understand the details of your code. the examples are good, but too few. questions so far:
defs
element.symbol
element.thanks for the great library -
joachim
Beta Was this translation helpful? Give feedback.
All reactions