Collection of mostly command line tools / PHP scripts. Somewhat out of date.

⌈⌋ branch:  scripts + snippets


Check-in [519aaabdbf]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fix `attrib` method name, and translate float detection
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1: 519aaabdbf565bb84f2e6523042a9cf0a1674efe
User & Date: mario 2023-11-10 23:35:37
Context
2023-11-10
23:35
fix `attrib` method name, and translate float detection Leaf check-in: 519aaabdbf user: mario tags: trunk
2023-05-23
10:10
prepare potential all-merge mode check-in: 58335bd8d7 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to inkscape/animate_yo.py.

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# author: mario#include-once:org
#
# Allows to add trivial <animate> tags to a SVG document. Embedded animations
# work for standalone SVG graphics. Some instructions are understood by the
# GIF interpolation in ★export_gif (which this was originally intended for).
#
# Usually requires selecting one object/shape/path, invoking the module in
# Extension➜Animation➜Animate-Yo, and selecting one of the tabs to inject an
# <animate*> tag.  The [move] option additionally requires a selected path
# (second argument) from transitioning the main object on.
#
# More timing attributes:
#  · fill, end, min, max, restart, repeatDur,
#  · calcMode, values, by
#  · keyTimes, keyPoints, keySplines







|







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# author: mario#include-once:org
#
# Allows to add trivial <animate> tags to a SVG document. Embedded animations
# work for standalone SVG graphics. Some instructions are understood by the
# GIF interpolation in ★export_gif (which this was originally intended for).
#
# Usually requires selecting one object/shape/path, invoking the module in
# Extension➜Animation➜Animate-Yo, and activating one of the tabs to inject an
# <animate*> tag.  The [move] option additionally requires a selected path
# (second argument) from transitioning the main object on.
#
# More timing attributes:
#  · fill, end, min, max, restart, repeatDur,
#  · calcMode, values, by
#  · keyTimes, keyPoints, keySplines
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
            "type": self.options.mode, # scale
            "from": "1.0 1.0",
            "to": self.options.scale,
        }

    def translate(self):
        """ <animateTransform attributeName=transform to=translate(20 30 50)> """
        nums = re.findall(r"(-?\d+(?:\.\d)?)", self.options.translate)
        if len(nums) == 6:
            func = "matrix"
        elif len(nums) == 2:
            func = "translate"
        else:
            raise AbortExtension("Requires either two params for translate(x y) or six for matrix(a b c d e f)")
        return AnimateTransform,  {
            "attributeName": "transform",
            "attributeType": "XML",
            "type": func, # translate / matrix
            #"from": "0 0",
            "to": self.options.translate,
        }

    def rotate(self):
        """ <animateTransform attributeName=transform to=rotate(360)> """
        if re.search(r"rotate\(.*\)", self.has_transform):
            raise AbortExtension("Can't realistically calculate center point with pre-existing rotation.")
            # obj.transform-origin=center ?







|





|





|







184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
            "type": self.options.mode, # scale
            "from": "1.0 1.0",
            "to": self.options.scale,
        }

    def translate(self):
        """ <animateTransform attributeName=transform to=translate(20 30 50)> """
        nums = re.findall(r"(-?\d+(?:\.\d+)?)", self.options.translate)
        if len(nums) == 6:
            func = "matrix"
        elif len(nums) == 2:
            func = "translate"
        else:
            raise AbortExtension(f"Requires either two params for translate(x y) or six for matrix(a b c d e f) - received '{nums}'")
        return AnimateTransform,  {
            "attributeName": "transform",
            "attributeType": "XML",
            "type": func, # translate / matrix
            #"from": "0 0",
            "to": " ".join(nums),
        }

    def rotate(self):
        """ <animateTransform attributeName=transform to=rotate(360)> """
        if re.search(r"rotate\(.*\)", self.has_transform):
            raise AbortExtension("Can't realistically calculate center point with pre-existing rotation.")
            # obj.transform-origin=center ?
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
            "attributeName": "transform",
            "attributeType": "XML",
            "type": "skewX" if self.options.skew_x else "skewY",
            #"from": "0",
            "to": self.options.skew_x or self.options.skew_y,
        }

    def attribute(self):
        """ <animate attributeName=width to=20px> """
        return Animate, {
            "attributeName": self.options.attr_name,
            "attributeType": "auto", # XML
            "from": self.options.attr_from,
            "to": self.options.attr_to,
        }







|







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
            "attributeName": "transform",
            "attributeType": "XML",
            "type": "skewX" if self.options.skew_x else "skewY",
            #"from": "0",
            "to": self.options.skew_x or self.options.skew_y,
        }

    def attrib(self):
        """ <animate attributeName=width to=20px> """
        return Animate, {
            "attributeName": self.options.attr_name,
            "attributeType": "auto", # XML
            "from": self.options.attr_from,
            "to": self.options.attr_to,
        }