abstract-image 3.2.5 → 3.3.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +38 -27
  2. package/LICENSE +21 -21
  3. package/README.md +73 -73
  4. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-ellipse.js +379 -379
  5. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.js +123 -123
  6. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-line.js +55 -55
  7. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polygon.js +89 -89
  8. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polyline.js +79 -79
  9. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-rectangle.js +99 -99
  10. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.js +135 -135
  11. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.js +63 -63
  12. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-ellipse.js +24 -24
  13. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.js +26 -26
  14. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-group.js +31 -31
  15. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-line.js +20 -20
  16. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-polygon.js +34 -34
  17. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-polyline.js +26 -26
  18. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-rectangle.js +20 -20
  19. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.js +59 -59
  20. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text.js +26 -26
  21. package/lib/exporters/__tests__/exception/png-unsupported.test.js +1 -1
  22. package/lib/exporters/__tests__/exception/png-unsupported.test.js.map +1 -1
  23. package/lib/exporters/__tests__/png-export-image/test-defs/png-createPNG.js +1 -1
  24. package/lib/exporters/__tests__/png-export-image/test-defs/png-createPNG.js.map +1 -1
  25. package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-png.d.ts.map +1 -1
  26. package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-png.js +2 -2
  27. package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-png.js.map +1 -1
  28. package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.d.ts +3 -0
  29. package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.d.ts.map +1 -0
  30. package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.js +33 -0
  31. package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.js.map +1 -0
  32. package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary.js +1 -1
  33. package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary.js.map +1 -1
  34. package/lib/exporters/__tests__/svg-export-image/test-defs/svg-binary.js +1 -1
  35. package/lib/exporters/__tests__/svg-export-image/test-defs/svg-binary.js.map +1 -1
  36. package/lib/exporters/__tests__/svg-export-image.test.d.ts +2 -0
  37. package/lib/exporters/__tests__/svg-export-image.test.d.ts.map +1 -0
  38. package/lib/exporters/__tests__/svg-export-image.test.js +35 -0
  39. package/lib/exporters/__tests__/svg-export-image.test.js.map +1 -0
  40. package/lib/exporters/png-export-image.js +2 -2
  41. package/lib/exporters/png-export-image.js.map +1 -1
  42. package/lib/exporters/react-svg-export-image.d.ts.map +1 -1
  43. package/lib/exporters/react-svg-export-image.js +23 -11
  44. package/lib/exporters/react-svg-export-image.js.map +1 -1
  45. package/lib/exporters/svg-export-image.d.ts.map +1 -1
  46. package/lib/exporters/svg-export-image.js +46 -15
  47. package/lib/exporters/svg-export-image.js.map +1 -1
  48. package/lib/model/component.d.ts +11 -2
  49. package/lib/model/component.d.ts.map +1 -1
  50. package/lib/model/component.js.map +1 -1
  51. package/package.json +4 -2
  52. package/src/__stories__/react-svg-export/example-1.stories.tsx +54 -54
  53. package/src/__stories__/svg-export/example-1.stories.tsx +42 -42
  54. package/src/exporters/__tests__/dxf2d-export-image/export-test-def.ts +11 -11
  55. package/src/exporters/__tests__/dxf2d-export-image/export.test.tsx +13 -13
  56. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-ellipse.ts +405 -405
  57. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.ts +166 -166
  58. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-line.ts +80 -80
  59. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polygon.ts +114 -114
  60. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polyline.ts +103 -103
  61. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-rectangle.ts +125 -125
  62. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.ts +214 -214
  63. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.ts +97 -97
  64. package/src/exporters/__tests__/eps-export-image/export-test-def.ts +11 -11
  65. package/src/exporters/__tests__/eps-export-image/export.test.tsx +13 -13
  66. package/src/exporters/__tests__/eps-export-image/test-defs/eps-ellipse.ts +50 -50
  67. package/src/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.ts +60 -60
  68. package/src/exporters/__tests__/eps-export-image/test-defs/eps-group.ts +74 -74
  69. package/src/exporters/__tests__/eps-export-image/test-defs/eps-line.ts +45 -45
  70. package/src/exporters/__tests__/eps-export-image/test-defs/eps-polygon.ts +65 -65
  71. package/src/exporters/__tests__/eps-export-image/test-defs/eps-polyline.ts +58 -58
  72. package/src/exporters/__tests__/eps-export-image/test-defs/eps-rectangle.ts +46 -46
  73. package/src/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.ts +138 -138
  74. package/src/exporters/__tests__/eps-export-image/test-defs/eps-text.ts +60 -60
  75. package/src/exporters/__tests__/exception/png-unsupported.test.tsx +25 -25
  76. package/src/exporters/__tests__/exception/react-svg-direction-exception.test.tsx +65 -65
  77. package/src/exporters/__tests__/exception/svg-direction-exception.test.tsx +65 -65
  78. package/src/exporters/__tests__/png-export-image/export-test-def.ts +11 -11
  79. package/src/exporters/__tests__/png-export-image/export.test.tsx +13 -13
  80. package/src/exporters/__tests__/png-export-image/test-defs/png-createPNG.tsx +26 -26
  81. package/src/exporters/__tests__/react-svg-export-image/export-test-def.tsx +13 -13
  82. package/src/exporters/__tests__/react-svg-export-image/export.test.tsx +13 -13
  83. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-png.tsx +26 -27
  84. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.tsx +26 -0
  85. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary.tsx +25 -25
  86. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-callback.tsx +60 -60
  87. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-ellipse.tsx +28 -28
  88. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-empty-text.tsx +35 -35
  89. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-group.tsx +44 -44
  90. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-line.tsx +26 -26
  91. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polygon.tsx +32 -32
  92. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polyline.tsx +33 -33
  93. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-rectangle.tsx +27 -27
  94. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-subimage.tsx +36 -36
  95. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-bold.tsx +50 -50
  96. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-growth-directions.tsx +80 -80
  97. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-italic.tsx +65 -65
  98. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-sub.tsx +35 -35
  99. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text.tsx +35 -35
  100. package/src/exporters/__tests__/svg-export-image/export-test-def.ts +11 -11
  101. package/src/exporters/__tests__/svg-export-image/export.test.tsx +13 -13
  102. package/src/exporters/__tests__/svg-export-image/test-defs/svg-binary.tsx +25 -25
  103. package/src/exporters/__tests__/svg-export-image/test-defs/svg-ellipse.ts +27 -27
  104. package/src/exporters/__tests__/svg-export-image/test-defs/svg-empty-text.ts +34 -34
  105. package/src/exporters/__tests__/svg-export-image/test-defs/svg-group.ts +44 -44
  106. package/src/exporters/__tests__/svg-export-image/test-defs/svg-line.ts +26 -26
  107. package/src/exporters/__tests__/svg-export-image/test-defs/svg-polygon.ts +32 -32
  108. package/src/exporters/__tests__/svg-export-image/test-defs/svg-polyline.ts +33 -33
  109. package/src/exporters/__tests__/svg-export-image/test-defs/svg-rectangle.ts +27 -27
  110. package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-bold.ts +50 -50
  111. package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-growth-directions.ts +80 -80
  112. package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-italic.ts +65 -65
  113. package/src/exporters/__tests__/svg-export-image/test-defs/svg-text.ts +35 -35
  114. package/src/exporters/dxf2d-export-image.ts +218 -218
  115. package/src/exporters/eps-export-image.ts +154 -154
  116. package/src/exporters/index.ts +3 -3
  117. package/src/exporters/png-export-image.ts +12 -12
  118. package/src/exporters/react-svg-export-image.tsx +315 -305
  119. package/src/exporters/svg-export-image.ts +309 -300
  120. package/src/index.ts +11 -11
  121. package/src/model/__tests__/color/export-test-def.ts +13 -13
  122. package/src/model/__tests__/color/export.test.tsx +14 -14
  123. package/src/model/__tests__/color/test-defs/color-from-string.ts +46 -46
  124. package/src/model/__tests__/color/test-defs/color-to-string.ts +35 -35
  125. package/src/model/__tests__/color/test-defs/color-undefined-2.ts +8 -8
  126. package/src/model/__tests__/color/test-defs/color-undefined.ts +8 -8
  127. package/src/model/abstract-image.ts +25 -25
  128. package/src/model/color.ts +52 -52
  129. package/src/model/component.ts +279 -266
  130. package/src/model/index.ts +5 -5
  131. package/src/model/point.ts +11 -11
  132. package/src/model/size.ts +11 -11
