You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// The collection of data, such as a list or table.
18
+
#[implementations(
19
+
Vec<f64>,
20
+
Vec<u32>,
21
+
Vec<u64>,
22
+
Vec<DVec2>,
23
+
Vec<String>,
24
+
Table<Artboard>,
25
+
Table<Graphic>,
26
+
Table<Vector>,
27
+
Table<Raster<CPU>>,
28
+
Table<Raster<GPU>>,
29
+
Table<Color>,
30
+
Table<GradientStops>,
31
+
)]
32
+
collection:T,
33
+
/// The index of the item to retrieve, starting from 0 for the first item. Negative indices count backwards from the end of the collection, starting from -1 for the last item.
/// The collection of data, such as a list or table.
276
-
#[implementations(
277
-
Vec<f64>,
278
-
Vec<u32>,
279
-
Vec<u64>,
280
-
Vec<DVec2>,
281
-
Vec<String>,
282
-
Table<Artboard>,
283
-
Table<Graphic>,
284
-
Table<Vector>,
285
-
Table<Raster<CPU>>,
286
-
Table<Raster<GPU>>,
287
-
Table<Color>,
288
-
Table<GradientStops>,
289
-
)]
290
-
collection:T,
291
-
/// The index of the item to retrieve, starting from 0 for the first item. Negative indices count backwards from the end of the collection, starting from -1 for the last item.
292
-
index:SignedInteger,
293
-
) -> T::Output
294
-
where
295
-
T::Output:Clone + Default,
296
-
{
297
-
let index = index asi32;
309
+
pubasyncfnflatten_color<T:IntoGraphicTable + 'n + Send + Clone>(_:implCtx,#[implementations(Table<Graphic>,Table<Color>)]content:T) -> Table<Color>{
310
+
content.into_flattened_color_table()
311
+
}
298
312
299
-
if index < 0{
300
-
collection.at_index_from_end(-index asusize)
301
-
}else{
302
-
collection.at_index(index asusize)
313
+
/// Converts a graphic table into a gradient table by deeply flattening any gradient content it contains, and discarding any non-gradient content.
314
+
#[node_macro::node(category("General"))]
315
+
pubasyncfnflatten_gradient<T:IntoGraphicTable + 'n + Send + Clone>(_:implCtx,#[implementations(Table<Graphic>,Table<GradientStops>)]content:T) -> Table<GradientStops>{
316
+
content.into_flattened_gradient_table()
317
+
}
318
+
319
+
/// Constructs a gradient from a table of colors, where the colors are evenly distributed as gradient stops across the range from 0 to 1.
320
+
#[node_macro::node(category("Color"))]
321
+
fncolors_to_gradient<T:IntoGraphicTable + 'n + Send + Clone>(_:implCtx,#[implementations(Table<Graphic>,Table<Color>)]colors:T) -> GradientStops{
322
+
let colors = colors.into_flattened_color_table();
323
+
let total_colors = colors.len();
324
+
325
+
if total_colors == 0{
326
+
returnGradientStops::new(vec![GradientStop{
327
+
position:0.,
328
+
midpoint:0.5,
329
+
color:Color::BLACK,
330
+
}]);
303
331
}
304
-
.unwrap_or_default()
332
+
333
+
let colors = colors.into_iter().enumerate().map(|(index, row)| GradientStop{
334
+
position: index asf64 / (total_colors - 1).max(1)asf64,
0 commit comments