@cesdk/cesdk-js 1.4.0-alpha.5 → 1.4.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/BlockAPI.d.ts CHANGED
@@ -6,12 +6,29 @@ type MimeType =
6
6
  | 'image/jpeg'
7
7
  | 'image/x-tga'
8
8
  | 'application/octet-stream';
9
- type Size = number; // | 'auto';
10
9
  type Size2 = {
11
- width: Size;
12
- height: Size;
10
+ width: number;
11
+ height: number;
13
12
  };
14
13
 
14
+ export enum PositionMode {
15
+ /** Position in absolute design units. */
16
+ Absolute = 'Absolute',
17
+ /** Position in relation to the block's parent's size in percent, where 1.0 means 100%. */
18
+ Percent = 'Percent',
19
+ /** Position is not defined. */
20
+ Undefined = 'Undefined'
21
+ }
22
+
23
+ export enum SizeMode {
24
+ /** Size in absolute design units. */
25
+ Absolute = 'Absolute',
26
+ /** Size in relation to the block's parent's size in percent, where 1.0 means 100%. */
27
+ Percent = 'Percent',
28
+ /** Size is determined by the block's content. */
29
+ Auto = 'Auto'
30
+ }
31
+
15
32
  export default class BlockAPI {
16
33
  /**
17
34
  * Exports a design block element as a file of the given mime type.
@@ -124,18 +141,60 @@ export default class BlockAPI {
124
141
  setVisible(id: DesignElementId, visible: boolean): void;
125
142
 
126
143
  /**
127
- * Query a block's absolute position in design units.
144
+ * Query a block's x position.
145
+ * @param id The block to query.
146
+ * @returns The value of the x position.
147
+ */
148
+ getPositionX(id: DesignElementId): number;
149
+
150
+ /**
151
+ * Query a block's mode for its x position.
152
+ * @param id The block to query.
153
+ * @returns The current mode for the x position: absolute, percent or undefined.
154
+ */
155
+ getPositionXMode(id: DesignElementId): PositionMode;
156
+
157
+ /**
158
+ * Query a block's y position.
159
+ * @param id The block to query.
160
+ * @returns The value of the y position.
161
+ */
162
+ getPositionY(id: DesignElementId): number;
163
+
164
+ /**
165
+ * Query a block's mode for its y position.
128
166
  * @param id The block to query.
129
- * @returns
167
+ * @returns The current mode for the y position: absolute, percent or undefined.
168
+ */
169
+ getPositionYMode(id: DesignElementId): PositionMode;
170
+
171
+ /**
172
+ * Update a block's x position.
173
+ * @param id The block to update.
174
+ * @param value The value of the x position.
175
+ */
176
+ setPositionX(id: DesignElementId, value: number): void;
177
+
178
+ /**
179
+ * Set a block's mode for its x position.
180
+ * @param id The block to update.
181
+ * @param mode The x position mode: absolute, percent or undefined.
182
+ */
183
+ setPositionXMode(id: DesignElementId, mode: PositionMode): void;
184
+
185
+ /**
186
+ * Update a block's y position.
187
+ * @param id The block to update.
188
+ * @param value The value of the y position.
130
189
  */
131
- getPosition(id: DesignElementId): Vec2;
190
+ setPositionY(id: DesignElementId, value: number): void;
132
191
 
133
192
  /**
134
- * Update a block's absolute position.
193
+ * Set a block's mode for its y position.
135
194
  * @param id The block to update.
136
- * @param { x, y } pos The new position in design units.
195
+ * @param mode The y position mode: absolute, percent or undefined.
137
196
  */
138
- setPosition(id: DesignElementId, { x, y }: Vec2): void;
197
+ setPositionYMode(id: DesignElementId, mode: PositionMode): void;
139
198
 
140
199
  /**
141
200
  * Query a block's rotation in radians.
@@ -169,7 +228,6 @@ export default class BlockAPI {
169
228
  * Update a block's horizontal flip.
170
229
  * @param id The block to update.
171
230
  * @param horizontal Whether the block should be flipped along its x-axis.
172
- * @returns
173
231
  */
174
232
  setFlipHorizontal(id: DesignElementId, flip: boolean): void;
175
233
 
@@ -177,23 +235,64 @@ export default class BlockAPI {
177
235
  * Update a block's vertical flip.
178
236
  * @param id The block to update.
179
237
  * @param vertical Whether the block should be flipped along its y-axis.
180
- * @returns
181
238
  */
182
239
  setFlipVertical(id: DesignElementId, flip: boolean): void;
183
240
 
184
241
  /**
185
- * Query a block's absolute size in design units.
242
+ * Query a block's width.
243
+ * @param id The block to query.
244
+ * @returns The value of the block's width.
245
+ */
246
+ getWidth(id: DesignElementId): number;
247
+
248
+ /**
249
+ * Query a block's mode for its width.
250
+ * @param id The block to query.
251
+ * @returns The current mode for the width: absolute, percent or auto.
252
+ */
253
+ getWidthMode(id: DesignElementId): SizeMode;
254
+
255
+ /**
256
+ * Query a block's height.
257
+ * @param id The block to query.
258
+ * @returns The value of the block's height.
259
+ */
260
+ getHeight(id: DesignElementId): number;
261
+
262
+ /**
263
+ * Query a block's mode for its height.
186
264
  * @param id The block to query.
187
- * @returns A `Size2` object.
265
+ * @returns The current mode for the height: absolute, percent or auto.
266
+ */
267
+ getHeightMode(id: DesignElementId): SizeMode;
268
+
269
+ /**
270
+ * Update a block's width.
271
+ * @param id The block to update.
272
+ * @param value The new width of the block.
273
+ */
274
+ setWidth(id: DesignElementId, value: number): void;
275
+
276
+ /**
277
+ * Set a block's mode for its width.
278
+ * @param id The block to update.
279
+ * @param mode The width mode: absolute, percent or auto.
280
+ */
281
+ setWidthMode(id: DesignElementId, mode: SizeMode): void;
282
+
283
+ /**
284
+ * Update a block's height.
285
+ * @param id The block to update.
286
+ * @param value The new height of the block.
188
287
  */
189
- getSize(id: DesignElementId): Size2;
288
+ setHeight(id: DesignElementId, value: number): void;
190
289
 
191
290
  /**
192
- * Update a block's absolute size in design units.
291
+ * Set a block's mode for its height.
193
292
  * @param id The block to update.
194
- * @param size A size object defining width and height.
293
+ * @param mode The height mode: absolute, percent or auto.
195
294
  */
196
- setSize(id: DesignElementId, size: Size2): void;
295
+ setHeightMode(id: DesignElementId, mode: SizeMode): void;
197
296
 
198
297
  /**
199
298
  * Get a block's layouted size. Requires an `engine.render()` beforehand.
package/PropertyAPI.d.ts CHANGED
@@ -1,16 +1,5 @@
1
1
  type DesignBlockId = number;
2
2
  type RGBA = [r: number, g: number, b: number, a: number];
3
- type Size2 = {
4
- width: number;
5
- height: number;
6
- };
7
- type Crop = {
8
- scaleX: number;
9
- scaleY: number;
10
- rotation: number;
11
- translationX: number;
12
- translationY: number;
13
- };
14
3
 
15
4
  export enum PropertyType {
16
5
  Bool = 'Bool',
@@ -18,7 +7,6 @@ export enum PropertyType {
18
7
  Float = 'Float',
19
8
  String = 'String',
20
9
  Color = 'Color',
21
- Size = 'Size',
22
10
  Enum = 'Enum',
23
11
  Struct = 'Struct'
24
12
  }
@@ -113,42 +101,28 @@ export default class PropertyAPI {
113
101
  * Set a color property of the given design block to the given value.
114
102
  * @param id The block whose property should be set.
115
103
  * @param property The name of the property to set.
116
- * @param color A tuple of channels red, green, blue and alpha in the range 0 to 1.
104
+ * @param r The red color component in the range of 0 to 1.
105
+ * @param g The green color component in the range of 0 to 1.
106
+ * @param b The blue color component in the range of 0 to 1.
107
+ * @param a The alpha color component in the range of 0 to 1.
117
108
  */
118
- setColorRGBA(id: DesignBlockId, property: string, color: RGBA): void;
109
+ setColorRGBA(
110
+ id: DesignBlockId,
111
+ property: string,
112
+ r: number,
113
+ g: number,
114
+ b: number,
115
+ a: number
116
+ ): void;
119
117
 
120
118
  /**
121
119
  * Get the value of a string property of the given design block.
122
120
  * @param id The block whose property should be queried.
123
121
  * @param property The name of the property to query.
124
- * @returns The value of the property.
122
+ * @returns A tuple of channels red, green, blue and alpha in the range of 0 to 1.
125
123
  */
126
124
  getColorRGBA(id: DesignBlockId, property: string): RGBA;
127
125
 
128
- /**
129
- * Set a size property's width of the given design block to the given value.
130
- * @param id The block whose property should be set.
131
- * @param property The name of the property to set.
132
- * @param value The width to set to.
133
- */
134
- setSize2Width(id: DesignBlockId, property: string, value: number);
135
-
136
- /**
137
- * Set a size property's height of the given design block to the given value.
138
- * @param id The block whose property should be set.
139
- * @param property The name of the property to set.
140
- * @param value The height to set to.
141
- */
142
- setSize2Height(id: DesignBlockId, property: string, value: number): void;
143
-
144
- /**
145
- * Get the value of a size property of the given design block.
146
- * @param id The block whose property should be queried.
147
- * @param property The name of the property to query.
148
- * @returns The value of the property.
149
- */
150
- getSize2(id: DesignBlockId, property: string): Size2;
151
-
152
126
  /**
153
127
  * Set an enum property of the given design block to the given value.
154
128
  * @param block The block whose property should be set.
@@ -208,11 +182,39 @@ export default class PropertyAPI {
208
182
  setCropTranslationY(id: DesignBlockId, translationY: number): void;
209
183
 
210
184
  /**
211
- * Get the crop of the given design block.
212
- * @param id The block whose crop should be queried.
213
- * @returns An object with crop properties of scale, rotation and translation.
185
+ * Get the crop scale on the x axis of the given design block.
186
+ * @param id The block whose scale should be queried.
187
+ * @returns The scale on the x axis.
188
+ */
189
+ getCropScaleX(id: DesignBlockId): number;
190
+
191
+ /**
192
+ * Get the crop scale on the y axis of the given design block.
193
+ * @param id The block whose scale should be queried.
194
+ * @returns The scale on the y axis.
195
+ */
196
+ getCropScaleY(id: DesignBlockId): number;
197
+
198
+ /**
199
+ * Get the crop rotation of the given design block.
200
+ * @param id The block whose crop rotation should be queried.
201
+ * @returns The crop rotation.
214
202
  */
215
- getCrop(id: DesignBlockId): Crop;
203
+ getCropRotation(id: DesignBlockId): number;
204
+
205
+ /**
206
+ * Get the crop translation on the x axis of the given design block.
207
+ * @param id The block whose translation should be queried.
208
+ * @returns The translation on the x axis.
209
+ */
210
+ getCropTranslationX(id: DesignBlockId): number;
211
+
212
+ /**
213
+ * Get the crop translation on the y axis of the given design block.
214
+ * @param id The block whose translation should be queried.
215
+ * @returns The translation on the y axis.
216
+ */
217
+ getCropTranslationY(id: DesignBlockId): number;
216
218
 
217
219
  /**
218
220
  * Query if the given block has an opacity.
@@ -231,7 +233,7 @@ export default class PropertyAPI {
231
233
  /**
232
234
  * Get the opacity of the given design block.
233
235
  * @param id The block whose opacity should be queried.
234
- * @param opacity The opacity.
236
+ * @returns The opacity in a range of 0 to 1.
235
237
  */
236
238
  getOpacity(id: DesignBlockId): number;
237
239
 
@@ -246,9 +248,18 @@ export default class PropertyAPI {
246
248
  * Set the fill color of the given design block.
247
249
  * @param id The block whose fill color should be set.
248
250
  * @param color The fill color to be set, a tuple of
249
- * red, green, blue and alpha in the range of 0 to 1.
251
+ * @param r The red color component in the range of 0 to 1.
252
+ * @param g The green color component in the range of 0 to 1.
253
+ * @param b The blue color component in the range of 0 to 1.
254
+ * @param a The alpha color component in the range of 0 to 1.
250
255
  */
251
- setFillColorRGBA(id: DesignBlockId, color: RGBA): void;
256
+ setFillColorRGBA(
257
+ id: DesignBlockId,
258
+ r: number,
259
+ g: number,
260
+ b: number,
261
+ a: number
262
+ ): void;
252
263
 
253
264
  /**
254
265
  * Get the fill color of the given design block.
@@ -282,9 +293,18 @@ export default class PropertyAPI {
282
293
  * Set the background color of the given design block.
283
294
  * @param id The block whose background color should be set.
284
295
  * @param color The background color to be set, a tuple of
285
- * red, green, blue and alpha in the range of 0 to 1.
296
+ * @param r The red color component in the range of 0 to 1.
297
+ * @param g The green color component in the range of 0 to 1.
298
+ * @param b The blue color component in the range of 0 to 1.
299
+ * @param a The alpha color component in the range of 0 to 1.
286
300
  */
287
- setBackgroundColorRGBA(id: DesignBlockId, color: RGBA): void;
301
+ setBackgroundColorRGBA(
302
+ id: DesignBlockId,
303
+ r: number,
304
+ g: number,
305
+ b: number,
306
+ a: number
307
+ ): void;
288
308
 
289
309
  /**
290
310
  * Get the background color of the given design block.
@@ -318,9 +338,18 @@ export default class PropertyAPI {
318
338
  * Set the outline color of the given design block.
319
339
  * @param id The block whose outline color should be set.
320
340
  * @param color The outline color to be set, a tuple of
321
- * red, green, blue and alpha in the range of 0 to 1.
322
- */
323
- setOutlineColorRGBA(id: DesignBlockId, color: RGBA): void;
341
+ * @param r The red color component in the range of 0 to 1.
342
+ * @param g The green color component in the range of 0 to 1.
343
+ * @param b The blue color component in the range of 0 to 1.
344
+ * @param a The alpha color component in the range of 0 to 1.
345
+ */
346
+ setOutlineColorRGBA(
347
+ id: DesignBlockId,
348
+ r: number,
349
+ g: number,
350
+ b: number,
351
+ a: number
352
+ ): void;
324
353
 
325
354
  /**
326
355
  * Get the outline color of the given design block.
Binary file
Binary file