xpict 0.3.3 → 0.3.5

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.
@@ -37,7 +37,9 @@ class ImageLayer extends layer_1.Layer {
37
37
  img = img.flip();
38
38
  }
39
39
  if (this.options.rotate !== undefined) {
40
- img = img.rotate(this.options.rotate);
40
+ img = img.rotate(this.options.rotate, {
41
+ background: { r: 0, g: 0, b: 0, alpha: 0 },
42
+ });
41
43
  }
42
44
  if (this.options.transform && this.options.transform.length > 0) {
43
45
  for (const transform of this.options.transform) {
@@ -5,9 +5,14 @@ export type EachOptions<Data> = {
5
5
  index: number;
6
6
  };
7
7
  export type EachFunction<Data, Item> = (options: EachOptions<Data>) => Item[];
8
+ export type LayerFunctionOptions = {
9
+ index: number;
10
+ length: number;
11
+ };
12
+ export type LayerFunction<Data, Item> = (item: Item, options: LayerFunctionOptions) => Layer<Data>;
8
13
  export type RepeatLayerOptions<Data, Item> = {
9
14
  each: EachFunction<Data, Item>;
10
- layer: (item: Item, index: number) => Layer<Data>;
15
+ layer: LayerFunction<Data, Item>;
11
16
  when?: WhenFunction<Data>;
12
17
  x: Axis<Data>;
13
18
  y: Axis<Data>;
@@ -31,7 +31,7 @@ class RepeatLayer extends layer_1.Layer {
31
31
  const prevY = ctx.offsetY;
32
32
  ctx.offsetX += dx;
33
33
  ctx.offsetY += dy;
34
- const layer = this.options.layer(item, index);
34
+ const layer = this.options.layer(item, { index: index, length: items.length });
35
35
  await layer.render({
36
36
  context: ctx,
37
37
  data: data,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xpict",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Xpict é uma biblioteca para a geração de imagens padronizadas a partir de modelos declarativos.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",