xpict 1.0.0 → 1.0.1

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.
@@ -14,14 +14,14 @@ class CircleLayer extends layer_1.Layer {
14
14
  axis: this.options.x,
15
15
  data: data,
16
16
  index: index,
17
- templateConfig: templateConfig,
17
+ templateSize: templateConfig,
18
18
  });
19
19
  const y = renderContext.offsetY +
20
20
  (0, resolve_axis_1.resolveAxis)({
21
21
  axis: this.options.y,
22
22
  data: data,
23
23
  index: index,
24
- templateConfig: templateConfig,
24
+ templateSize: templateConfig,
25
25
  });
26
26
  const { radius, fill } = this.options;
27
27
  const context = renderContext.ctx;
@@ -14,13 +14,13 @@ class GroupLayer extends layer_1.Layer {
14
14
  axis: (_a = this.options.x) !== null && _a !== void 0 ? _a : 0,
15
15
  data: data,
16
16
  index: index,
17
- templateConfig: templateConfig,
17
+ templateSize: templateConfig,
18
18
  });
19
19
  const dy = (0, resolve_axis_1.resolveAxis)({
20
20
  axis: (_b = this.options.y) !== null && _b !== void 0 ? _b : 0,
21
21
  data: data,
22
22
  index: index,
23
- templateConfig: templateConfig,
23
+ templateSize: templateConfig,
24
24
  });
25
25
  const prevX = ctx.offsetX;
26
26
  const prevY = ctx.offsetY;
@@ -15,13 +15,13 @@ class ImageLayer extends layer_1.Layer {
15
15
  axis: this.options.x,
16
16
  data: data,
17
17
  index: index,
18
- templateConfig: templateConfig,
18
+ templateSize: templateConfig,
19
19
  });
20
20
  const localY = (0, resolve_axis_1.resolveAxis)({
21
21
  axis: this.options.y,
22
22
  data: data,
23
23
  index: index,
24
- templateConfig: templateConfig,
24
+ templateSize: templateConfig,
25
25
  });
26
26
  const x = renderContext.offsetX + localX;
27
27
  const y = renderContext.offsetY + localY;
@@ -14,28 +14,28 @@ class LineLayer extends layer_1.Layer {
14
14
  axis: this.options.from.x,
15
15
  data: data,
16
16
  index: index,
17
- templateConfig: templateConfig,
17
+ templateSize: templateConfig,
18
18
  });
19
19
  const y1 = renderContext.offsetY +
20
20
  (0, resolve_axis_1.resolveAxis)({
21
21
  axis: this.options.from.y,
22
22
  data: data,
23
23
  index: index,
24
- templateConfig: templateConfig,
24
+ templateSize: templateConfig,
25
25
  });
26
26
  const x2 = renderContext.offsetX +
27
27
  (0, resolve_axis_1.resolveAxis)({
28
28
  axis: this.options.to.x,
29
29
  data: data,
30
30
  index: index,
31
- templateConfig: templateConfig,
31
+ templateSize: templateConfig,
32
32
  });
33
33
  const y2 = renderContext.offsetY +
34
34
  (0, resolve_axis_1.resolveAxis)({
35
35
  axis: this.options.to.y,
36
36
  data: data,
37
37
  index: index,
38
- templateConfig: templateConfig,
38
+ templateSize: templateConfig,
39
39
  });
40
40
  const context = renderContext.ctx;
41
41
  context.strokeStyle = this.options.color;
@@ -13,13 +13,13 @@ class RectangleLayer extends layer_1.Layer {
13
13
  axis: this.options.x,
14
14
  data: data,
15
15
  index: index,
16
- templateConfig: templateConfig,
16
+ templateSize: templateConfig,
17
17
  });
18
18
  const localY = (0, resolve_axis_1.resolveAxis)({
19
19
  axis: this.options.y,
20
20
  data: data,
21
21
  index: index,
22
- templateConfig: templateConfig,
22
+ templateSize: templateConfig,
23
23
  });
24
24
  const x = renderContext.offsetX + localX;
25
25
  const y = renderContext.offsetY + localY;
@@ -18,13 +18,13 @@ class RepeatLayer extends layer_1.Layer {
18
18
  axis: this.options.x,
19
19
  data: data,
20
20
  index: index,
21
- templateConfig: templateConfig,
21
+ templateSize: templateConfig,
22
22
  });
23
23
  const dy = (0, resolve_axis_1.resolveAxis)({
24
24
  axis: this.options.y,
25
25
  data: data,
26
26
  index: index,
27
- templateConfig: templateConfig,
27
+ templateSize: templateConfig,
28
28
  });
29
29
  const prevX = ctx.offsetX;
30
30
  const prevY = ctx.offsetY;
@@ -25,13 +25,13 @@ class TextLayer extends layer_1.Layer {
25
25
  axis: initialX,
26
26
  data: data,
27
27
  index: index,
28
- templateConfig: templateConfig,
28
+ templateSize: templateConfig,
29
29
  });
30
30
  const localY = (0, resolve_axis_1.resolveAxis)({
31
31
  axis: initialY,
32
32
  data: data,
33
33
  index: index,
34
- templateConfig: templateConfig,
34
+ templateSize: templateConfig,
35
35
  });
36
36
  const x = renderContext.offsetX + localX;
37
37
  const y = renderContext.offsetY + localY;
@@ -1,8 +1,10 @@
1
1
  import { Canvas } from "@napi-rs/canvas";
2
2
  import { Layer } from "./layers/layer";
3
- export type TemplateConfig = {
3
+ export type TemplateSize = {
4
4
  width: number;
5
5
  height: number;
6
+ };
7
+ export type TemplateConfig = TemplateSize & {
6
8
  fill?: string;
7
9
  };
8
10
  export type InputTemplateOptions<Data> = {
@@ -1,14 +1,12 @@
1
- import { TemplateConfig } from "../template";
1
+ import { TemplateSize } from "../template";
2
2
  export type ComputeAxisOptions<Data> = {
3
3
  data: Data;
4
4
  index: number;
5
+ templateSize: TemplateSize;
5
6
  };
6
7
  export type ComputeAxis<Data> = (options: ComputeAxisOptions<Data>) => number;
7
8
  export type Axis<Data> = ComputeAxis<Data> | number;
8
- export type ResolveAxisOptions<Data> = {
9
+ export type ResolveAxisOptions<Data> = ComputeAxisOptions<Data> & {
9
10
  axis: Axis<Data>;
10
- data: Data;
11
- index: number;
12
- templateConfig: TemplateConfig;
13
11
  };
14
12
  export declare function resolveAxis<Data>({ axis, ...params }: ResolveAxisOptions<Data>): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xpict",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
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",