package/CHANGELOG.md CHANGED
@@ -1,27 +1,38 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
4
-
5
- ## [Unreleased](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.0.1...master)
6
-
7
- ### Added
8
-
9
- ### Changed
10
-
11
- ### Removed
12
-
13
- ## [v3.1.4](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.1.3...abstract-image@3.1.4) - 2022-01-05
14
-
15
- ### Added
16
-
17
- - Added italic and mediumBold as options for texts
18
-
19
- ## [v3.0.1](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.0.0...abstract-image@3.0.1) - 2021-01-01
20
-
21
- ### Added
22
-
23
- - Added typing on GrowthDirection for textAnchor on the svg export.
24
-
25
- ## v3.0.0 - 2021-03-24
26
-
27
- - Start of changelog.
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [Unreleased](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.3.2...master)
6
+
7
+ ### Added
8
+
9
+ ### Changed
10
+
11
+ ### Removed
12
+
13
+ ## [v3.3.2](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.0.0...abstract-image@3.3.2) - 2022-06-02
14
+
15
+ ### Added
16
+
17
+ - Support for URL as source for embedded binary images
18
+ - Support for positioning and scaling embedded svg images
19
+
20
+ ### Changed
21
+
22
+ ### Removed
23
+
24
+ ## [v3.1.4](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.1.3...abstract-image@3.1.4) - 2022-01-05
25
+
26
+ ### Added
27
+
28
+ - Added italic and mediumBold as options for texts
29
+
30
+ ## [v3.0.1](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.0.0...abstract-image@3.0.1) - 2021-01-01
31
+
32
+ ### Added
33
+
34
+ - Added typing on GrowthDirection for textAnchor on the svg export.
35
+
36
+ ## v3.0.0 - 2021-03-24
37
+
38
+ - Start of changelog.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 Divid AB
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Divid AB
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,73 +1,73 @@
1
- # abstract-image
2
-
3
- [![npm version][version-image]][version-url]
4
- [![code style: prettier][prettier-image]][prettier-url]
5
- [![MIT license][license-image]][license-url]
6
-
7
- Dynamically create images using code or JSX and render to any format
8
-
9
- ## Introduction
10
-
11
- Sometimes you need to create an image dynamically, for example when dynamically generating schematics etc. This library makes that easy by providing tools to create an abstract representation of an image which can then be turned into a concrete format such as .png, .svg etc.
12
-
13
- ## Installation
14
-
15
- `npm install --save abstract-document`
16
-
17
- The library is compiled to ES5 and no polyfills are required.
18
-
19
- ## Usage
20
-
21
- ```js
22
- import * as React from "react";
23
- import * as AbstractImage from "abstract-image";
24
-
25
- export function AbstractImageExample() {
26
- const components = [
27
- AbstractImage.createLine(
28
- AbstractImage.createPoint(25, 25),
29
- AbstractImage.createPoint(80, 60),
30
- AbstractImage.black,
31
- 2
32
- ),
33
- AbstractImage.createRectangle(
34
- AbstractImage.createPoint(10, 50),
35
- AbstractImage.createPoint(40, 80),
36
- AbstractImage.blue,
37
- 2,
38
- AbstractImage.fromArgb(100, 0, 0, 0)
39
- ),
40
- AbstractImage.createRectangle(
41
- AbstractImage.createPoint(60, 50),
42
- AbstractImage.createPoint(90, 80),
43
- AbstractImage.blue,
44
- 2,
45
- AbstractImage.transparent
46
- ),
47
- ];
48
- const image = AbstractImage.createAbstractImage(
49
- AbstractImage.createPoint(0, 0),
50
- AbstractImage.createSize(400, 400),
51
- AbstractImage.white,
52
- components
53
- );
54
- const svg = AbstractImage.createSVG(image);
55
- return (
56
- <div>
57
- <h1>Svg</h1>
58
- <p>Test</p>
59
- <pre>{svg}</pre>
60
- <img width="400" height="400" src={`data:image/svg+xml;,${svg}`} />
61
- </div>
62
- );
63
- }
64
- ```
65
-
66
- [version-image]: https://img.shields.io/npm/v/abstract-image.svg?style=flat
67
- [version-url]: https://www.npmjs.com/package/abstract-image
68
- [license-image]: https://img.shields.io/github/license/dividab/abstract-visuals.svg?style=flat
69
- [license-url]: https://opensource.org/licenses/MIT
70
- [prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat
71
- [prettier-url]: https://github.com/prettier/prettier
72
-
73
- dummy
1
+ # abstract-image
2
+
3
+ [![npm version][version-image]][version-url]
4
+ [![code style: prettier][prettier-image]][prettier-url]
5
+ [![MIT license][license-image]][license-url]
6
+
7
+ Dynamically create images using code or JSX and render to any format
8
+
9
+ ## Introduction
10
+
11
+ Sometimes you need to create an image dynamically, for example when dynamically generating schematics etc. This library makes that easy by providing tools to create an abstract representation of an image which can then be turned into a concrete format such as .png, .svg etc.
12
+
13
+ ## Installation
14
+
15
+ `npm install --save abstract-document`
16
+
17
+ The library is compiled to ES5 and no polyfills are required.
18
+
19
+ ## Usage
20
+
21
+ ```js
22
+ import * as React from "react";
23
+ import * as AbstractImage from "abstract-image";
24
+
25
+ export function AbstractImageExample() {
26
+ const components = [
27
+ AbstractImage.createLine(
28
+ AbstractImage.createPoint(25, 25),
29
+ AbstractImage.createPoint(80, 60),
30
+ AbstractImage.black,
31
+ 2
32
+ ),
33
+ AbstractImage.createRectangle(
34
+ AbstractImage.createPoint(10, 50),
35
+ AbstractImage.createPoint(40, 80),
36
+ AbstractImage.blue,
37
+ 2,
38
+ AbstractImage.fromArgb(100, 0, 0, 0)
39
+ ),
40
+ AbstractImage.createRectangle(
41
+ AbstractImage.createPoint(60, 50),
42
+ AbstractImage.createPoint(90, 80),
43
+ AbstractImage.blue,
44
+ 2,
45
+ AbstractImage.transparent
46
+ ),
47
+ ];
48
+ const image = AbstractImage.createAbstractImage(
49
+ AbstractImage.createPoint(0, 0),
50
+ AbstractImage.createSize(400, 400),
51
+ AbstractImage.white,
52
+ components
53
+ );
54
+ const svg = AbstractImage.createSVG(image);
55
+ return (
56
+ <div>
57
+ <h1>Svg</h1>
58
+ <p>Test</p>
59
+ <pre>{svg}</pre>
60
+ <img width="400" height="400" src={`data:image/svg+xml;,${svg}`} />
61
+ </div>
62
+ );
63
+ }
64
+ ```
65
+
66
+ [version-image]: https://img.shields.io/npm/v/abstract-image.svg?style=flat
67
+ [version-url]: https://www.npmjs.com/package/abstract-image
68
+ [license-image]: https://img.shields.io/github/license/dividab/abstract-visuals.svg?style=flat
69
+ [license-url]: https://opensource.org/licenses/MIT
70
+ [prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat
71
+ [prettier-url]: https://github.com/prettier/prettier
72
+
73
+ dummy