@nmmty/lazycanvas 0.6.0-dev.1d5786 → 0.6.0-dev.7aa084

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.
@@ -1,28 +0,0 @@
1
- import { Group } from "../structures/components";
2
- import { ColorType } from "../types";
3
- declare const Utils: {
4
- grid(size: {
5
- x: number;
6
- y: number;
7
- }, opts?: gridOptions): Group;
8
- box(start: {
9
- x: number;
10
- y: number;
11
- }, end: {
12
- x: number;
13
- y: number;
14
- }, opts?: options): Group;
15
- };
16
- interface options {
17
- color?: ColorType;
18
- lineWidth?: number;
19
- }
20
- interface gridOptions extends options {
21
- cellWith?: number;
22
- cellHeight?: number;
23
- startX?: number;
24
- startY?: number;
25
- endX?: number;
26
- endY?: number;
27
- }
28
- export { Utils };
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Utils = void 0;
4
- const components_1 = require("../structures/components");
5
- const Utils = {
6
- grid(size, opts) {
7
- if (size.x === undefined || size.y === undefined) {
8
- throw new Error("Size must have x and y properties");
9
- }
10
- if (opts === undefined)
11
- opts = {};
12
- if (opts.cellWith === undefined)
13
- opts.cellWith = 10;
14
- if (opts.cellHeight === undefined)
15
- opts.cellHeight = 10;
16
- if (opts.startX === undefined)
17
- opts.startX = 0;
18
- if (opts.startY === undefined)
19
- opts.startY = 0;
20
- if (opts.endX === undefined)
21
- opts.endX = size.x;
22
- if (opts.endY === undefined)
23
- opts.endY = size.y;
24
- if (opts.color === undefined)
25
- opts.color = 'rgba(0, 0, 0, 0.5)';
26
- if (opts.lineWidth === undefined)
27
- opts.lineWidth = 1;
28
- const options = { ...opts };
29
- return new components_1.Group()
30
- .setID(`grid-${options.cellWith}-${options.cellHeight}-${options.startX}-${options.startY}-${options.endX}-${options.endY}`)
31
- .add(...Array.from({ length: Math.ceil((options.endX - options.startX) / options.cellWith) }, (_, i) => {
32
- const x = options.startX + i * options.cellWith;
33
- return new components_1.LineLayer()
34
- .setPosition(x, options.startY)
35
- .setEndPosition(x, options.endY)
36
- .setColor(options.color)
37
- .setStroke(options.lineWidth);
38
- }), ...Array.from({ length: Math.ceil((options.endY - options.startY) / options.cellHeight) }, (_, i) => {
39
- const y = options.startY + i * options.cellHeight;
40
- return new components_1.LineLayer()
41
- .setPosition(options.startX, y)
42
- .setEndPosition(options.endX, y)
43
- .setColor(options.color)
44
- .setStroke(options.lineWidth);
45
- }));
46
- },
47
- box(start, end, opts) {
48
- if (start.x === undefined || start.y === undefined || end.x === undefined || end.y === undefined) {
49
- throw new Error("Start and end must have x and y properties");
50
- }
51
- if (opts === undefined)
52
- opts = {};
53
- if (opts.color === undefined)
54
- opts.color = 'rgba(0, 0, 0, 0.5)';
55
- if (opts.lineWidth === undefined)
56
- opts.lineWidth = 1;
57
- return new components_1.Group()
58
- .setID(`box-${start.x}-${start.y}-${end.x}-${end.y}`)
59
- .add(new components_1.LineLayer()
60
- .setPosition(start.x, start.y)
61
- .setEndPosition(end.x, start.y)
62
- .setColor(opts.color)
63
- .setStroke(opts.lineWidth), new components_1.LineLayer()
64
- .setPosition(end.x, start.y)
65
- .setEndPosition(end.x, end.y)
66
- .setColor(opts.color)
67
- .setStroke(opts.lineWidth), new components_1.LineLayer()
68
- .setPosition(end.x, end.y)
69
- .setEndPosition(start.x, end.y)
70
- .setColor(opts.color)
71
- .setStroke(opts.lineWidth), new components_1.LineLayer()
72
- .setPosition(start.x, end.y)
73
- .setEndPosition(start.x, start.y)
74
- .setColor(opts.color)
75
- .setStroke(opts.lineWidth));
76
- }
77
- };
78
- exports.Utils = Utils;