-
Notifications
You must be signed in to change notification settings - Fork 3
/
definitions.kt
553 lines (520 loc) · 17.4 KB
/
definitions.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
/// [Figma documentation](https://www.figma.com/developers/api#color-type)
@Serializable
data class Color (
val r: Double,
val g: Double,
val b: Double,
val a: Double
)
/// [Figma documentation](https://www.figma.com/developers/api#component-type)
@Serializable
data class Component (
val key: String,
val name: String,
val description: String
)
@Serializable
enum class EffectType(val string: String) {
@SerialName("INNER_SHADOW")
InnerShadow("INNER_SHADOW"),
@SerialName("DROP_SHADOW")
DropShadow("DROP_SHADOW"),
@SerialName("LAYER_BLUR")
LayerBlur("LAYER_BLUR"),
@SerialName("BACKGROUND_BLUR")
BackgroundBlur("BACKGROUND_BLUR"),
}
/// [Figma documentation](https://www.figma.com/developers/api#vector-type)
@Serializable
data class Vector (
val x: Double,
val y: Double
)
/// A visual effect such as a shadow or blur
///
/// [Figma documentation](https://www.figma.com/developers/api#effect-type)
@Serializable
data class Effect (
/// Type of effect
val type: EffectType,
/// Is the effect active?
val visible: Boolean,
/// The color of the shadow
val color: Color? = null,
/// How far the shadow is projected in the x and y directions
val offset: Vector? = null,
/// How far the shadow spreads
val spread: Double? = null
)
/// Node type indicates what kind of node you are working with: for example, a FRAME node versus a RECTANGLE node. A node can have additional properties associated with it depending on its node type.
@Serializable
enum class NodeType(val string: String) {
@SerialName("DOCUMENT")
Document("DOCUMENT"),
@SerialName("CANVAS")
Canvas("CANVAS"),
@SerialName("FRAME")
Frame("FRAME"),
@SerialName("GROUP")
Group("GROUP"),
@SerialName("VECTOR")
Vector("VECTOR"),
@SerialName("BOOLEAN_OPERATION")
BooleanOperation("BOOLEAN_OPERATION"),
@SerialName("STAR")
Star("STAR"),
@SerialName("LINE")
Line("LINE"),
@SerialName("ELLIPSE")
Ellipse("ELLIPSE"),
@SerialName("REGULAR_POLYGON")
RegularPolygon("REGULAR_POLYGON"),
@SerialName("RECTANGLE")
Rectangle("RECTANGLE"),
@SerialName("TEXT")
Text("TEXT"),
@SerialName("SLICE")
Slice("SLICE"),
@SerialName("COMPONENT")
Component("COMPONENT"),
@SerialName("COMPONENT_SET")
ComponentSet("COMPONENT_SET"),
@SerialName("INSTANCE")
Instance("INSTANCE"),
@SerialName("STICKY")
Sticky("STICKY"),
@SerialName("SHAPE_WITH_TEXT")
ShapeWithText("SHAPE_WITH_TEXT"),
@SerialName("CONNECTOR")
Connector("CONNECTOR"),
@SerialName("SECTION")
Section("SECTION"),
}
@Serializable
enum class PaintType(val string: String) {
@SerialName("SOLID")
Solid("SOLID"),
@SerialName("GRADIENT_LINEAR")
GradientLinear("GRADIENT_LINEAR"),
@SerialName("GRADIENT_RADIAL")
GradientRadial("GRADIENT_RADIAL"),
@SerialName("GRADIENT_ANGULAR")
GradientAngular("GRADIENT_ANGULAR"),
@SerialName("GRADIENT_DIAMOND")
GradientDiamond("GRADIENT_DIAMOND"),
@SerialName("IMAGE")
Image("IMAGE"),
}
/// how layer blends with layers below
///
/// [Figma documentation](https://www.figma.com/developers/api#blendmode-type)
@Serializable
enum class BlendMode(val string: String) {
@SerialName("PASS_THROUGH")
PassThrough("PASS_THROUGH"),
@SerialName("NORMAL")
Normal("NORMAL"),
@SerialName("DARKEN")
Darken("DARKEN"),
@SerialName("MULTIPLY")
Multiply("MULTIPLY"),
@SerialName("LINEAR_BURN")
LinearBurn("LINEAR_BURN"),
@SerialName("COLOR_BURN")
ColorBurn("COLOR_BURN"),
@SerialName("LIGHTEN")
Lighten("LIGHTEN"),
@SerialName("SCREEN")
Screen("SCREEN"),
@SerialName("LINEAR_DODGE")
LinearDodge("LINEAR_DODGE"),
@SerialName("COLOR_DODGE")
ColorDodge("COLOR_DODGE"),
@SerialName("OVERLAY")
Overlay("OVERLAY"),
@SerialName("SOFT_LIGHT")
SoftLight("SOFT_LIGHT"),
@SerialName("HARD_LIGHT")
HardLight("HARD_LIGHT"),
@SerialName("DIFFERENCE")
Difference("DIFFERENCE"),
@SerialName("EXCLUSION")
Exclusion("EXCLUSION"),
@SerialName("HUE")
Hue("HUE"),
@SerialName("SATURATION")
Saturation("SATURATION"),
@SerialName("COLOR")
Color("COLOR"),
@SerialName("LUMINOSITY")
Luminosity("LUMINOSITY"),
}
/// A solid color, gradient, or image texture that can be applied as fills or strokes
///
/// [Figma documentation](https://www.figma.com/developers/api#paint-type)
@Serializable
data class Paint (
val type: PaintType,
/// Is the paint enabled?
val visible: Boolean? = null,
/// Overall opacity of paint (colors within the paint can also have opacity values which would blend with this)
val opacity: Double? = null,
/// Solid color of the paint
val color: Color? = null,
/// How this node blends with nodes behind it in the scene
val blend_mode: BlendMode? = null,
/// This field contains three vectors, each of which are a position in normalized object space (normalized object space is if the top left corner of the bounding box of the object is (0, 0) and the bottom right is (1,1)). The first position corresponds to the start of the gradient (value 0 for the purposes of calculating gradient stops), the second position is the end of the gradient (value 1), and the third handle position determines the width of the gradient. See image examples below:
val gradient_handle_positions: List<Vector>? = null
)
/// Individual stroke weights
@Serializable
data class StrokeWeights (
/// The top stroke weight
val top: Double,
/// The right stroke weight
val right: Double,
/// The bottom stroke weight
val bottom: Double,
/// The left stroke weight
val left: Double
)
@Serializable
enum class StrokeAlign(val string: String) {
/// stroke drawn inside the shape boundary
@SerialName("INSIDE")
Inside("INSIDE"),
/// stroke drawn outside the shape boundary
@SerialName("OUTSIDE")
Outside("OUTSIDE"),
/// stroke drawn centered along the shape boundary
@SerialName("CENTER")
Center("CENTER"),
}
/// Animation easing curves
///
/// [Figma documentation](https://www.figma.com/developers/api#easingtype-type)
@Serializable
enum class EasingType(val string: String) {
/// Ease in with an animation curve similar to CSS ease-in
@SerialName("EASE_IN")
EaseIn("EASE_IN"),
/// Ease out with an animation curve similar to CSS ease-out
@SerialName("EASE_OUT")
EaseOut("EASE_OUT"),
/// Ease in and then out with an animation curve similar to CSS ease-in-out
@SerialName("EASE_IN_AND_OUT")
EaseInAndOut("EASE_IN_AND_OUT"),
/// No easing, similar to CSS linear
@SerialName("LINEAR")
Linear("LINEAR"),
@SerialName("EASE_IN_BACK")
EaseInBack("EASE_IN_BACK"),
@SerialName("EASE_OUT_BACK")
EaseOutBack("EASE_OUT_BACK"),
@SerialName("EASE_IN_AND_OUT_BACK")
EaseInAndOutBack("EASE_IN_AND_OUT_BACK"),
@SerialName("CUSTOM_BEZIER")
CustomBezier("CUSTOM_BEZIER"),
@SerialName("GENTLE")
Gentle("GENTLE"),
@SerialName("QUICK")
Quick("QUICK"),
@SerialName("BOUNCY")
Bouncy("BOUNCY"),
@SerialName("SLOW")
Slow("SLOW"),
@SerialName("CUSTOM_SPRING")
CustomSpring("CUSTOM_SPRING"),
}
/// [Figma documentation](https://www.figma.com/developers/api#rectangle-type)
@Serializable
data class Rectangle (
val x: Double? = null,
val y: Double? = null,
val width: Double? = null,
val height: Double? = null
)
@Serializable
enum class AxisSizingMode(val string: String) {
@SerialName("FIXED")
Fixed("FIXED"),
@SerialName("AUTO")
Auto("AUTO"),
}
@Serializable
enum class PrimaryAxisAlignItems(val string: String) {
@SerialName("MIN")
Min("MIN"),
@SerialName("CENTER")
Center("CENTER"),
@SerialName("MAX")
Max("MAX"),
@SerialName("SPACE_BETWEEN")
SpaceBetween("SPACE_BETWEEN"),
}
@Serializable
enum class CounterAxisAlignItems(val string: String) {
@SerialName("MIN")
Min("MIN"),
@SerialName("CENTER")
Center("CENTER"),
@SerialName("MAX")
Max("MAX"),
@SerialName("BASELINE")
Baseline("BASELINE"),
}
@Serializable
enum class LayoutPositioning(val string: String) {
@SerialName("ABSOLUTE")
Absolute("ABSOLUTE"),
}
@Serializable
enum class LayoutMode(val string: String) {
@SerialName("NONE")
None("NONE"),
@SerialName("HORIZONTAL")
Horizontal("HORIZONTAL"),
@SerialName("VERTICAL")
Vertical("VERTICAL"),
}
@Serializable
data class Styles (
val fill: String? = null,
val text: String? = null,
val stroke: String? = null,
val effect: String? = null
)
@Serializable
enum class TextCase(val string: String) {
@SerialName("UPPER")
Upper("UPPER"),
@SerialName("LOWER")
Lower("LOWER"),
@SerialName("TITLE")
Title("TITLE"),
@SerialName("SMALL_CAPS")
SmallCaps("SMALL_CAPS"),
@SerialName("SMALL_CAPS_FORCED")
SmallCapsForced("SMALL_CAPS_FORCED"),
}
@Serializable
enum class TextDecoration(val string: String) {
@SerialName("STRIKETHROUGH")
Strikethrough("STRIKETHROUGH"),
@SerialName("UNDERLINE")
Underline("UNDERLINE"),
}
@Serializable
enum class TextAutoResize(val string: String) {
@SerialName("HEIGHT")
Height("HEIGHT"),
@SerialName("WIDTH_AND_HEIGHT")
WidthAndHeight("WIDTH_AND_HEIGHT"),
/// The text will be shortened and trailing text will be replaced with "…" if the text contents is larger than the bounds
@SerialName("TRUNCATE")
Truncate("TRUNCATE"),
}
/// Type of hyperlink
@Serializable
enum class HyperlinkType(val string: String) {
@SerialName("URL")
Url("URL"),
@SerialName("NODE")
Node("NODE"),
}
@Serializable
data class Hyperlink (
val type: HyperlinkType? = null,
/// URL being linked to, if URL type
val url: String? = null,
/// ID of frame hyperlink points to, if NODE type
val nodeId: String? = null
)
/// Metadata for character formatting
///
/// [Figma documentation](https://www.figma.com/developers/api#typestyle-type)
@Serializable
data class TypeStyle (
/// Font family of text (standard name)
val fontFamily: String,
/// Space between paragraphs in px, 0 if not present
val paragraphSpacing: Double? = null,
/// Whether or not text is italicized
val italic: Boolean? = null,
/// Numeric font weight
val fontWeight: Double,
/// Font size in px
val fontSize: Double,
/// Text casing applied to the node, default is the original casing
val textCase: TextCase? = null,
/// Text decoration applied to the node, default is none
val textDecoration: TextDecoration? = null,
/// Dimensions along which text will auto resize, default is that the text does not auto-resize
val textAutoResize: TextAutoResize? = null,
/// Link to a URL or frame
val hyperlink: Hyperlink? = null,
/// Line height in px
val lineHeightPx: Double
)
@Serializable
enum class LayoutConstraintVertical(val string: String) {
/// Node is laid out relative to top of the containing frame
@SerialName("TOP")
Top("TOP"),
/// Node is laid out relative to bottom of the containing frame
@SerialName("BOTTOM")
Bottom("BOTTOM"),
/// Node is vertically centered relative to containing frame
@SerialName("CENTER")
Center("CENTER"),
/// Both top and bottom of node are constrained relative to containing frame (node stretches with frame)
@SerialName("TOP_BOTTOM")
TopBottom("TOP_BOTTOM"),
/// Node scales vertically with containing frame
@SerialName("SCALE")
Scale("SCALE"),
}
@Serializable
enum class LayoutConstraintHorizontal(val string: String) {
/// Node is laid out relative to left of the containing frame
@SerialName("LEFT")
Left("LEFT"),
/// Node is laid out relative to right of the containing frame
@SerialName("RIGHT")
Right("RIGHT"),
/// Node is horizontally centered relative to containing frame
@SerialName("CENTER")
Center("CENTER"),
/// Both left and right of node are constrained relative to containing frame (node stretches with frame)
@SerialName("LEFT_RIGHT")
LeftRight("LEFT_RIGHT"),
/// Node scales horizontally with containing frame
@SerialName("SCALE")
Scale("SCALE"),
}
/// Layout constraint relative to containing Frame
@Serializable
data class LayoutConstraint (
val vertical: LayoutConstraintVertical,
val horizontal: LayoutConstraintHorizontal
)
@Serializable
enum class LayoutAlign(val string: String) {
@SerialName("INHERIT")
Inherit("INHERIT"),
@SerialName("STRETCH")
Stretch("STRETCH"),
@SerialName("MIN")
Min("MIN"),
@SerialName("CENTER")
Center("CENTER"),
@SerialName("MAX")
Max("MAX"),
}
/// [Figma documentation](https://www.figma.com/developers/api#node-types)
@Serializable
data class Node (
/// A string uniquely identifying this node within the document.
val id: String,
/// The name given to the node by the user in the tool.
val name: String,
/// Whether or not the node is visible on the canvas.
val visible: Boolean? = null,
/// The type of the node
val type: NodeType,
/// An array of nodes that are direct children of this node
val children: List<Node>? = null,
/// Background color of the canvas
val backgroundColor: Color? = null,
/// An array of fill paints applied to the node
val fills: List<Paint>? = null,
/// An array of stroke paints applied to the node
val strokes: List<Paint>? = null,
/// The weight of strokes on the node
val strokeWeight: Double? = null,
/// An object including the top, bottom, left, and right stroke weights. Only returned if individual stroke weights are used.
val individualStrokeWeights: StrokeWeights? = null,
/// Position of stroke relative to vector outline
val strokeAlign: StrokeAlign? = null,
/// An array of floating point numbers describing the pattern of dash length and gap lengths that the vector path follows. For example a value of [1, 2] indicates that the path has a dash of length 1 followed by a gap of length 2, repeated.
val strokeDashes: List<Double>? = null,
/// Radius of each corner of the node if a single radius is set for all corners
val cornerRadius: Double? = null,
/// Array of length 4 of the radius of each corner of the node, starting in the top left and proceeding clockwise
val rectangleCornerRadii: List<Double>? = null,
/// The duration of the prototyping transition on this node (in milliseconds)
val transitionDuration: Double? = null,
/// The easing curve used in the prototyping transition on this node
val transitionEasing: EasingType? = null,
/// Opacity of the node
val opacity: Double? = null,
/// Bounding box of the node in absolute space coordinates
val absoluteBoundingBox: Rectangle? = null,
/// The bounds of the rendered node in the file in absolute space coordinates
val absoluteRenderBounds: Rectangle? = null,
/// Whether the primary axis has a fixed length (determined by the user) or an automatic length (determined by the layout engine). This property is only applicable for auto-layout frames.
val primaryAxisSizingMode: AxisSizingMode? = null,
/// Whether the counter axis has a fixed length (determined by the user) or an automatic length (determined by the layout engine). This property is only applicable for auto-layout frames.
val counterAxisSizingMode: AxisSizingMode? = null,
/// Determines how the auto-layout frame’s children should be aligned in the primary axis direction. This property is only applicable for auto-layout frames.
val primaryAxisAlignItems: PrimaryAxisAlignItems? = null,
/// Determines how the auto-layout frame’s children should be aligned in the counter axis direction. This property is only applicable for auto-layout frames.
val counterAxisAlignItems: CounterAxisAlignItems? = null,
/// The distance between children of the frame. Can be negative. This property is only applicable for auto-layout frames.
val itemSpacing: Double? = null,
/// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
val layoutPositioning: LayoutPositioning? = null,
/// Whether this layer uses auto-layout to position its children.
val layoutMode: LayoutMode? = null,
/// The padding between the left border of the frame and its children. This property is only applicable for auto-layout frames.
val paddingLeft: Double? = null,
/// The padding between the right border of the frame and its children. This property is only applicable for auto-layout frames.
val paddingRight: Double? = null,
/// The padding between the top border of the frame and its children. This property is only applicable for auto-layout frames.
val paddingTop: Double? = null,
/// The padding between the bottom border of the frame and its children. This property is only applicable for auto-layout frames.
val paddingBottom: Double? = null,
/// An array of effects attached to this node
val effects: List<Effect>? = null,
/// A mapping of a StyleType to style ID of styles present on this node. The style ID can be used to look up more information about the style in the top-level styles field.
val styles: Styles? = null,
/// Text contained within a text box
val characters: String? = null,
/// Style of text including font family and weight
val style: TypeStyle? = null,
/// Horizontal and vertical layout contraints for node
val constraints: LayoutConstraint? = null,
/// Determines if the layer should stretch along the parent’s counter axis. This property is only provided for direct children of auto-layout frames.
val layoutAlign: LayoutAlign? = null,
/// This property is applicable only for direct children of auto-layout frames, ignored otherwise. Determines whether a layer should stretch along the parent’s primary axis. A 0 corresponds to a fixed size and 1 corresponds to stretch
val layoutGrow: Double? = null
)
@Serializable
enum class StyleType(val string: String) {
@SerialName("FILL")
Fill("FILL"),
@SerialName("TEXT")
Text("TEXT"),
@SerialName("EFFECT")
Effect("EFFECT"),
@SerialName("GRID")
Grid("GRID"),
}
/// [Figma documentation](https://www.figma.com/developers/api#style-type)
@Serializable
data class Style (
val key: String,
val name: String,
val description: String,
val remote: Boolean,
val styleType: StyleType
)
@Serializable
data class File (
val document: Node,
val components: HashMap<String, Component>,
val styles: HashMap<String, Style>,
val name: String,
val schemaVersion: UByte,
val version: String
)