@chocbite/ts-lib-svg 1.1.0 → 1.1.2

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/README.md ADDED
@@ -0,0 +1,231 @@
1
+ # @chocbite/ts-lib-svg
2
+
3
+ A TypeScript library for programmatic SVG generation with a fluent, chainable API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @chocbite/ts-lib-svg
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```ts
14
+ import { svg } from "@chocbite/ts-lib-svg";
15
+
16
+ // Create an SVG canvas and append a red circle
17
+ const canvas = svg.svg(200, 200).elem;
18
+ canvas.appendChild(
19
+ svg.circle(100, 100, 40).fill("red").stroke("black").stroke_width(2).elem
20
+ );
21
+ document.body.appendChild(canvas);
22
+ ```
23
+
24
+ ## API
25
+
26
+ All drawing functions return an `SVGAttributes` wrapper that supports chaining. Call `.elem` to get the underlying `SVGElement`.
27
+
28
+ ### Primitives
29
+
30
+ #### `svg.svg(width, height, viewbox?)`
31
+
32
+ Creates an `<svg>` root element. The viewbox defaults to `"0 0 <width> <height>"`.
33
+
34
+ ```ts
35
+ const canvas = svg.svg(400, 300).elem;
36
+ ```
37
+
38
+ #### `svg.circle(center_x, center_y, radius)`
39
+
40
+ Creates a `<circle>` element.
41
+
42
+ ```ts
43
+ svg.circle(50, 50, 25).fill("blue").elem;
44
+ ```
45
+
46
+ #### `svg.ellipse(center_x, center_y, radius_x, radius_y)`
47
+
48
+ Creates an `<ellipse>` element.
49
+
50
+ ```ts
51
+ svg.ellipse(100, 100, 60, 30).fill("green").stroke("black").elem;
52
+ ```
53
+
54
+ #### `svg.rectangle_from_center(center_x, center_y, width, height, corner_radius)`
55
+
56
+ Creates a `<rect>` positioned by its center point.
57
+
58
+ ```ts
59
+ svg.rectangle_from_center(100, 100, 80, 40, 5).fill("orange").elem;
60
+ ```
61
+
62
+ #### `svg.rectangle_from_corner(start_x, start_y, width, height, corner_radius)`
63
+
64
+ Creates a `<rect>` positioned by its top-left corner.
65
+
66
+ ```ts
67
+ svg.rectangle_from_corner(10, 10, 80, 40, 0).fill("purple").elem;
68
+ ```
69
+
70
+ #### `svg.line(start_x, start_y, end_x, end_y)`
71
+
72
+ Creates a `<line>` element.
73
+
74
+ ```ts
75
+ svg.line(0, 0, 100, 100).stroke("black").stroke_width(2).elem;
76
+ ```
77
+
78
+ #### `svg.path(d)`
79
+
80
+ Creates a `<path>` element with the given path data string.
81
+
82
+ ```ts
83
+ svg.path("M 10 80 C 40 10, 65 10, 95 80").stroke("black").fill("none").elem;
84
+ ```
85
+
86
+ #### `svg.isosceles_triangle(center_x, center_y, width, height)`
87
+
88
+ Creates an isosceles triangle as a `<path>`.
89
+
90
+ ```ts
91
+ svg.isosceles_triangle(100, 100, 60, 80).fill("yellow").stroke("black").elem;
92
+ ```
93
+
94
+ #### `svg.circle_arc(center_x, center_y, radius, start_angle, end_angle)`
95
+
96
+ Draws a circular arc. Angles are in degrees.
97
+
98
+ ```ts
99
+ svg.circle_arc(100, 100, 50, 0, 90).stroke("red").fill("none").stroke_width(2).elem;
100
+ ```
101
+
102
+ #### `svg.ellipse_arc(center_x, center_y, radius_x, radius_y, start_angle, end_angle)`
103
+
104
+ Draws an elliptical arc. Angles are in degrees.
105
+
106
+ ```ts
107
+ svg.ellipse_arc(100, 100, 60, 30, 0, 180).stroke("blue").fill("none").elem;
108
+ ```
109
+
110
+ #### `svg.text(x, y, text, size, anchor)`
111
+
112
+ Creates a single-line `<text>` element. The `anchor` parameter controls text alignment using `SVGAnchorPoint`.
113
+
114
+ ```ts
115
+ import { svg, SVGAnchorPoint } from "@chocbite/ts-lib-svg";
116
+
117
+ svg.text(100, 50, "Hello", 16, SVGAnchorPoint.middleCenter).fill("black").elem;
118
+ ```
119
+
120
+ #### `svg.multi_line_text(x, y, width, height, text, size, anchor)`
121
+
122
+ Creates a multi-line text block using a `<foreignObject>` with an inner `<div>`.
123
+
124
+ ```ts
125
+ svg.multi_line_text(10, 10, 200, 100, "Long text that wraps", 14, SVGAnchorPoint.topLeft).elem;
126
+ ```
127
+
128
+ #### `svg.group()`
129
+
130
+ Creates a `<g>` group element. Append child elements to it.
131
+
132
+ ```ts
133
+ const g = svg.group().translate(50, 50).elem;
134
+ g.appendChild(svg.circle(0, 0, 20).fill("red").elem);
135
+ g.appendChild(svg.circle(40, 0, 20).fill("blue").elem);
136
+ ```
137
+
138
+ #### `svg.create(tagName)`
139
+
140
+ Creates an arbitrary SVG element by tag name (e.g. `"defs"`, `"clipPath"`).
141
+
142
+ ```ts
143
+ const defs = svg.create("defs").elem;
144
+ ```
145
+
146
+ ### Chaining Attributes
147
+
148
+ Every primitive returns an `SVGAttributes` wrapper with chainable methods:
149
+
150
+ | Method | Shorthand | Description |
151
+ |---|---|---|
152
+ | `.fill(color)` | `.f(color)` | Set fill color |
153
+ | `.stroke(color)` | `.s(color)` | Set stroke color |
154
+ | `.stroke_width(n)` | `.sw(n)` | Set stroke width |
155
+ | `.class_list(...names)` | `.cl(...names)` | Add CSS class names |
156
+ | `.attribute(name, value)` | `.a(name, value)` | Set any attribute |
157
+ | `.translate(x, y)` | | Apply translate transform |
158
+ | `.rotate(angle, cx?, cy?)` | | Apply rotate transform |
159
+ | `.scale(sx, sy?)` | | Apply scale transform |
160
+ | `.skewX(angle)` | | Apply skewX transform |
161
+ | `.skewY(angle)` | | Apply skewY transform |
162
+ | `.transform(str)` | | Apply a custom transform string |
163
+ | `.elem` | | Get the underlying `SVGElement` |
164
+
165
+ Transforms are accumulated and written to the `transform` attribute when `.elem` is accessed.
166
+
167
+ ```ts
168
+ svg.circle(0, 0, 10)
169
+ .fill("red")
170
+ .stroke("black")
171
+ .stroke_width(1)
172
+ .class_list("my-circle")
173
+ .translate(50, 50)
174
+ .rotate(45)
175
+ .elem;
176
+ ```
177
+
178
+ ### Utilities
179
+
180
+ #### `SVGAnchorPoint`
181
+
182
+ An enum-like object describing text anchor positions:
183
+
184
+ ```ts
185
+ import { SVGAnchorPoint } from "@chocbite/ts-lib-svg";
186
+
187
+ SVGAnchorPoint.topLeft; // 2
188
+ SVGAnchorPoint.topCenter; // 3
189
+ SVGAnchorPoint.topRight; // 4
190
+ SVGAnchorPoint.middleLeft; // 1
191
+ SVGAnchorPoint.middleCenter; // 8
192
+ SVGAnchorPoint.middleRight; // 5
193
+ SVGAnchorPoint.bottomLeft; // 0
194
+ SVGAnchorPoint.bottomCenter; // 7
195
+ SVGAnchorPoint.bottomRight; // 6
196
+ ```
197
+
198
+ #### `svg.angle_to_anchor_point(angle)`
199
+
200
+ Converts an angle (in radians) to the nearest `SVGAnchorPoint`. Useful for placing labels around a circle.
201
+
202
+ ```ts
203
+ const anchor = svg.angle_to_anchor_point(Math.PI / 4); // bottomRight
204
+ ```
205
+
206
+ ## Full Example
207
+
208
+ ```ts
209
+ import { svg, SVGAnchorPoint } from "@chocbite/ts-lib-svg";
210
+
211
+ const canvas = svg.svg(300, 300).elem;
212
+
213
+ // Background
214
+ canvas.appendChild(
215
+ svg.rectangle_from_corner(0, 0, 300, 300, 0).fill("#f0f0f0").elem
216
+ );
217
+
218
+ // Grouped shapes
219
+ const g = svg.group().translate(150, 150).elem;
220
+ g.appendChild(svg.circle(0, 0, 50).fill("none").stroke("steelblue").stroke_width(2).elem);
221
+ g.appendChild(svg.line(-50, 0, 50, 0).stroke("gray").stroke_width(1).elem);
222
+ g.appendChild(svg.line(0, -50, 0, 50).stroke("gray").stroke_width(1).elem);
223
+ g.appendChild(svg.text(0, -60, "Center", 12, SVGAnchorPoint.bottomCenter).fill("black").elem);
224
+ canvas.appendChild(g);
225
+
226
+ document.body.appendChild(canvas);
227
+ ```
228
+
229
+ ## License
230
+
231
+ MIT
package/dist/index.d.mts CHANGED
@@ -164,6 +164,7 @@ declare function isosceles_triangle(center_x: number, center_y: number, width: n
164
164
  //#region src/index.d.ts
165
165
  declare const svg: {
166
166
  create: typeof create_svg_element;
167
+ attr: (elem: SVGElement) => SVGAttributes<SVGElement>;
167
168
  circle: typeof circle;
168
169
  circle_arc: typeof circle_arc;
169
170
  ellipse: typeof ellipse;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/attributes.ts","../src/primitives/circle.ts","../src/primitives/ellipse.ts","../src/primitives/group.ts","../src/primitives/line.ts","../src/primitives/path.ts","../src/primitives/rectangle.ts","../src/primitives/shared.ts","../src/primitives/svg.ts","../src/util/anchorPoint.ts","../src/primitives/text.ts","../src/primitives/triangle.ts","../src/index.ts"],"mappings":";cAAa,aAAA,WAAwB,UAAA;EAAA;cACvB,IAAA,EAAM,CAAA;EADM;EAAA,IAMpB,IAAA,CAAA,GAAQ,CAAA;EALM;EAWlB,MAAA,CAAO,MAAA;EANM;EAWb,CAAA,CAAE,MAAA;EAjBuB;EAuBzB,IAAA,CAAK,IAAA;;EAKL,CAAA,CAAE,IAAA;EA3BgB;EAiClB,YAAA,CAAa,KAAA;EA5BT;EAiCJ,EAAA,CAAG,KAAA;EA3BH;EAiCA,UAAA,CAAA,GAAc,UAAA;EA5Bd;EAiCA,EAAA,CAAA,GAAM,UAAA;EA3BN;EAiCA,SAAA,CAAU,IAAA,UAAc,KAAA;EA5BxB;EAiCA,CAAA,CAAE,IAAA,UAAc,KAAA;EA3BhB;EAuCA,SAAA,CAAU,CAAA,UAAW,CAAA;EAlCrB;EAwCA,MAAA,CAAO,KAAA,UAAe,EAAA,WAAa,EAAA;EAlCnC;EA0CA,KAAA,CAAM,EAAA,UAAY,EAAA;EArClB;EA4CA,KAAA,CAAM,KAAA;EAtCN;EA4CA,KAAA,CAAM,KAAA;EA5CkB;EAkDxB,SAAA,CAAU,SAAA;AAAA;;;AA1GZ;;;;AAAA,iBCQgB,MAAA,CACd,QAAA,UACA,QAAA,UACA,MAAA,WACC,aAAA,CAAc,gBAAA;;;;;;;iBAcD,UAAA,CACd,QAAA,UACA,QAAA,UACA,MAAA,UACA,WAAA,UACA,SAAA,WACC,aAAA,CAAc,cAAA;;;ADhCjB;;;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,CAAc,cAAA;;;;;;;;;iBAyDD,eAAA,CACd,CAAA,UACA,CAAA,UACA,KAAA,UACA,MAAA,UACA,IAAA,UACA,IAAA,UACA,MAAA,EAAQ,cAAA,GACP,aAAA,CAAc,uBAAA;;;AVjFjB;;;;;AAAA,iBWQgB,kBAAA,CACd,QAAA,UACA,QAAA,UACA,KAAA,UACA,MAAA,WACC,aAAA,CAAc,cAAA;;;cCEJ,GAAA;;;;;;;;;;;;;;;;;KAoBD,OAAA,SAAgB,aAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/attributes.ts","../src/primitives/circle.ts","../src/primitives/ellipse.ts","../src/primitives/group.ts","../src/primitives/line.ts","../src/primitives/path.ts","../src/primitives/rectangle.ts","../src/primitives/shared.ts","../src/primitives/svg.ts","../src/util/anchorPoint.ts","../src/primitives/text.ts","../src/primitives/triangle.ts","../src/index.ts"],"mappings":";cAAa,aAAA,WAAwB,UAAA;EAAA;cACvB,IAAA,EAAM,CAAA;EADM;EAAA,IAMpB,IAAA,CAAA,GAAQ,CAAA;EALM;EAWlB,MAAA,CAAO,MAAA;EANM;EAWb,CAAA,CAAE,MAAA;EAjBuB;EAuBzB,IAAA,CAAK,IAAA;;EAKL,CAAA,CAAE,IAAA;EA3BgB;EAiClB,YAAA,CAAa,KAAA;EA5BT;EAiCJ,EAAA,CAAG,KAAA;EA3BH;EAiCA,UAAA,CAAA,GAAc,UAAA;EA5Bd;EAiCA,EAAA,CAAA,GAAM,UAAA;EA3BN;EAiCA,SAAA,CAAU,IAAA,UAAc,KAAA;EA5BxB;EAiCA,CAAA,CAAE,IAAA,UAAc,KAAA;EA3BhB;EAuCA,SAAA,CAAU,CAAA,UAAW,CAAA;EAlCrB;EAwCA,MAAA,CAAO,KAAA,UAAe,EAAA,WAAa,EAAA;EAlCnC;EA0CA,KAAA,CAAM,EAAA,UAAY,EAAA;EArClB;EA4CA,KAAA,CAAM,KAAA;EAtCN;EA4CA,KAAA,CAAM,KAAA;EA5Ck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QOgB,KAAA,CACd,KAAA,UACA,MAAA,UACA,OAAA,YACC,aAAA,CAAc,aAAA;;;cCVJ,cAAA;EAAA;;;;;;;;;;KAWD,cAAA,WACF,cAAA,eAA6B,cAAA;;;;;;;;;iBCHvB,IAAA,CACd,CAAA,UACA,CAAA,UACA,IAAA,UACA,IAAA,UACA,MAAA,EAAQ,cAAA,GACP,aAAA,CAAc,cAAA;;;;;;;;;iBAyDD,eAAA,CACd,CAAA,UACA,CAAA,UACA,KAAA,UACA,MAAA,UACA,IAAA,UACA,IAAA,UACA,MAAA,EAAQ,cAAA,GACP,aAAA,CAAc,uBAAA;;;AVjFjB;;;;;AAAA,iBWQgB,kBAAA,CACd,QAAA,UACA,QAAA,UACA,KAAA,UACA,MAAA,WACC,aAAA,CAAc,cAAA;;;cCGJ,GAAA;;eAEE,UAAA,KAAU,aAAA,CAAA,UAAA;;;;;;;;;;;;;;;;KAmBb,OAAA,SAAgB,aAAA"}
package/dist/index.mjs CHANGED
@@ -357,6 +357,7 @@ const angle_to_anchor_point = (angle) => {
357
357
  //#region src/index.ts
358
358
  const svg = {
359
359
  create: create_svg_element,
360
+ attr: (elem) => new SVGAttributes(elem),
360
361
  circle,
361
362
  circle_arc,
362
363
  ellipse,
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["#elem","#apply_transforms","#transforms","svg","svgsvg"],"sources":["../src/attributes.ts","../src/shared.ts","../src/primitives/shared.ts","../src/primitives/ellipse.ts","../src/primitives/circle.ts","../src/primitives/group.ts","../src/primitives/line.ts","../src/primitives/path.ts","../src/primitives/rectangle.ts","../src/primitives/svg.ts","../src/util/anchorPoint.ts","../src/primitives/text.ts","../src/primitives/triangle.ts","../src/util/angleToAnchorPoint.ts","../src/index.ts"],"sourcesContent":["export class SVGAttributes<T extends SVGElement> {\n constructor(elem: T) {\n this.#elem = elem;\n }\n #elem: T;\n /**Returns the svg element */\n get elem(): T {\n this.#apply_transforms();\n return this.#elem;\n }\n\n /** Sets the stroke color of the SVG element */\n stroke(stroke: string): this {\n this.#elem.setAttribute(\"stroke\", stroke);\n return this;\n }\n /** Sets the stroke color of the SVG element */\n s(stroke: string): this {\n this.#elem.setAttribute(\"stroke\", stroke);\n return this;\n }\n\n /** Sets the fill color of the SVG element */\n fill(fill: string): this {\n this.#elem.setAttribute(\"fill\", fill);\n return this;\n }\n /** Sets the fill color of the SVG element */\n f(fill: string): this {\n this.#elem.setAttribute(\"fill\", fill);\n return this;\n }\n\n /** Sets the stroke width of the SVG element */\n stroke_width(width: number): this {\n this.#elem.setAttribute(\"stroke-width\", String(width));\n return this;\n }\n /** Sets the stroke width of the SVG element */\n sw(width: number): this {\n this.#elem.setAttribute(\"stroke-width\", String(width));\n return this;\n }\n\n /** Adds one or more class names to the SVG element */\n class_list(...class_name: string[]): this {\n this.#elem.classList.add(...class_name);\n return this;\n }\n /** Adds one or more class names to the SVG element */\n cl(...class_name: string[]): this {\n this.#elem.classList.add(...class_name);\n return this;\n }\n\n /** Sets an arbitrary attribute on the SVG element */\n attribute(name: string, value: string): this {\n this.#elem.setAttribute(name, value);\n return this;\n }\n /** Sets an arbitrary attribute on the SVG element */\n a(name: string, value: string): this {\n this.#elem.setAttribute(name, value);\n return this;\n }\n\n #transforms: string[] = [];\n #apply_transforms(): void {\n if (this.#transforms.length > 0)\n this.#elem.setAttribute(\"transform\", this.#transforms.join(\" \"));\n }\n\n /** Applies a translation transform to the SVG element */\n translate(x: number, y: number): this {\n this.#transforms.push(`translate(${x} ${y})`);\n return this;\n }\n\n /** Applies a rotation transform to the SVG element */\n rotate(angle: number, cx?: number, cy?: number): this {\n if (cx !== undefined && cy !== undefined)\n this.#transforms.push(`rotate(${angle} ${cx} ${cy})`);\n else this.#transforms.push(`rotate(${angle})`);\n return this;\n }\n\n /** Applies a scaling transform to the SVG element */\n scale(sx: number, sy?: number): this {\n if (sy !== undefined) this.#transforms.push(`scale(${sx} ${sy})`);\n else this.#transforms.push(`scale(${sx})`);\n return this;\n }\n\n /** Applies a skewX transform to the SVG element */\n skewX(angle: number): this {\n this.#transforms.push(`skewX(${angle})`);\n return this;\n }\n\n /** Applies a skewY transform to the SVG element */\n skewY(angle: number): this {\n this.#transforms.push(`skewY(${angle})`);\n return this;\n }\n\n /** Applies a custom transform to the SVG element */\n transform(transform: string): this {\n this.#transforms.push(transform);\n return this;\n }\n}\n","export const NAME_SPACE = \"http://www.w3.org/2000/svg\";\n","import { SVGAttributes } from \"../attributes\";\nimport { NAME_SPACE } from \"../shared\";\n\ntype SVGElements = {\n ellipse: SVGEllipseElement;\n circle: SVGCircleElement;\n path: SVGPathElement;\n line: SVGLineElement;\n rect: SVGRectElement;\n text: SVGTextElement;\n g: SVGGElement;\n svg: SVGSVGElement;\n foreignObject: SVGForeignObjectElement;\n};\n\nexport function create_svg_element<K extends keyof SVGElements>(\n name: K,\n): SVGAttributes<SVGElements[K]> {\n return new SVGAttributes(\n document.createElementNS(NAME_SPACE, name) as SVGElements[K],\n );\n}\n","import { degrees_to_radians } from \"@chocbite/ts-lib-math\";\nimport { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a svg ellipse\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param radius_x x radius of circle\n * @param radius_y y radius of circle*/\nexport function ellipse(\n center_x: number,\n center_y: number,\n radius_x: number,\n radius_y: number,\n): SVGAttributes<SVGEllipseElement> {\n return create_svg_element(\"ellipse\")\n .a(\"cx\", String(center_x))\n .a(\"cy\", String(center_y))\n .a(\"rx\", String(radius_x))\n .a(\"ry\", String(radius_y));\n}\n\n/**This draws parts of a circle/ellipse, the circle direction is reversed\n * @param center_x the center point on the x axis\n * @param center_y the center point on the y axis\n * @param radius_x radius in x axis\n * @param radius_y radius in y axis\n * @param start_angle start angle in radians\n * @param end_angle end anglein radians*/\nexport function ellipse_arc(\n center_x: number,\n center_y: number,\n radius_x: number,\n radius_y: number,\n start_angle: number,\n end_angle: number,\n): SVGAttributes<SVGPathElement> {\n const start_radian = degrees_to_radians(start_angle);\n end_angle = degrees_to_radians(end_angle - start_angle);\n const s_x = radius_x * Math.cos(start_radian) + center_x;\n const s_y = radius_y * Math.sin(start_radian) + center_y;\n const e_x = radius_x * Math.cos(start_radian + end_angle) + center_x;\n const e_y = radius_y * Math.sin(start_radian + end_angle) + center_y;\n const f_a = end_angle > Math.PI ? 1 : 0;\n const f_s = end_angle > 0 ? 1 : 0;\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${s_x} ${s_y} A ${radius_x} ${radius_y} 0 ${f_a} ${f_s} ${e_x} ${e_y}`,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { ellipse_arc } from \"./ellipse\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a svg circle\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param radius radius of circle*/\nexport function circle(\n center_x: number,\n center_y: number,\n radius: number,\n): SVGAttributes<SVGCircleElement> {\n const circle = create_svg_element(\"circle\");\n circle.a(\"cx\", String(center_x));\n circle.a(\"cy\", String(center_y));\n circle.a(\"r\", String(radius));\n return circle;\n}\n\n/**This draws parts of a circle/ellipse, the circle direction is reversed\n * @param center_x the center point on the x axis\n * @param center_y the center point on the y axis\n * @param radius radius in x axis\n * @param start_angle start angle in radians\n * @param end_angle end anglein radians*/\nexport function circle_arc(\n center_x: number,\n center_y: number,\n radius: number,\n start_angle: number,\n end_angle: number,\n): SVGAttributes<SVGPathElement> {\n return ellipse_arc(\n center_x,\n center_y,\n radius,\n radius,\n start_angle,\n end_angle,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This draws a triangle*/\nexport function group(): SVGAttributes<SVGGElement> {\n return create_svg_element(\"g\");\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a line element\n * @param start_x start point on x axis\n * @param start_y start point on y axis\n * @param end_x end point on x axis\n * @param end_y end point on y axis*/\nexport function line(\n start_x: number,\n start_y: number,\n end_x: number,\n end_y: number,\n): SVGAttributes<SVGLineElement> {\n return create_svg_element(\"line\")\n .a(\"x1\", String(start_x))\n .a(\"y1\", String(start_y))\n .a(\"x2\", String(end_x))\n .a(\"y2\", String(end_y));\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a path element*/\nexport function path(path: string): SVGAttributes<SVGPathElement> {\n return create_svg_element(\"path\").a(\"d\", path);\n}\n\n/**This creates a line with a path element\n * @param start_x start point on x axis\n * @param start_y start point on y axis\n * @param end_x end point on x axis\n * @param end_y end point on y axis*/\nexport function path_line(\n start_x: number,\n start_y: number,\n end_x: number,\n end_y: number,\n): SVGAttributes<SVGPathElement> {\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${start_x} ${start_y} L ${end_x} ${end_y}`,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a rectangle with teh center as origin\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param width width\n * @param height height\n * @param corner_radius radius of corner*/\nexport function rectangle_from_center(\n center_x: number,\n center_y: number,\n width: number,\n height: number,\n corner_radius: number,\n): SVGAttributes<SVGRectElement> {\n return create_svg_element(\"rect\")\n .a(\"x\", String(center_x - width / 2))\n .a(\"y\", String(center_y - height / 2))\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"rx\", String(corner_radius));\n}\n\n/**This creates a rectangle with teh center as origin\n * @param start_x x coordinate of center\n * @param start_y y coordinate of center\n * @param width width\n * @param height height\n * @param corner_radius radius of corner*/\nexport function rectangle_from_corner(\n start_x: number,\n start_y: number,\n width: number,\n height: number,\n corner_radius: number,\n): SVGAttributes<SVGRectElement> {\n return create_svg_element(\"rect\")\n .a(\"x\", String(start_x))\n .a(\"y\", String(start_y))\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"rx\", String(corner_radius));\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/** This returns an empty svg element\n * @param width width of svg\n * @param height height of svg\n * @param viewbox viewbox of svg*/\nexport function svg(\n width: number,\n height: number,\n viewbox: string = `0 0 ${width} ${height}`,\n): SVGAttributes<SVGSVGElement> {\n return create_svg_element(\"svg\")\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"viewBox\", String(viewbox));\n}\n","//Enum describing the diffrent possible anchor points\nexport const SVGAnchorPoint = {\n bottomLeft: 0,\n middleLeft: 1,\n topLeft: 2,\n topCenter: 3,\n topRight: 4,\n middleRight: 5,\n bottomRight: 6,\n bottomCenter: 7,\n middleCenter: 8,\n} as const;\nexport type SVGAnchorPoint =\n (typeof SVGAnchorPoint)[keyof typeof SVGAnchorPoint];\n","import { SVGAttributes } from \"../attributes\";\nimport { SVGAnchorPoint } from \"../util/anchorPoint\";\nimport { create_svg_element } from \"./shared\";\n\n/**Creates a text nodes for an svg\n * @param x x coordinate of text\n * @param y y coordinate of text\n * @param text text\n * @param size size of text in px\n * @param anchor anchor point of text*/\nexport function text(\n x: number,\n y: number,\n text: string,\n size: number,\n anchor: SVGAnchorPoint,\n): SVGAttributes<SVGTextElement> {\n const text_elem = create_svg_element(\"text\")\n .a(\"x\", String(x))\n .a(\"y\", String(y))\n .a(\"font-size\", String(size));\n text_elem.elem.innerHTML = text;\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.topLeft: {\n text_elem.a(\"text-anchor\", \"start\");\n break;\n }\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.bottomCenter:\n case SVGAnchorPoint.middleCenter: {\n text_elem.a(\"text-anchor\", \"middle\");\n break;\n }\n case SVGAnchorPoint.topRight:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.bottomRight: {\n text_elem.a(\"text-anchor\", \"end\");\n break;\n }\n }\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.bottomRight:\n case SVGAnchorPoint.bottomCenter: {\n text_elem.a(\"dominant-baseline\", \"auto\");\n break;\n }\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.middleCenter: {\n text_elem.a(\"dominant-baseline\", \"central\");\n break;\n }\n case SVGAnchorPoint.topLeft:\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.topRight: {\n text_elem.a(\"dominant-baseline\", \"hanging\");\n break;\n }\n }\n return text_elem;\n}\n\n/**Creates a text nodes for an svg\n * @param x x coordinate of text\n * @param y y coordinate of text\n * @param width width of text\n * @param height height of text\n * @param text text\n * @param size size of text in px\n * @param anchor anchor point of */\nexport function multi_line_text(\n x: number,\n y: number,\n width: number,\n height: number,\n text: string,\n size: number,\n anchor: SVGAnchorPoint,\n): SVGAttributes<SVGForeignObjectElement> {\n const text_element = create_svg_element(\"foreignObject\");\n const text_div = text_element.elem.appendChild(document.createElement(\"div\"));\n text_element.a(\"width\", String(width));\n text_element.a(\"height\", String(height));\n text_element.a(\"x\", String(x));\n text_element.a(\"y\", String(y));\n text_div.style.fontSize = size + \"px\";\n text_div.style.width = \"100%\";\n text_div.style.height = \"100%\";\n text_div.style.display = \"flex\";\n text_div.innerHTML = text;\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.topLeft: {\n text_div.style.textAlign = \"start\";\n text_div.style.justifyContent = \"flex-start\";\n break;\n }\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.bottomCenter:\n case SVGAnchorPoint.middleCenter: {\n text_div.style.textAlign = \"center\";\n text_div.style.justifyContent = \"center\";\n break;\n }\n case SVGAnchorPoint.topRight:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.bottomRight: {\n text_div.style.textAlign = \"end\";\n text_div.style.justifyContent = \"flex-end\";\n break;\n }\n }\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.bottomRight:\n case SVGAnchorPoint.bottomCenter: {\n text_div.style.alignItems = \"flex-end\";\n break;\n }\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.middleCenter: {\n text_div.style.alignItems = \"center\";\n break;\n }\n case SVGAnchorPoint.topLeft:\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.topRight: {\n text_div.style.alignItems = \"flex-start\";\n break;\n }\n }\n return text_element;\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This draws a triangle\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param width width\n * @param height height*/\nexport function isosceles_triangle(\n center_x: number,\n center_y: number,\n width: number,\n height: number,\n): SVGAttributes<SVGPathElement> {\n const half_w = width / 2;\n const half_h = height / 2;\n return create_svg_element(\"path\").a(\n \"d\",\n \"M\" +\n (center_x - half_w) +\n \",\" +\n (center_y + half_h) +\n \" \" +\n (center_x + half_w) +\n \",\" +\n (center_y + half_h) +\n \" \" +\n center_x +\n \",\" +\n (center_y - half_h) +\n \"Z\",\n );\n}\n","import { SVGAnchorPoint } from \"./anchorPoint\";\n\n/**Converts an angle to an anchor point\n * @param angle angle in radians*/\nexport const angle_to_anchor_point = (angle: number) => {\n const sec =\n angle >= 0 ? angle % 6.283185307179586 : -(angle % 6.283185307179586);\n if (sec > 5.93411945678072) {\n return SVGAnchorPoint.middleRight;\n } else if (sec > 4.974188368183839) {\n return SVGAnchorPoint.topRight;\n } else if (sec > 4.45058959258554) {\n return SVGAnchorPoint.topCenter;\n } else if (sec > 3.4906585039886591) {\n return SVGAnchorPoint.topLeft;\n } else if (sec > 2.792526803190927) {\n return SVGAnchorPoint.middleLeft;\n } else if (sec > 1.832595714594046) {\n return SVGAnchorPoint.bottomLeft;\n } else if (sec > 1.308996938995747) {\n return SVGAnchorPoint.bottomCenter;\n } else if (sec > 0.3490658503988659) {\n return SVGAnchorPoint.bottomRight;\n } else {\n return SVGAnchorPoint.middleRight;\n }\n};\n","import { circle, circle_arc } from \"./primitives/circle\";\nimport { ellipse, ellipse_arc } from \"./primitives/ellipse\";\nimport { group } from \"./primitives/group\";\nimport { line } from \"./primitives/line\";\nimport { path } from \"./primitives/path\";\nimport {\n rectangle_from_center,\n rectangle_from_corner,\n} from \"./primitives/rectangle\";\nimport { create_svg_element } from \"./primitives/shared\";\nimport { svg as svgsvg } from \"./primitives/svg\";\nimport { multi_line_text, text } from \"./primitives/text\";\nimport { isosceles_triangle } from \"./primitives/triangle\";\nimport { angle_to_anchor_point } from \"./util/angleToAnchorPoint\";\n\nexport const svg = {\n create: create_svg_element,\n //Primitives\n circle: circle,\n circle_arc: circle_arc,\n ellipse: ellipse,\n ellipse_arc: ellipse_arc,\n group: group,\n line: line,\n path: path,\n rectangle_from_center: rectangle_from_center,\n rectangle_from_corner: rectangle_from_corner,\n svg: svgsvg,\n text: text,\n multi_line_text: multi_line_text,\n isosceles_triangle: isosceles_triangle,\n //Utilities\n angle_to_anchor_point: angle_to_anchor_point,\n};\n\nexport type SVGFunc = () => SVGSVGElement;\nexport { SVGAnchorPoint } from \"./util/anchorPoint\";\n"],"mappings":";;AAAA,IAAa,gBAAb,MAAiD;CAC/C,YAAY,MAAS;AACnB,QAAA,OAAa;;CAEf;;CAEA,IAAI,OAAU;AACZ,QAAA,kBAAwB;AACxB,SAAO,MAAA;;;CAIT,OAAO,QAAsB;AAC3B,QAAA,KAAW,aAAa,UAAU,OAAO;AACzC,SAAO;;;CAGT,EAAE,QAAsB;AACtB,QAAA,KAAW,aAAa,UAAU,OAAO;AACzC,SAAO;;;CAIT,KAAK,MAAoB;AACvB,QAAA,KAAW,aAAa,QAAQ,KAAK;AACrC,SAAO;;;CAGT,EAAE,MAAoB;AACpB,QAAA,KAAW,aAAa,QAAQ,KAAK;AACrC,SAAO;;;CAIT,aAAa,OAAqB;AAChC,QAAA,KAAW,aAAa,gBAAgB,OAAO,MAAM,CAAC;AACtD,SAAO;;;CAGT,GAAG,OAAqB;AACtB,QAAA,K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;;;;ACT1B,MAAa,MAAM;CACjB,QAAQ;CAEA;CACI;CACH;CACI;CACN;CACD;CACA;CACiB;CACA;CACvB,KAAKC;CACC;CACW;CACG;CAEG;CACxB"}
1
+ {"version":3,"file":"index.mjs","names":["#elem","#apply_transforms","#transforms","svg","svgsvg"],"sources":["../src/attributes.ts","../src/shared.ts","../src/primitives/shared.ts","../src/primitives/ellipse.ts","../src/primitives/circle.ts","../src/primitives/group.ts","../src/primitives/line.ts","../src/primitives/path.ts","../src/primitives/rectangle.ts","../src/primitives/svg.ts","../src/util/anchorPoint.ts","../src/primitives/text.ts","../src/primitives/triangle.ts","../src/util/angleToAnchorPoint.ts","../src/index.ts"],"sourcesContent":["export class SVGAttributes<T extends SVGElement> {\n constructor(elem: T) {\n this.#elem = elem;\n }\n #elem: T;\n /**Returns the svg element */\n get elem(): T {\n this.#apply_transforms();\n return this.#elem;\n }\n\n /** Sets the stroke color of the SVG element */\n stroke(stroke: string): this {\n this.#elem.setAttribute(\"stroke\", stroke);\n return this;\n }\n /** Sets the stroke color of the SVG element */\n s(stroke: string): this {\n this.#elem.setAttribute(\"stroke\", stroke);\n return this;\n }\n\n /** Sets the fill color of the SVG element */\n fill(fill: string): this {\n this.#elem.setAttribute(\"fill\", fill);\n return this;\n }\n /** Sets the fill color of the SVG element */\n f(fill: string): this {\n this.#elem.setAttribute(\"fill\", fill);\n return this;\n }\n\n /** Sets the stroke width of the SVG element */\n stroke_width(width: number): this {\n this.#elem.setAttribute(\"stroke-width\", String(width));\n return this;\n }\n /** Sets the stroke width of the SVG element */\n sw(width: number): this {\n this.#elem.setAttribute(\"stroke-width\", String(width));\n return this;\n }\n\n /** Adds one or more class names to the SVG element */\n class_list(...class_name: string[]): this {\n this.#elem.classList.add(...class_name);\n return this;\n }\n /** Adds one or more class names to the SVG element */\n cl(...class_name: string[]): this {\n this.#elem.classList.add(...class_name);\n return this;\n }\n\n /** Sets an arbitrary attribute on the SVG element */\n attribute(name: string, value: string): this {\n this.#elem.setAttribute(name, value);\n return this;\n }\n /** Sets an arbitrary attribute on the SVG element */\n a(name: string, value: string): this {\n this.#elem.setAttribute(name, value);\n return this;\n }\n\n #transforms: string[] = [];\n #apply_transforms(): void {\n if (this.#transforms.length > 0)\n this.#elem.setAttribute(\"transform\", this.#transforms.join(\" \"));\n }\n\n /** Applies a translation transform to the SVG element */\n translate(x: number, y: number): this {\n this.#transforms.push(`translate(${x} ${y})`);\n return this;\n }\n\n /** Applies a rotation transform to the SVG element */\n rotate(angle: number, cx?: number, cy?: number): this {\n if (cx !== undefined && cy !== undefined)\n this.#transforms.push(`rotate(${angle} ${cx} ${cy})`);\n else this.#transforms.push(`rotate(${angle})`);\n return this;\n }\n\n /** Applies a scaling transform to the SVG element */\n scale(sx: number, sy?: number): this {\n if (sy !== undefined) this.#transforms.push(`scale(${sx} ${sy})`);\n else this.#transforms.push(`scale(${sx})`);\n return this;\n }\n\n /** Applies a skewX transform to the SVG element */\n skewX(angle: number): this {\n this.#transforms.push(`skewX(${angle})`);\n return this;\n }\n\n /** Applies a skewY transform to the SVG element */\n skewY(angle: number): this {\n this.#transforms.push(`skewY(${angle})`);\n return this;\n }\n\n /** Applies a custom transform to the SVG element */\n transform(transform: string): this {\n this.#transforms.push(transform);\n return this;\n }\n}\n","export const NAME_SPACE = \"http://www.w3.org/2000/svg\";\n","import { SVGAttributes } from \"../attributes\";\nimport { NAME_SPACE } from \"../shared\";\n\ntype SVGElements = {\n ellipse: SVGEllipseElement;\n circle: SVGCircleElement;\n path: SVGPathElement;\n line: SVGLineElement;\n rect: SVGRectElement;\n text: SVGTextElement;\n g: SVGGElement;\n svg: SVGSVGElement;\n foreignObject: SVGForeignObjectElement;\n};\n\nexport function create_svg_element<K extends keyof SVGElements>(\n name: K,\n): SVGAttributes<SVGElements[K]> {\n return new SVGAttributes(\n document.createElementNS(NAME_SPACE, name) as SVGElements[K],\n );\n}\n","import { degrees_to_radians } from \"@chocbite/ts-lib-math\";\nimport { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a svg ellipse\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param radius_x x radius of circle\n * @param radius_y y radius of circle*/\nexport function ellipse(\n center_x: number,\n center_y: number,\n radius_x: number,\n radius_y: number,\n): SVGAttributes<SVGEllipseElement> {\n return create_svg_element(\"ellipse\")\n .a(\"cx\", String(center_x))\n .a(\"cy\", String(center_y))\n .a(\"rx\", String(radius_x))\n .a(\"ry\", String(radius_y));\n}\n\n/**This draws parts of a circle/ellipse, the circle direction is reversed\n * @param center_x the center point on the x axis\n * @param center_y the center point on the y axis\n * @param radius_x radius in x axis\n * @param radius_y radius in y axis\n * @param start_angle start angle in radians\n * @param end_angle end anglein radians*/\nexport function ellipse_arc(\n center_x: number,\n center_y: number,\n radius_x: number,\n radius_y: number,\n start_angle: number,\n end_angle: number,\n): SVGAttributes<SVGPathElement> {\n const start_radian = degrees_to_radians(start_angle);\n end_angle = degrees_to_radians(end_angle - start_angle);\n const s_x = radius_x * Math.cos(start_radian) + center_x;\n const s_y = radius_y * Math.sin(start_radian) + center_y;\n const e_x = radius_x * Math.cos(start_radian + end_angle) + center_x;\n const e_y = radius_y * Math.sin(start_radian + end_angle) + center_y;\n const f_a = end_angle > Math.PI ? 1 : 0;\n const f_s = end_angle > 0 ? 1 : 0;\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${s_x} ${s_y} A ${radius_x} ${radius_y} 0 ${f_a} ${f_s} ${e_x} ${e_y}`,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { ellipse_arc } from \"./ellipse\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a svg circle\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param radius radius of circle*/\nexport function circle(\n center_x: number,\n center_y: number,\n radius: number,\n): SVGAttributes<SVGCircleElement> {\n const circle = create_svg_element(\"circle\");\n circle.a(\"cx\", String(center_x));\n circle.a(\"cy\", String(center_y));\n circle.a(\"r\", String(radius));\n return circle;\n}\n\n/**This draws parts of a circle/ellipse, the circle direction is reversed\n * @param center_x the center point on the x axis\n * @param center_y the center point on the y axis\n * @param radius radius in x axis\n * @param start_angle start angle in radians\n * @param end_angle end anglein radians*/\nexport function circle_arc(\n center_x: number,\n center_y: number,\n radius: number,\n start_angle: number,\n end_angle: number,\n): SVGAttributes<SVGPathElement> {\n return ellipse_arc(\n center_x,\n center_y,\n radius,\n radius,\n start_angle,\n end_angle,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This draws a triangle*/\nexport function group(): SVGAttributes<SVGGElement> {\n return create_svg_element(\"g\");\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a line element\n * @param start_x start point on x axis\n * @param start_y start point on y axis\n * @param end_x end point on x axis\n * @param end_y end point on y axis*/\nexport function line(\n start_x: number,\n start_y: number,\n end_x: number,\n end_y: number,\n): SVGAttributes<SVGLineElement> {\n return create_svg_element(\"line\")\n .a(\"x1\", String(start_x))\n .a(\"y1\", String(start_y))\n .a(\"x2\", String(end_x))\n .a(\"y2\", String(end_y));\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a path element*/\nexport function path(path: string): SVGAttributes<SVGPathElement> {\n return create_svg_element(\"path\").a(\"d\", path);\n}\n\n/**This creates a line with a path element\n * @param start_x start point on x axis\n * @param start_y start point on y axis\n * @param end_x end point on x axis\n * @param end_y end point on y axis*/\nexport function path_line(\n start_x: number,\n start_y: number,\n end_x: number,\n end_y: number,\n): SVGAttributes<SVGPathElement> {\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${start_x} ${start_y} L ${end_x} ${end_y}`,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a rectangle with teh center as origin\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param width width\n * @param height height\n * @param corner_radius radius of corner*/\nexport function rectangle_from_center(\n center_x: number,\n center_y: number,\n width: number,\n height: number,\n corner_radius: number,\n): SVGAttributes<SVGRectElement> {\n return create_svg_element(\"rect\")\n .a(\"x\", String(center_x - width / 2))\n .a(\"y\", String(center_y - height / 2))\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"rx\", String(corner_radius));\n}\n\n/**This creates a rectangle with teh center as origin\n * @param start_x x coordinate of center\n * @param start_y y coordinate of center\n * @param width width\n * @param height height\n * @param corner_radius radius of corner*/\nexport function rectangle_from_corner(\n start_x: number,\n start_y: number,\n width: number,\n height: number,\n corner_radius: number,\n): SVGAttributes<SVGRectElement> {\n return create_svg_element(\"rect\")\n .a(\"x\", String(start_x))\n .a(\"y\", String(start_y))\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"rx\", String(corner_radius));\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/** This returns an empty svg element\n * @param width width of svg\n * @param height height of svg\n * @param viewbox viewbox of svg*/\nexport function svg(\n width: number,\n height: number,\n viewbox: string = `0 0 ${width} ${height}`,\n): SVGAttributes<SVGSVGElement> {\n return create_svg_element(\"svg\")\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"viewBox\", String(viewbox));\n}\n","//Enum describing the diffrent possible anchor points\nexport const SVGAnchorPoint = {\n bottomLeft: 0,\n middleLeft: 1,\n topLeft: 2,\n topCenter: 3,\n topRight: 4,\n middleRight: 5,\n bottomRight: 6,\n bottomCenter: 7,\n middleCenter: 8,\n} as const;\nexport type SVGAnchorPoint =\n (typeof SVGAnchorPoint)[keyof typeof SVGAnchorPoint];\n","import { SVGAttributes } from \"../attributes\";\nimport { SVGAnchorPoint } from \"../util/anchorPoint\";\nimport { create_svg_element } from \"./shared\";\n\n/**Creates a text nodes for an svg\n * @param x x coordinate of text\n * @param y y coordinate of text\n * @param text text\n * @param size size of text in px\n * @param anchor anchor point of text*/\nexport function text(\n x: number,\n y: number,\n text: string,\n size: number,\n anchor: SVGAnchorPoint,\n): SVGAttributes<SVGTextElement> {\n const text_elem = create_svg_element(\"text\")\n .a(\"x\", String(x))\n .a(\"y\", String(y))\n .a(\"font-size\", String(size));\n text_elem.elem.innerHTML = text;\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.topLeft: {\n text_elem.a(\"text-anchor\", \"start\");\n break;\n }\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.bottomCenter:\n case SVGAnchorPoint.middleCenter: {\n text_elem.a(\"text-anchor\", \"middle\");\n break;\n }\n case SVGAnchorPoint.topRight:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.bottomRight: {\n text_elem.a(\"text-anchor\", \"end\");\n break;\n }\n }\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.bottomRight:\n case SVGAnchorPoint.bottomCenter: {\n text_elem.a(\"dominant-baseline\", \"auto\");\n break;\n }\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.middleCenter: {\n text_elem.a(\"dominant-baseline\", \"central\");\n break;\n }\n case SVGAnchorPoint.topLeft:\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.topRight: {\n text_elem.a(\"dominant-baseline\", \"hanging\");\n break;\n }\n }\n return text_elem;\n}\n\n/**Creates a text nodes for an svg\n * @param x x coordinate of text\n * @param y y coordinate of text\n * @param width width of text\n * @param height height of text\n * @param text text\n * @param size size of text in px\n * @param anchor anchor point of */\nexport function multi_line_text(\n x: number,\n y: number,\n width: number,\n height: number,\n text: string,\n size: number,\n anchor: SVGAnchorPoint,\n): SVGAttributes<SVGForeignObjectElement> {\n const text_element = create_svg_element(\"foreignObject\");\n const text_div = text_element.elem.appendChild(document.createElement(\"div\"));\n text_element.a(\"width\", String(width));\n text_element.a(\"height\", String(height));\n text_element.a(\"x\", String(x));\n text_element.a(\"y\", String(y));\n text_div.style.fontSize = size + \"px\";\n text_div.style.width = \"100%\";\n text_div.style.height = \"100%\";\n text_div.style.display = \"flex\";\n text_div.innerHTML = text;\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.topLeft: {\n text_div.style.textAlign = \"start\";\n text_div.style.justifyContent = \"flex-start\";\n break;\n }\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.bottomCenter:\n case SVGAnchorPoint.middleCenter: {\n text_div.style.textAlign = \"center\";\n text_div.style.justifyContent = \"center\";\n break;\n }\n case SVGAnchorPoint.topRight:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.bottomRight: {\n text_div.style.textAlign = \"end\";\n text_div.style.justifyContent = \"flex-end\";\n break;\n }\n }\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.bottomRight:\n case SVGAnchorPoint.bottomCenter: {\n text_div.style.alignItems = \"flex-end\";\n break;\n }\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.middleCenter: {\n text_div.style.alignItems = \"center\";\n break;\n }\n case SVGAnchorPoint.topLeft:\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.topRight: {\n text_div.style.alignItems = \"flex-start\";\n break;\n }\n }\n return text_element;\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This draws a triangle\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param width width\n * @param height height*/\nexport function isosceles_triangle(\n center_x: number,\n center_y: number,\n width: number,\n height: number,\n): SVGAttributes<SVGPathElement> {\n const half_w = width / 2;\n const half_h = height / 2;\n return create_svg_element(\"path\").a(\n \"d\",\n \"M\" +\n (center_x - half_w) +\n \",\" +\n (center_y + half_h) +\n \" \" +\n (center_x + half_w) +\n \",\" +\n (center_y + half_h) +\n \" \" +\n center_x +\n \",\" +\n (center_y - half_h) +\n \"Z\",\n );\n}\n","import { SVGAnchorPoint } from \"./anchorPoint\";\n\n/**Converts an angle to an anchor point\n * @param angle angle in radians*/\nexport const angle_to_anchor_point = (angle: number) => {\n const sec =\n angle >= 0 ? angle % 6.283185307179586 : -(angle % 6.283185307179586);\n if (sec > 5.93411945678072) {\n return SVGAnchorPoint.middleRight;\n } else if (sec > 4.974188368183839) {\n return SVGAnchorPoint.topRight;\n } else if (sec > 4.45058959258554) {\n return SVGAnchorPoint.topCenter;\n } else if (sec > 3.4906585039886591) {\n return SVGAnchorPoint.topLeft;\n } else if (sec > 2.792526803190927) {\n return SVGAnchorPoint.middleLeft;\n } else if (sec > 1.832595714594046) {\n return SVGAnchorPoint.bottomLeft;\n } else if (sec > 1.308996938995747) {\n return SVGAnchorPoint.bottomCenter;\n } else if (sec > 0.3490658503988659) {\n return SVGAnchorPoint.bottomRight;\n } else {\n return SVGAnchorPoint.middleRight;\n }\n};\n","import { SVGAttributes } from \"./attributes\";\nimport { circle, circle_arc } from \"./primitives/circle\";\nimport { ellipse, ellipse_arc } from \"./primitives/ellipse\";\nimport { group } from \"./primitives/group\";\nimport { line } from \"./primitives/line\";\nimport { path } from \"./primitives/path\";\nimport {\n rectangle_from_center,\n rectangle_from_corner,\n} from \"./primitives/rectangle\";\nimport { create_svg_element } from \"./primitives/shared\";\nimport { svg as svgsvg } from \"./primitives/svg\";\nimport { multi_line_text, text } from \"./primitives/text\";\nimport { isosceles_triangle } from \"./primitives/triangle\";\nimport { angle_to_anchor_point } from \"./util/angleToAnchorPoint\";\n\nexport const svg = {\n create: create_svg_element,\n attr: (elem: SVGElement) => new SVGAttributes(elem),\n //Primitives\n circle: circle,\n circle_arc: circle_arc,\n ellipse: ellipse,\n ellipse_arc: ellipse_arc,\n group: group,\n line: line,\n path: path,\n rectangle_from_center: rectangle_from_center,\n rectangle_from_corner: rectangle_from_corner,\n svg: svgsvg,\n text: text,\n multi_line_text: multi_line_text,\n isosceles_triangle: isosceles_triangle,\n //Utilities\n angle_to_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,YAAS,MAAM,aAAa;AAC5B;;AAGJ,QAAO;;;;;;;;;AChIT,SAAgB,mBACd,UACA,UACA,OACA,QAC+B;CAC/B,MAAM,SAAS,QAAQ;CACvB,MAAM,SAAS,SAAS;AACxB,QAAO,mBAAmB,OAAO,CAAC,EAChC,KACA,OACG,WAAW,UACZ,OACC,WAAW,UACZ,OACC,WAAW,UACZ,OACC,WAAW,UACZ,MACA,WACA,OACC,WAAW,UACZ,IACH;;;;;;AC3BH,MAAa,yBAAyB,UAAkB;CACtD,MAAM,MACJ,SAAS,IAAI,QAAQ,oBAAoB,EAAE,QAAQ;AACrD,KAAI,MAAM,iBACR,QAAO,eAAe;UACb,MAAM,kBACf,QAAO,eAAe;UACb,MAAM,iBACf,QAAO,eAAe;UACb,MAAM,kBACf,QAAO,eAAe;UACb,MAAM,kBACf,QAAO,eAAe;UACb,MAAM,kBACf,QAAO,eAAe;UACb,MAAM,kBACf,QAAO,eAAe;UACb,MAAM,kBACf,QAAO,eAAe;KAEtB,QAAO,eAAe;;;;ACR1B,MAAa,MAAM;CACjB,QAAQ;CACR,OAAO,SAAqB,IAAI,cAAc,KAAK;CAE3C;CACI;CACH;CACI;CACN;CACD;CACA;CACiB;CACA;CACvB,KAAKC;CACC;CACW;CACG;CAEG;CACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chocbite/ts-lib-svg",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Library to help with svg generation in typescript",
5
5
  "author": "chocolateandmilkwin",
6
6
  "license": "MIT",