silkenweb/elements/svg/attributes.rs
1//! Groups of SVG attributes.
2
3use super::{
4 content_type::{Length, NumberOrPercentage},
5 path::Data,
6};
7use crate::node::element::Element;
8
9macro_rules! svg_attributes {
10 ($($t:tt)*) => {
11 attributes![
12 [
13 attribute_parent = (),
14 attribute_doc_macro = svg_attribute_doc
15 ]
16
17 $($t)*
18 ];
19 };
20}
21
22/// SVG [core] attributes
23///
24/// [core]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Core
25pub trait Core: Element {
26 svg_attributes.
37 lang: String,
38 /// The tabindex SVG attribute allows you to control whether an element
39 /// is focusable and to define the relative order of the element for the
40 /// purposes of sequential focus navigation. Animatable: No
41 tabindex: i32,
42 /// It specifies style information for its element. It functions
43 /// identically to the style attribute in HTML. Value: Any valid style
44 /// string; Animatable: No
45 style: String,
46 ];
47}
48
49/// SVG [animation] timing attributes
50///
51/// [animation]:https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute#animation_attributes
52pub trait AnimationTiming: Element {
53 svg_attributes![
54 /// The begin attribute defines when an animation should begin or when
55 /// an element should be discarded.
56 ///
57 /// The attribute value is a semicolon separated list of values. The
58 /// interpretation of a list of start times is detailed in the SMIL
59 /// specification in "Evaluation of begin and end time lists". Each
60 /// individual value can be one of the following :
61 /// - `<offset-value>`
62 /// - `<syncbase-value>`
63 /// - `<event-value>`
64 /// - `<repeat-value>`
65 /// - `<accessKey-value>`
66 /// - `<wallclock-sync-value>`
67 /// - the keyword indefinite.
68 begin: String,
69 /// The dur attribute indicates the simple duration of an animation.
70 dur: String,
71 /// The end attribute defines an end value for the animation that can
72 /// constrain the active duration.
73 end: String,
74 /// The min attribute specifies the minimum value of the active
75 /// animation duration.
76 min: String,
77 /// The max attribute specifies the maximum value of the active
78 /// animation duration.
79 max: String,
80 /// The restart attribute specifies whether or not an animation can
81 /// restart.
82 restart: String,
83 /// The repeatCount attribute indicates the number of times an animation
84 /// will take place.
85 repeat_count("repeatCount"): String,
86 /// The repeatDur attribute specifies the total duration for repeating
87 /// an animation.
88 repeat_dur("repeatDur"): String,
89 /// The fill attribute has two different meanings. For shapes and text
90 /// it's a presentation attribute that defines the color (or any SVG
91 /// paint servers like gradients or patterns) used to paint the element;
92 /// for animation it defines the final state of the animation.
93 fill: String,
94 ];
95}
96
97/// SVG [animation] value attributes
98///
99/// [animation]:https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute#animation_attributes
100pub trait AnimationValue: Element {
101 svg_attributes![
102 /// The calcMode attribute specifies the interpolation mode for the
103 /// animation.
104 ///
105 /// The default mode is linear, however if the attribute does not
106 /// support linear interpolation (e.g. for strings), the calcMode
107 /// attribute is ignored and discrete interpolation is used.
108 calc_mode("calcMode"): String,
109 /// The values attribute has different meanings, depending upon the
110 /// context where it's used, either it defines a sequence of values used
111 /// over the course of an animation, or it's a list of numbers for a
112 /// color matrix, which is interpreted differently depending on the type
113 /// of color change to be performed.
114 values: String,
115 /// The keyTimes attribute represents a list of time values used to
116 /// control the pacing of the animation.
117 ///
118 /// Each time in the list corresponds to a value in the values attribute
119 /// list, and defines when the value is used in the animation. Each time
120 /// value in the keyTimes list is specified as a floating point value
121 /// between 0 and 1 (inclusive), representing a proportional offset into
122 /// the duration of the animation element.
123 key_times("keyTimes"): String,
124 /// The keySplines attribute defines a set of Bézier curve control
125 /// points associated with the keyTimes list, defining a cubic Bézier
126 /// function that controls interval pacing.
127 ///
128 /// This attribute is ignored unless the calcMode attribute is set to
129 /// spline.
130 ///
131 /// If there are any errors in the keySplines specification (bad values,
132 /// too many or too few values), the animation will not occur.
133 key_splines("keySplines"): String,
134 /// The from attribute indicates the initial value of the attribute that
135 /// will be modified during the animation.
136 ///
137 /// When used with the to attribute, the animation will change the
138 /// modified attribute from the from value to the to value. When used
139 /// with the by attribute, the animation will change the attribute
140 /// relatively from the from value by the value specified in by.
141 from: String,
142 /// The to attribute indicates the final value of the attribute that
143 /// will be modified during the animation.
144 ///
145 /// The value of the attribute will change between the from attribute
146 /// value and this value.
147 to: String,
148 /// The by attribute specifies a relative offset value for an attribute
149 /// that will be modified during an animation.
150 ///
151 /// The starting value for the attribute is either indicated by
152 /// specifying it as value for the attribute given in the attributeName
153 /// or the from attribute.
154 by: String,
155 /// Undocumented in MDN
156 auto_reverse("autoReverse"): String,
157 /// Undocumented in MDN
158 accelerate: String,
159 /// Undocumented in MDN
160 decelerate: String,
161 ];
162}
163
164/// Other SVG [animation] attributes
165///
166/// [animation]:https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute#animation_attributes
167pub trait OtherAnimation: Element {
168 svg_attributes![
169 /// The attributeName attribute indicates the name of the CSS property
170 /// or attribute of the target element that is going to be changed
171 /// during an animation.
172 attribute_name("attributeName"): String,
173 /// The additive attribute controls whether or not an animation is
174 /// additive.
175 additive: String,
176 /// The accumulate attribute controls whether or not an animation is
177 /// cumulative.
178 ///
179 /// It is frequently useful for repeated animations to build upon the
180 /// previous results, accumulating with each iteration. This attribute
181 /// said to the animation if the value is added to the previous animated
182 /// attribute's value on each iteration.
183 accumulate: String,
184 ];
185}
186
187/// SVG [Presentation] Attributes
188///
189/// [Presentation]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Presentation
190pub trait Presentation: Element {
191 svg_attributes![
192 /// It specifies how an object is aligned along the font baseline with
193 /// respect to its parent. Value:
194 /// auto|baseline|before-edge|text-before-edge|middle|central|after-edge|text-after-edge|ideographic|alphabetic|hanging|mathematical|inherit;
195 /// Animatable: Yes
196 alignment_baseline: String,
197 /// It allows repositioning of the dominant-baseline relative to the
198 /// dominant-baseline of the parent text content element. Value:
199 /// auto|baseline|super|sub|`<percentage>`|`<length>`|inherit;
200 /// Animatable: Yes
201 baseline_shift: String,
202 /// It binds the element it is applied to with a given `<clipPath>`
203 /// element. Value: none|`<FuncIRI>`|inherit; Animatable: Yes
204 clip_path: String,
205 /// It indicates how to determine what side of a path is inside a shape
206 /// in order to know how a `<clipPath>` should clip its target. Value:
207 /// nonezero|evenodd|inherit; Animatable: Yes
208 clip_rule: String,
209 /// It provides a potential indirect value (currentcolor) for the fill,
210 /// stroke, stop-color, flood-color and lighting-color presentation
211 /// attributes. Value: `<color>`|inherit; Animatable: Yes
212 color: String,
213 /// It specifies the color space for gradient interpolations, color
214 /// animations, and alpha compositing. Value:
215 /// auto|sRGB|linearRGB|inherit; Animatable: Yes
216 color_interpolation: String,
217 /// It specifies the color space for imaging operations performed via
218 /// filter effects. Value: auto|sRGB|linearRGB|inherit; Animatable: Yes
219 color_interpolation_filters: String,
220 /// It provides a hint to the browser about how to optimize its color
221 /// interpolation and compositing operations. Value:
222 /// auto|optimizeSpeed|optimizeQuality|inherit; Animatable: Yes
223 color_rendering: String,
224 /// It specifies the mouse cursor displayed when the mouse pointer is
225 /// over an element. Value: `<FuncIRI>`|`<keywords>`|inherit;
226 /// Animatable: Yes
227 cursor: String,
228 /// It defines a path to be drawn. Value: path()|none
229 d: Data,
230 /// It specifies the base writing direction of text. Value:
231 /// ltr|rtl|inherit; Animatable: Yes
232 direction: String,
233 /// It allows to control the rendering of graphical or container
234 /// elements. Value: see CSS display; Animatable: Yes
235 display: String,
236 /// It defines the baseline used to align the box's text and
237 /// inline-level contents. Value:
238 /// auto|text-bottom|alphabetic|ideographic|middle|central|
239 /// mathematical|hanging|text-top; Animatable: Yes
240 dominant_baseline: String,
241 /// It defines the color of the inside of the graphical element it
242 /// applies to. Value: `<paint>`; Animatable: Yes
243 fill: String,
244 /// It specifies the opacity of the color or the content the current
245 /// object is filled with. Value: `<number>`|`<percentage>`; Animatable:
246 /// Yes
247 fill_opacity: NumberOrPercentage,
248 /// It indicates how to determine what side of a path is inside a shape.
249 /// Value: nonzero|evenodd|inherit; Animatable: Yes
250 fill_rule: String,
251 /// It defines the filter effects defined by the `<filter>` element that
252 /// shall be applied to its element. Value: `<FuncIRI>`|none|inherit;
253 /// Animatable: Yes
254 filter: String,
255 /// It indicates what color to use to flood the current filter primitive
256 /// subregion defined through the `<feFlood>` or `<feDropShadow>`
257 /// element. Value: `<color>`; Animatable: Yes
258 flood_color: String,
259 /// It indicates the opacity value to use across the current filter
260 /// primitive subregion defined through the `<feFlood>` or
261 /// `<feDropShadow>` element. Value: `<number>`|`<percentage>`;
262 /// Animatable: Yes
263 flood_opacity: NumberOrPercentage,
264 /// It indicates which font family will be used to render the text of
265 /// the element. Value: see CSS font-family; Animatable: Yes
266 font_family: String,
267 /// It specifies the size of the font. Value: see CSS font-size;
268 /// Animatable: Yes
269 font_size: String,
270 /// It specifies that the font size should be chosen based on the height
271 /// of lowercase letters rather than the height of capital letters.
272 /// Value: `<number>`|none|inherit; Animatable: Yes
273 font_size_adjust: String,
274 /// It selects a normal, condensed, or expanded face from a font. Value:
275 /// see CSS font-stretch; Animatable: Yes
276 font_stretch: String,
277 /// It specifies whether a font should be styled with a normal, italic,
278 /// or oblique face from its font-family. Value: normal|italic|oblique;
279 /// Animatable: Yes
280 font_style: String,
281 /// It specifies whether a font should be used with some of their
282 /// variation such as small caps or ligatures. Value: see CSS
283 /// font-variant; Animatable: Yes
284 font_variant: String,
285 /// It specifies the weight (or boldness) of the font. Value:
286 /// normal|bold|lighter|bolder|100|200|300|400|500|600|700|800|900;
287 /// Animatable: Yes
288 font_weight: String,
289 /// It provides a hint to the browser about how to make speed vs.
290 /// quality tradeoffs as it performs image processing. Value:
291 /// auto|optimizeQuality|optimizeSpeed; Animatable: Yes
292 image_rendering: String,
293 /// It controls spacing between text characters. Value:
294 /// normal|`<length>`|inherit; Animatable: Yes
295 letter_spacing: String,
296 /// It defines the color of the light source for filter primitives
297 /// elements `<feDiffuseLighting>` and `<feSpecularLighting>`. Value:
298 /// `<color>`; Animatable: Yes
299 lighting_color: String,
300 /// It defines the arrowhead or polymarker that will be drawn at the
301 /// final vertex of the given `<path>` element or basic shape. Value:
302 /// `<FuncIRI>`|none|inherit; Animatable: Yes
303 marker_end: String,
304 /// It defines the arrowhead or polymarker that will be drawn at every
305 /// vertex other than the first and last vertex of the given `<path>`
306 /// element or basic shape. Value: `<FuncIRI>`|none|inherit; Animatable:
307 /// Yes
308 marker_mid: String,
309 /// It defines the arrowhead or polymarker that will be drawn at the
310 /// first vertex of the given `<path>` element or basic shape. Value:
311 /// `<FuncIRI>`|none|inherit; Animatable: Yes
312 marker_start: String,
313 /// It alters the visibility of an element by either masking or clipping
314 /// the image at specific points. Value: see CSS mask; Animatable: Yes
315 mask: String,
316 /// It specifies the transparency of an object or a group of objects.
317 /// Value: `<opacity-value>`; Animatable: Yes
318 opacity: f64,
319 /// Specifies whether the content of a block-level element is clipped
320 /// when it overflows the element's box. Value:
321 /// visible|hidden|scroll|auto|inherit; Animatable: Yes
322 overflow: String,
323 /// Defines whether or when an element may be the target of a mouse
324 /// event. Value:
325 /// bounding-box|visiblePainted|visibleFill|visibleStroke|visible
326 /// |painted|fill|stroke|all|none; Animatable: Yes
327 pointer_events: String,
328 /// Hints about what tradeoffs to make as the browser renders `<path>`
329 /// element or basic shapes. Value:
330 /// auto|optimizeSpeed|crispEdges|geometricPrecision |inherit;
331 /// Animatable: Yes
332 shape_rendering: String,
333 /// - Value:; Animatable: -
334 solid_color: String,
335 ///_Value:; Animatable: -
336 solid_opacity: String,
337 /// Indicates what color to use at that gradient stop. Value:
338 /// currentcolor|`<color>`|`<icccolor>`|inherit; Animatable: Yes
339 stop_color: String,
340 /// Defines the opacity of a given gradient stop. Value:
341 /// `<opacity-value>`|inherit; Animatable: Yes
342 stop_opacity: String,
343 /// Defines the color used to paint the outline of the shape. Value:
344 /// `<paint>`; Animatable: Yes
345 stroke: String,
346 /// Defines the pattern of dashes and gaps used to paint the outline of
347 /// the shape. Value: none|`<dasharray>`; Animatable: Yes
348 stroke_dasharray: String,
349 /// Defines an offset on the rendering of the associated dash array.
350 /// Value: `<percentage>`|`<length>`; Animatable: Yes
351 stroke_dashoffset: Length,
352 /// Defines the shape to be used at the end of open subpaths when they
353 /// are stroked. Value: butt|round|square; Animatable: Yes
354 stroke_linecap: String,
355 /// Defines the shape to be used at the corners of paths when they are
356 /// stroked. Value: arcs|bevel|miter|miter-clip|round; Animatable: Yes
357 stroke_linejoin: String,
358 /// Defines a limit on the ratio of the miter length to the stroke-width
359 /// used to draw a miter join. Value: `<number>`; Animatable: Yes
360 stroke_miterlimit: f64,
361 /// Defines the opacity of the stroke of a shape. Value:
362 /// `<opacity-value>`|`<percentage>`; Animatable: Yes
363 stroke_opacity: NumberOrPercentage,
364 /// Defines the width of the stroke to be applied to the shape. Value:
365 /// `<length>`|`<percentage>`; Animatable: Yes
366 stroke_width: Length,
367 /// Defines the vertical alignment a string of text. Value:
368 /// start|middle|end|inherit; Animatable: Yes
369 text_anchor: String,
370 /// Sets the appearance of decorative lines on text. Value:
371 /// none|underline|overline|line-through|blink|inherit; Animatable: Yes
372 text_decoration: String,
373 /// Hints about what tradeoffs to make as the browser renders text.
374 /// Value: auto|optimizeSpeed|optimizeLegibility|geometricPrecision|inherit;
375 /// Animatable: Yes
376 text_rendering: String,
377 /// Defines a list of transform definitions that are applied to an
378 /// element and the element's children. Value: `<transform-list>`;
379 /// Animatable: Yes
380 transform: String,
381 /// - Value:; Animatable: -
382 unicode_bidi: String,
383 /// Specifies the vector effect to use when drawing an object. Value:
384 /// default|non-scaling-stroke|inherit|`<uri>`; Animatable: Yes
385 vector_effect: String,
386 ];
387}
388
389/// SVG [Conditional Processing] Attributes
390///
391/// [Conditional Processing]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Conditional_Processing
392pub trait ConditionalProcessing: Element {
393 svg_attributes![
394 /// List all the browser specific capabilities that must be supported by
395 /// the browser to be allowed to render the associated element. Value: A
396 /// list of space-separated URI; Animatable: No
397 required_extensions("requiredExtensions"): String,
398 /// Indicates which language the user must have chosen to render the
399 /// associated element. Value: A list of comma-separated language tags
400 /// according to RFC 5646: Tags for Identifying Languages (also known as
401 /// BCP 47); Animatable: No
402 system_language("systemLanguage"): String,
403 ];
404}
405
406/// SVG [Filter] Primitve Attributes
407///
408/// [Filter]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute#filters_attributes
409pub trait FilterPrimitives: Element {
410 svg_attributes![
411 /// The height attribute defines the vertical length of an element in
412 /// the user coordinate system.
413 height: Length,
414 /// The result attribute defines the assigned name for this filter
415 /// primitive. If supplied, then graphics that result from processing
416 /// this filter primitive can be referenced by an in attribute on a
417 /// subsequent filter primitive within the same `<filter>` element. If
418 /// no value is provided, the output will only be available for
419 /// re-use as the implicit input into the next filter primitive
420 /// if that filter primitive provides no value for its in
421 /// attribute.
422 result: String,
423 /// The width attribute defines the horizontal length of an element in
424 /// the user coordinate system.
425 width: Length,
426 /// The x attribute defines an x-axis coordinate in the user coordinate
427 /// system.
428 x: Length,
429 /// The y attribute defines a y-axis coordinate in the user coordinate
430 /// system.
431 y: Length,
432 ];
433}
434
435/// SVG [Filter] Transfer Function Attributes
436///
437/// [Filter]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute#filters_attributes
438pub trait TransferFunction: Element {
439 svg_attributes![
440 /// The type attribute is a generic attribute and it has different
441 /// meaning based on the context in which it's used.
442 r#type: String,
443 /// The tableValues attribute defines a list of numbers defining a
444 /// lookup table of values for a color component transfer function.
445 table_values("tableValues"): String,
446 /// The intercept attribute defines the intercept of the linear function
447 /// of color component transfers when the type attribute is set to
448 /// linear.
449 intercept: f64,
450 /// The amplitude attribute controls the amplitude of the gamma function
451 /// of a component transfer element when its type attribute is gamma.
452 amplitude: f64,
453 /// The exponent attribute defines the exponent of the gamma function.
454 exponent: f64,
455 ];
456}