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

⌈⌋ branch:  scripts + snippets


Check-in [c284f16d06]

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

Overview
Comment:hex_color redundant with inkex.Color
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c284f16d06d2568388744c801b0d9e257fe8f260
User & Date: mario 2022-10-11 07:12:27
Context
2022-10-12
13:01
recombine zip_args into imagick_gif(), distribute some flags onto frame.pngs check-in: 4621d9c6bd user: mario tags: trunk
2022-10-11
07:12
hex_color redundant with inkex.Color check-in: c284f16d06 user: mario tags: trunk
07:12
separate handler for notebook/page sectioning check-in: 6b16bde070 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to inkscape/animate_yo.py.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#    { class: repeat, name: repeat_count, type: select, select: "indefinite|0|1|2|3|4|5|10|15|20|25|50|100", value: style, description: repeatCount, help: "How often this animation loops. (Ignored by gif_export, where animations are generally per-frame.)" }
#    { class: repeat, name: repeat_fill, type: select, select: "freeze|remove", value: freeze, translatable: no, description: repeatFill, help: "Animation can either stay at last state, or reset to value before animation. (gif_export always reverts to previous slide state)" }
#    { class: calc, name: calc_mode, type: select, select: "linear|discrete|paced|spline", value: "linear", description: "calcMode", help: "Defines if values in animation are traversed in a straight from-to progression (linear), jump from start to end (discrete), slowly speed up (paced), or use a list of values/keyTimes (spline)." }
#    { class: calc, name: key_values, type: str, value: "", description: "(key)values", help: "Spline mode: Instead of a single to= attribute, can give a list of values `12px;20px;50px` or `#f33;#77cc99;#03F` for use with keyTimes/Splines." }
#    { class: calc, name: key_times, type: str, value: "", description: "keyTimes", help: "Spline mode: Lists the time lapse positions `0.0; 0.3; 0.9; 1.0` when point in values= list should be approached." }
#    { class: calc, name: key_splines, type: str, value: "", description: "keySplines", help: "Spline mode: defines bezier curves for use with keyTimes. (Ignored by gif_export)" }
#    { class: id, name: set_id, type: str, value: "", description: "Assign #id", help: "Animation itself can have an #id for referencing." }
#    {  xml: </page></param> }
#    { name: remove_child, type: bool, value: 0, description: "Strip previous animation", help: "Remove any existing ﹤animate*﹥ tags from selected object. (Else use the XML editor Ctrl+Shift+X.)" }
#    {  xml: </vbox><image width='220' height='220'>animate_yo.svg</image></hbox> }
#    { name: mode, type: notebook, select: "style|scale|rotate|translate|skewxy|attrib|move", value: style, description: Animation mode, help: Animation }
#    { class: style,  name: style, type: select, select: "fill|stroke|fill-opacity|stroke-opacity|stroke-width", value: style, description: Attribute, help: "Can change either colors, opacity, or width.", translatable: no }
#    { class: style,  name: color, type: color, appearance: colorbutton, value: "#ff5555", description: Color, help: Target color, translatable: no }
#    { class: style,  name: style_val, type: str, value: "", description: Opacity/width, help: "Use a fraction 0.75 for opacity. Or an integer 25 for widths." }
#    { class: scale,  name: scale, type: str, value: "1.0 1.0", description: Scaling, help: "Scales both width and height. Specify fractions each. For example 0.0 will vanish the object, or 2.0 double it per dimension. Beware that this transform can 'scale' x= and y= positions alongside. Can also be a single value `2.5` to scale both width and height." }






<







19
20
21
22
23
24
25

