12 for node
in self._nodes:
13 node.initialize_object(kw, self)
16 if name
in self._nodemap:
17 value = self._nodemap[name].clean(value)
23 for node
in cls._nodes:
24 node.from_xml(instance, xml, registry)
28 def from_dom(cls, xml: minidom.Element, registry: ObjectRegistry):
29 return SifNode.static_from_dom(cls, xml, registry)
31 def to_dom(self, dom: minidom.Document):
32 element = dom.createElement(self._tag)
33 for node
in self._nodes:
34 node.to_xml(self, element, dom)
44 def from_dom(cls, xml: minidom.Element, registry: ObjectRegistry):
45 if xml.tagName ==
"bone_link":
46 return SifNode.static_from_dom(BoneLinkTransform, xml, registry)
48 if xml.tagName !=
"composite":
49 raise ValueError(
"Invalid transform element: %s" % xml.tagName)
50 return SifNode.static_from_dom(SifTransform, xml, registry)
84 XmlList(BlinePoint,
"points",
"entry"),
135 def from_dom(cls, xml: minidom.Element, registry: ObjectRegistry):
138 actual_class = Def.def_types()[xml.tagName]
140 obj = SifNode.static_from_dom(actual_class, xml, registry)
142 registry.register_as(obj, obj.id)
144 registry.register(obj)
149 return list(Def.def_types().keys())
153 if Def._subclasses
is None:
155 Def._gather_def_types(Def)
156 return Def._subclasses
159 def _gather_def_types(cls):
160 for subcls
in cls.__subclasses__():
161 Def._subclasses[subcls._tag] = subcls
162 Def._gather_def_types(subcls)
175 return getattr(self,
"from")
179 setattr(self,
"from", value)
190 element.setAttribute(
"id", self.
idid)
204 XmlAttribute(
"exclude_from_rendering", bool_str,
False),
209 kw.setdefault(
"version", self.
_version_version)
214 return "<%s.%s %r>" % (__name__, self.__class__.__name__, self.desc
or self.
typetype)
217 element = dom.createElement(
"layer")
218 for node
in self.
_nodes_nodes:
219 node.to_xml(self, element, dom)
223 def from_dom(cls, xml: minidom.Element, registry: ObjectRegistry):
226 type = xml.getAttribute(
"type")
227 actual_class = Layer.layer_types().get(type, Layer)
229 return SifNode.static_from_dom(actual_class, xml, registry)
233 if Layer._types
is None:
235 Layer._gather_layer_types(Layer)
239 def _gather_layer_types(cls):
240 for subcls
in cls.__subclasses__():
241 if subcls._layer_type:
242 Layer._types[subcls._layer_type] = subcls
243 Layer._gather_layer_types(subcls)
250 XmlParam(
"blend_method",
"integer", BlendMethod.Composite, BlendMethod, static=
True),
257 XmlParamSif(
"transformation", AbstractTransform, SifTransform),
260 XmlParam(
"time_dilation",
"real", 1.),
262 XmlParam(
"children_lock",
"bool",
False, static=
True),
263 XmlParam(
"outline_grow",
"real", 0.),
267 self.layers.append(layer)
272 _layer_type =
"filter_group"
279 _layer_type =
"group"
283 XmlParam(
"z_range",
"bool",
False, static=
True),
284 XmlParam(
"z_range_position",
"real", 0.),
285 XmlParam(
"z_range_depth",
"real", 0.),
286 XmlParam(
"z_range_blur",
"real", 0.),
291 _layer_type =
"switch"
295 XmlParam(
"layer_depth",
"integer", -1),
300 _layer_type =
"rectangle"
311 XmlParam(
"bevCircle",
"bool",
True),
316 _layer_type =
"circle"
328 _layer_type =
"simple_circle"
342 XmlParam(
"antialias",
"bool",
True),
344 XmlParam(
"blurtype",
"integer", BlurType.FastGaussian, BlurType),
345 XmlParam(
"winding_style",
"integer", WindingStyle.NonZero, WindingStyle),
357 XmlParam(
"regular_polygon",
"bool",
False),
385 _layer_type =
"outline"
388 XmlParam(
"sharp_cusps",
"bool",
True),
389 XmlParam(
"round_tip[0]",
"bool",
True),
390 XmlParam(
"round_tip[1]",
"bool",
True),
391 XmlParam(
"homogeneous_width",
"bool",
True),
396 return LineCap.Rounded
if self.round_tip_0
else LineCap.Flat
400 return LineCap.Rounded
if self.round_tip_1
else LineCap.Flat
404 return CuspStyle.Miter
if self.sharp_cusps
else CuspStyle.Round
408 _layer_type =
"advanced_outline"
411 XmlParam(
"start_tip",
"integer", LineCap.Rounded, LineCap),
412 XmlParam(
"end_tip",
"integer", LineCap.Rounded, LineCap),
413 XmlParam(
"cusp_type",
"integer", CuspStyle.Miter, CuspStyle),
415 XmlParam(
"homogeneous",
"bool",
False),
421 _layer_type =
"polygon"
429 _layer_type =
"region"
449 XmlParam(
"style",
"integer", FontStyle.Normal, FontStyle),
456 XmlParam(
"use_kerning",
"bool",
False),
457 XmlParam(
"grid_fit",
"bool",
False),
466 class TranslateLayer(TransformDown):
467 _layer_type =
"translate"
470 XmlParam(
"origin",
"vector", NVector(0, 0)),
475 _layer_type =
"rotate"
494 XmlParam(
"gradient",
"gradient", []),
501 _layer_type =
"radial_gradient"
510 _layer_type =
"linear_gradient"
519 _layer_type =
"conical_gradient"
522 XmlParam(
"gradient",
"gradient", []),
523 XmlParam(
"symmetric",
"bool",
False),
530 _layer_type =
"curve_gradient"
534 XmlParam(
"width",
"real", 0.0833333358),
536 XmlParam(
"perpendicular",
"bool",
False),
542 _layer_type =
"noise"
545 XmlParam(
"gradient",
"gradient", []),
548 XmlParam(
"smooth",
"integer", Smooth.Cosine, Smooth),
551 XmlParam(
"turbulent",
"bool",
False),
552 XmlParam(
"do_alpha",
"bool",
False),
553 XmlParam(
"super_sample",
"bool",
False),
558 _layer_type =
"spiral_gradient"
561 XmlParam(
"gradient",
"gradient", []),
565 XmlParam(
"clockwise",
"bool",
False),
578 def from_dom(cls, xml: minidom.Element, registry: ObjectRegistry):
579 if xml.tagName ==
"bone_root":
580 val = SifNode.static_from_dom(BoneRoot, xml, registry)
582 val = SifNode.static_from_dom(Bone, xml, registry)
583 registry.register(val)
587 return "<%s %r>" % (self.__class__.__name__, self.guid)
622 _layer_type =
"skeleton"
639 _layer_type =
"MotionBlur"
643 XmlParam(
"subsamples_factor",
"real", 1.),
644 XmlParam(
"subsampling_type",
"integer", SubsamplingType.Hyperbolic, SubsamplingType),
645 XmlParam(
"subsample_start",
"real", 0.),
646 XmlParam(
"subsample_end",
"real", 1.),
655 XmlParam(
"type",
"integer", BlurType.FastGaussian, BlurType),
660 _layer_type =
"radial_blur"
665 XmlParam(
"fade_out",
"bool",
False),
670 _layer_type =
"curve_warp"
683 _layer_type =
"inside_out"
691 _layer_type =
"noise_distort"
697 XmlParam(
"smooth",
"integer", Smooth.Cosine, Smooth),
700 XmlParam(
"turbulent",
"bool",
False),
705 _layer_type =
"skeleton_deformation"
711 XmlParam(
"x_subdivisions",
"integer", 32),
712 XmlParam(
"y_subdivisions",
"integer", 32),
724 _layer_type =
"spherize"
731 XmlParam(
"type",
"integer", DistortType.Spherize, DistortType),
736 _layer_type =
"stretch"
745 _layer_type =
"twirl"
751 XmlParam(
"distort_inside",
"bool",
True),
752 XmlParam(
"distort_outside",
"bool",
False),
767 XmlParam(
"interpolation",
"integer", Smooth.Cubic, Smooth),
772 _layer_type =
"metaballs"
775 XmlParam(
"gradient",
"gradient", []),
781 XmlParam(
"positive",
"bool",
False),
786 _layer_type =
"clamp"
789 XmlParam(
"invert_negative",
"bool",
False),
790 XmlParam(
"clamp_ceiling",
"bool",
False),
797 _layer_type =
"colorcorrect"
800 XmlParam(
"hue_adjust",
"angle", 0.),
816 _layer_type =
"halftone2"
824 XmlParam(
"type",
"integer", HalftoneType.Symmetric, HalftoneType),
829 _layer_type =
"halftone3"
834 XmlParam(
"type",
"integer", HalftoneType.Symmetric, HalftoneType),
835 XmlParam(
"subtractive",
"bool",
True),
839 XmlParam(
"tone[0].angle",
"angle", 0.),
843 XmlParam(
"tone[1].angle",
"angle", 30.),
847 XmlParam(
"tone[2].angle",
"angle", 60.),
852 _layer_type =
"lumakey"
859 _layer_type =
"julia"
864 XmlParam(
"color_shift",
"real", 0.),
865 XmlParam(
"iterations",
"integer", 32),
868 XmlParam(
"distort_inside",
"bool",
True),
869 XmlParam(
"shade_inside",
"bool",
True),
870 XmlParam(
"solid_inside",
"bool",
False),
871 XmlParam(
"invert_inside",
"bool",
False),
872 XmlParam(
"color_inside",
"bool",
True),
873 XmlParam(
"distort_outside",
"bool",
True),
874 XmlParam(
"shade_outside",
"bool",
True),
875 XmlParam(
"solid_outside",
"bool",
False),
876 XmlParam(
"invert_outside",
"bool",
False),
877 XmlParam(
"color_outside",
"bool",
False),
878 XmlParam(
"color_cycle",
"bool",
False),
879 XmlParam(
"smooth_outside",
"bool",
True),
885 _layer_type =
"mandelbrot"
888 XmlParam(
"iterations",
"integer", 32),
891 XmlParam(
"distort_inside",
"bool",
True),
892 XmlParam(
"shade_inside",
"bool",
True),
893 XmlParam(
"solid_inside",
"bool",
False),
894 XmlParam(
"invert_inside",
"bool",
False),
895 XmlParam(
"distort_outside",
"bool",
True),
896 XmlParam(
"shade_outside",
"bool",
True),
897 XmlParam(
"solid_outside",
"bool",
False),
898 XmlParam(
"invert_outside",
"bool",
False),
899 XmlParam(
"smooth_outside",
"bool",
True),
901 XmlParam(
"gradient_inside",
"gradient", []),
902 XmlParam(
"gradient_offset_inside",
"real", 0.),
903 XmlParam(
"gradient_loop_inside",
"bool",
True),
905 XmlParam(
"gradient_outside",
"gradient", []),
906 XmlParam(
"gradient_offset_outside",
"real", 0.),
907 XmlParam(
"gradient_loop_outside",
"bool",
True),
908 XmlParam(
"gradient_scale_outside",
"real", 1.),
913 _layer_type =
"checker_board"
919 XmlParam(
"antialias",
"bool",
True),
924 _layer_type =
"SolidColor"
932 _layer_type =
"duplicate"
940 _layer_type =
"import"
945 XmlParam(
"c",
"integer", Smooth.Linear, Smooth),
946 XmlParam(
"gamma_adjust",
"real", 1.),
953 _layer_type =
"plant"
958 XmlParam(
"gradient",
"gradient", []),
959 XmlParam(
"split_angle",
"angle", 10.),
962 XmlParam(
"perp_velocity",
"real", 0.),
964 XmlParam(
"size_as_alpha",
"bool",
False),
970 XmlParam(
"random_factor",
"real", 0.2),
972 XmlParam(
"use_width",
"bool",
True),
977 _layer_type =
"sound"
988 _layer_type =
"super_sample"
993 XmlParam(
"scanline",
"bool",
False),
994 XmlParam(
"alpha_aware",
"bool",
True),
999 _layer_type =
"xor_pattern"
1008 _layer_type =
"bevel"
1011 XmlParam(
"type",
"integer", BlurType.FastGaussian, BlurType),
1017 XmlParam(
"use_luma",
"bool",
False),
1023 _layer_type =
"shade"
1026 XmlParam(
"type",
"integer", BlurType.FastGaussian, BlurType),
1035 _layer_type =
"freetime"
1044 _layer_type =
"stroboscope"
1053 _layer_type =
"timeloop"
1057 XmlParam(
"link_time",
"time",
FrameTime(0, FrameTime.Unit.Seconds), static=
True),
1058 XmlParam(
"local_time",
"time",
FrameTime(0, FrameTime.Unit.Seconds), static=
True),
1059 XmlParam(
"duration",
"time",
FrameTime(0, FrameTime.Unit.Seconds), static=
True),
1060 XmlParam(
"only_for_positive_duration",
"bool",
False, static=
True),
1061 XmlParam(
"symmetrical",
"bool",
True, static=
True),
1089 XmlMeta(
"background_first_color", NVector,
NVector(0.88, 0.88, 0.88)),
1090 XmlMeta(
"background_rendering", bool,
False),
1091 XmlMeta(
"background_second_color", NVector,
NVector(0.65, 0.65, 0.65)),
1094 XmlMeta(
"grid_show", bool,
False),
1096 XmlMeta(
"grid_snap", bool,
False),
1098 XmlMeta(
"guide_show", bool,
True),
1099 XmlMeta(
"guide_snap", bool,
False),
1100 XmlMeta(
"jack_offset", float, 0),
1101 XmlMeta(
"onion_skin", bool,
False),
1102 XmlMeta(
"onion_skin_future", int, 0),
1103 XmlMeta(
"onion_skin_past", int, 1),
1111 SifNode.__init__(self, **kw)
1112 ObjectRegistry.__init__(self)
1115 dom = minidom.Document()
1116 dom.appendChild(self.
to_domto_dom(dom))
1121 if isinstance(xml, str):
1122 with open(xml,
"r")
as file:
1123 return cls.
from_xmlfrom_xml(minidom.parse(file))
1124 return cls.
from_xmlfrom_xml(minidom.parse(xml))
1128 return cls.
from_xmlfrom_xml(minidom.parseString(xml))
1137 def from_dom(cls, xml: minidom.Element, registry: ObjectRegistry =
None):
1139 for node
in cls.
_nodes_nodes:
1140 node.from_xml(instance, xml, instance)
1144 if time.unit == FrameTime.Unit.Frame:
1146 elif time.unit == FrameTime.Unit.Seconds:
1147 return time.value * self.fps
1150 self.layers.append(layer)
1155 Applies Gamma to the rgb values
1175 _tag =
"weighted_vector"
def from_dom(cls, minidom.Element xml, ObjectRegistry registry)
def add_layer(self, Layer layer)
def from_xml_string(cls, xml)
def from_dom(cls, minidom.Element xml, ObjectRegistry registry=None)
def time_to_frames(self, FrameTime time)
def from_xml(cls, minidom.Document xml)
def from_xml_file(cls, xml)
def make_color(self, r, g, b, a=1)
def from_dom(cls, minidom.Element xml, ObjectRegistry registry)
def to_dom(self, minidom.Document dom)
def __init__(self, id, value, typename)
def add_layer(self, Layer layer)
def from_dom(cls, minidom.Element xml, ObjectRegistry registry)
def to_dom(self, minidom.Document dom)
def static_from_dom(cls, minidom.Element xml, ObjectRegistry registry)
def from_dom(cls, minidom.Element xml, ObjectRegistry registry)
def __setattr__(self, name, value)
def to_dom(self, minidom.Document dom)