added frame animation sequence
This commit is contained in:
parent
f2a7e671f1
commit
212c7786f8
@ -1,6 +1,6 @@
|
||||
# MightyScape for Inkscape 1.0+
|
||||
|
||||
In short: A maintained extension collection for Inkscape 1.0+, working on Windows and Linux. There are **221 extension folders** with **388 .inx files** inside. We also take part at https://inkscape.org/gallery/=extension/ (with single extension uploads).
|
||||
In short: A maintained extension collection for Inkscape 1.0+, working on Windows and Linux. There are **224 extension folders** with **395 .inx files** inside. We also take part at https://inkscape.org/gallery/=extension/ (with single extension uploads).
|
||||
|
||||
# About MightyScape
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>Frame Animation Sequence</name>
|
||||
<id>fablabchemnitz.de.frame_animation_sequence</id>
|
||||
<param name="begin_str" type="string" gui-text="begin_str:">0</param>
|
||||
<param name="repeat_str" type="string" gui-text="repeat_str:">indefinite</param>
|
||||
<param name="dur_str" type="string" gui-text="dur_str:">9.1</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu name="FabLab Chemnitz">
|
||||
<submenu name="Various"/>
|
||||
</submenu>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
<command location="inx" interpreter="python">frame_animation_sequence.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
#
|
||||
# Copyright (C) 2021 roberta bennett repeatingshadow@protonmail.com
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
"""
|
||||
Create svg path animation from frames.
|
||||
|
||||
Place each frame of the animation in a layer named 'frame'.
|
||||
Each of these layers should have the same number of paths,
|
||||
and each path should have the same number of points as the corresponding
|
||||
path in other layers.
|
||||
|
||||
The animation is applied to the paths in the first layer in the sequence, so the
|
||||
properties of that layer are used.
|
||||
|
||||
Animations with different numbers of frames can be put into different sequences,
|
||||
named 'sequence', using sub-groups:
|
||||
|
||||
Layers:
|
||||
not_animated_layer1
|
||||
sequence
|
||||
frame
|
||||
path1a
|
||||
path2a
|
||||
frame
|
||||
path1b
|
||||
path2b
|
||||
frame
|
||||
path1c
|
||||
path2c
|
||||
frame
|
||||
path1d
|
||||
path2d
|
||||
sequence
|
||||
frame
|
||||
frame
|
||||
frame
|
||||
|
||||
|
||||
use layer named exactly 'frame' and groups named exactly 'sequence',
|
||||
not, eg, frame1 frame2 frame3 !
|
||||
|
||||
"""
|
||||
|
||||
import inkex
|
||||
|
||||
class AnimateElement(inkex.BaseElement):
|
||||
"""animation Elements do not have a visible representation on the canvas"""
|
||||
tag_name = 'animate'
|
||||
@classmethod
|
||||
def new(cls, **attrs):
|
||||
return super().new( **attrs)
|
||||
|
||||
|
||||
class AnimationExtension(inkex.EffectExtension):
|
||||
|
||||
def add_arguments(self, pars):
|
||||
pars.add_argument("--begin_str", default="0", help="begin string: eg 0;an2.end;an3.begin")
|
||||
pars.add_argument("--repeat_str", default="indefinite", help="indefinite or an integer")
|
||||
pars.add_argument("--dur_str", default="7.9", help="duration in seconds. Do not decorate with units")
|
||||
|
||||
|
||||
def effect(self):
|
||||
sequences = self.svg.findall("svg:g[@inkscape:label='sequence']")
|
||||
if len(sequences) == 0:
|
||||
raise inkex.AbortExtension("layer named sequence does not exist.")
|
||||
for sequence in sequences:
|
||||
frames = sequence.findall("svg:g[@inkscape:label='frame']")
|
||||
if len(frames) == 0:
|
||||
raise inkex.AbortExtension("layer named frame does not exist.")
|
||||
frame0paths = frames[0].findall('svg:path')
|
||||
Dlists = [p.get_path() for p in frame0paths]
|
||||
for frame in frames[1:]:
|
||||
paths = frame.findall("svg:path")
|
||||
for i,p in enumerate(paths):
|
||||
Dlists[i] += ";\n"+p.get_path()
|
||||
for i,dl in enumerate(Dlists):
|
||||
animel = AnimateElement(
|
||||
attributeName="d",
|
||||
attributeType="XML",
|
||||
begin=self.options.begin_str,
|
||||
dur=self.options.dur_str,
|
||||
repeatCount=self.options.repeat_str,
|
||||
values=dl)
|
||||
frame0paths[i].append(animel)
|
||||
|
||||
if __name__ == '__main__':
|
||||
AnimationExtension().run()
|
||||
|
||||
|
20
extensions/fablabchemnitz/frame_animation_sequence/meta.json
Normal file
20
extensions/fablabchemnitz/frame_animation_sequence/meta.json
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"name": "Frame Animation Sequence",
|
||||
"id": "fablabchemnitz.de.frame_animation_sequence",
|
||||
"path": "frame_animation_sequence",
|
||||
"original_name": "Animate Extension",
|
||||
"original_id": "org.inkscape.katkitty.animate",
|
||||
"license": "GNU GPL v2",
|
||||
"license_url": "https://github.com/yttiktak/inkscape_extension_animate/blob/main/AnimationExtension.py",
|
||||
"comment": "",
|
||||
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/frame_animation_sequence",
|
||||
"fork_url": "https://github.com/yttiktak/inkscape_extension_animate",
|
||||
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Frame+Animation+Sequence",
|
||||
"inkscape_gallery_url": null,
|
||||
"main_authors": [
|
||||
"https://github.com/yttiktak",
|
||||
"github.com/vmario89"
|
||||
]
|
||||
}
|
||||
]
|
@ -6,7 +6,7 @@
|
||||
<page name="settings" gui-text="Settings">
|
||||
<label appearance="header">Measures and tab generation</label>
|
||||
<param name="tabangle" type="float" min="0.01" max="90.0" precision="2" gui-text="Angle of tab edges (degrees):">45.00</param>
|
||||
<param name="tabheight" type="float" min="0.01" max="9999.0" precision="2" gui-text="Height of tab:">0.40</param>
|
||||
<param name="tabheight" type="float" min="0.01" max="9999.0" precision="3" gui-text="Height of tab:">0.400</param>
|
||||
<param name="dashlength" type="float" min="0.0" max="9999.0" precision="3" gui-text="Length of dash line (zero for solid line):" gui-description="If value larger than zero the line will split up into real dash lines (no cosmetic one's)">0.1</param>
|
||||
<param name="tabsets" type="optiongroup" appearance="combo" gui-text="Tab placement on polygons with cutouts:">
|
||||
<option value="outside">outside</option>
|
||||
|
Reference in New Issue
Block a user