26
27
28
29
30
31
32
#    { class: repeat, name: repeat_count, type: select, select: "indefinite|0|1|2|3|4|5|10|15|20|25|50|100", value: style, description: repeatCount, help: "How often this animation loops. (Ignored by gif_export, where animations are generally per-frame.)" }
#    { class: repeat, name: repeat_fill, type: select, select: "freeze|remove", value: freeze, translatable: no, description: repeatFill, help: "Animation can either stay at last state, or reset to value before animation. (gif_export always reverts to previous slide state)" }
#    { class: calc, name: calc_mode, type: select, select: "linear|discrete|paced|spline", value: "linear", description: "calcMode", help: "Defines if values in animation are traversed in a straight from-to progression (linear), jump from start to end (discrete), slowly speed up (paced), or use a list of values/keyTimes (spline)." }
#    { class: calc, name: key_values, type: str, value: "", description: "(key)values", help: "Spline mode: Instead of a single to= attribute, can give a list of values `12px;20px;50px` or `#f33;#77cc99;#03F` for use with keyTimes/Splines." }
#    { class: calc, name: key_times, type: str, value: "", description: "keyTimes", help: "Spline mode: Lists the time lapse positions `0.0; 0.3; 0.9; 1.0` when point in values= list should be approached." }
#    { class: calc, name: key_splines, type: str, value: "", description: "keySplines", help: "Spline mode: defines bezier curves for use with keyTimes. (Ignored by gif_export)" }
#    { class: id, name: set_id, type: str, value: "", description: "Assign #id", help: "Animation itself can have an #id for referencing." }

#    { name: remove_child, type: bool, value: 0, description: "Strip previous animation", help: "Remove any existing ﹤animate*﹥ tags from selected object. (Else use the XML editor Ctrl+Shift+X.)" }
#    {  xml: </vbox><image width='220' height='220'>animate_yo.svg</image></hbox> }
#    { name: mode, type: notebook, select: "style|scale|rotate|translate|skewxy|attrib|move", value: style, description: Animation mode, help: Animation }
#    { class: style,  name: style, type: select, select: "fill|stroke|fill-opacity|stroke-opacity|stroke-width", value: style, description: Attribute, help: "Can change either colors, opacity, or width.", translatable: no }
#    { class: style,  name: color, type: color, appearance: colorbutton, value: "#ff5555", description: Color, help: Target color, translatable: no }
#    { class: style,  name: style_val, type: str, value: "", description: Opacity/width, help: "Use a fraction 0.75 for opacity. Or an integer 25 for widths." }
#    { class: scale,  name: scale, type: str, value: "1.0 1.0", description: Scaling, help: "Scales both width and height. Specify fractions each. For example 0.0 will vanish the object, or 2.0 double it per dimension. Beware that this transform can 'scale' x= and y= positions alongside. Can also be a single value `2.5` to scale both width and height." }
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
            if child.tag_name != tag_name: # only remove identically-named
                continue
            parent.remove(child)

    def style(self):
        """ <animate attributeName=color to=red> """
        if self.options.style in ("fill", "stroke"):
            val = hex_color(self.options.color)
        else:
            val = self.options.style_val
        return Animate, {
            "attributeName": self.options.style,
            "attributeType": "CSS",
            #"from": "",
            "to": val,






|







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
            if child.tag_name != tag_name: # only remove identically-named
                continue
            parent.remove(child)

    def style(self):
        """ <animate attributeName=color to=red> """
        if self.options.style in ("fill", "stroke"):
            val = str(self.options.color)
        else:
            val = self.options.style_val
        return Animate, {
            "attributeName": self.options.style,
            "attributeType": "CSS",
            #"from": "",
            "to": val,
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
        while args["id"] and self.svg.getElementById(args["id"]):
            args["id"] = "anim" + str(random.randint(100, 10000))

        return {
            key: val for key, val in args.items() if val
        }


def hex_color(col):
    """ convert ints or inkex.Color tuple to #hex color """
    if isinstance(col, list):
        col = list(col)
        if len(col) == 3:
            col.append(1.0)
        col = (int(col[0])<<24) + (int(col[1])<<16) + (int(col[2])<<8) + int(col[3]*255)
    return "#{:08X}".format(col & 0xFFFFFFFF)

class Animate(inkex.BaseElement):
    """Title element"""
    tag_name = "animate"

class AnimateTransform(inkex.BaseElement):
    """Title element"""
    tag_name = "animateTransform"






<
<
<
<
<
<
<
<
<
<







272
273
274
275
276
277
278










279
280
281
282
283
284
285
        while args["id"] and self.svg.getElementById(args["id"]):
            args["id"] = "anim" + str(random.randint(100, 10000))

        return {
            key: val for key, val in args.items() if val
        }











class Animate(inkex.BaseElement):
    """Title element"""
    tag_name = "animate"

class AnimateTransform(inkex.BaseElement):
    """Title element"""
    tag_name = "animateTransform"