abstract-image 3.3.0 → 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.
- package/CHANGELOG.md +38 -27
- package/LICENSE +21 -21
- package/README.md +73 -73
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-ellipse.js +379 -379
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.js +123 -123
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-line.js +55 -55
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polygon.js +89 -89
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polyline.js +79 -79
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-rectangle.js +99 -99
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.js +135 -135
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.js +63 -63
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-ellipse.js +24 -24
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.js +26 -26
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-group.js +31 -31
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-line.js +20 -20
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-polygon.js +34 -34
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-polyline.js +26 -26
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-rectangle.js +20 -20
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.js +59 -59
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text.js +26 -26
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.d.ts +3 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.d.ts.map +1 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.js +33 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.js.map +1 -0
- package/lib/exporters/__tests__/svg-export-image.test.d.ts +2 -0
- package/lib/exporters/__tests__/svg-export-image.test.d.ts.map +1 -0
- package/lib/exporters/__tests__/svg-export-image.test.js +35 -0
- package/lib/exporters/__tests__/svg-export-image.test.js.map +1 -0
- package/package.json +2 -2
- package/src/__stories__/react-svg-export/example-1.stories.tsx +54 -54
- package/src/__stories__/svg-export/example-1.stories.tsx +42 -42
- package/src/exporters/__tests__/dxf2d-export-image/export-test-def.ts +11 -11
- package/src/exporters/__tests__/dxf2d-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-ellipse.ts +405 -405
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.ts +166 -166
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-line.ts +80 -80
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polygon.ts +114 -114
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polyline.ts +103 -103
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-rectangle.ts +125 -125
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.ts +214 -214
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.ts +97 -97
- package/src/exporters/__tests__/eps-export-image/export-test-def.ts +11 -11
- package/src/exporters/__tests__/eps-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-ellipse.ts +50 -50
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.ts +60 -60
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-group.ts +74 -74
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-line.ts +45 -45
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-polygon.ts +65 -65
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-polyline.ts +58 -58
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-rectangle.ts +46 -46
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.ts +138 -138
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-text.ts +60 -60
- package/src/exporters/__tests__/exception/png-unsupported.test.tsx +25 -25
- package/src/exporters/__tests__/exception/react-svg-direction-exception.test.tsx +65 -65
- package/src/exporters/__tests__/exception/svg-direction-exception.test.tsx +65 -65
- package/src/exporters/__tests__/png-export-image/export-test-def.ts +11 -11
- package/src/exporters/__tests__/png-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/png-export-image/test-defs/png-createPNG.tsx +26 -26
- package/src/exporters/__tests__/react-svg-export-image/export-test-def.tsx +13 -13
- package/src/exporters/__tests__/react-svg-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-png.tsx +26 -26
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.tsx +26 -0
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary.tsx +25 -25
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-callback.tsx +60 -60
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-ellipse.tsx +28 -28
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-empty-text.tsx +35 -35
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-group.tsx +44 -44
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-line.tsx +26 -26
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polygon.tsx +32 -32
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polyline.tsx +33 -33
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-rectangle.tsx +27 -27
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-subimage.tsx +36 -36
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-bold.tsx +50 -50
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-growth-directions.tsx +80 -80
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-italic.tsx +65 -65
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-sub.tsx +35 -35
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text.tsx +35 -35
- package/src/exporters/__tests__/svg-export-image/export-test-def.ts +11 -11
- package/src/exporters/__tests__/svg-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-binary.tsx +25 -25
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-ellipse.ts +27 -27
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-empty-text.ts +34 -34
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-group.ts +44 -44
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-line.ts +26 -26
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-polygon.ts +32 -32
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-polyline.ts +33 -33
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-rectangle.ts +27 -27
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-bold.ts +50 -50
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-growth-directions.ts +80 -80
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-italic.ts +65 -65
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text.ts +35 -35
- package/src/exporters/dxf2d-export-image.ts +218 -218
- package/src/exporters/eps-export-image.ts +154 -154
- package/src/exporters/index.ts +3 -3
- package/src/exporters/png-export-image.ts +12 -12
- package/src/exporters/react-svg-export-image.tsx +315 -315
- package/src/exporters/svg-export-image.ts +309 -309
- package/src/index.ts +11 -11
- package/src/model/__tests__/color/export-test-def.ts +13 -13
- package/src/model/__tests__/color/export.test.tsx +14 -14
- package/src/model/__tests__/color/test-defs/color-from-string.ts +46 -46
- package/src/model/__tests__/color/test-defs/color-to-string.ts +35 -35
- package/src/model/__tests__/color/test-defs/color-undefined-2.ts +8 -8
- package/src/model/__tests__/color/test-defs/color-undefined.ts +8 -8
- package/src/model/abstract-image.ts +25 -25
- package/src/model/color.ts +52 -52
- package/src/model/component.ts +279 -279
- package/src/model/index.ts +5 -5
- package/src/model/point.ts +11 -11
- 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.
|
|
6
|
-
|
|
7
|
-
### Added
|
|
8
|
-
|
|
9
|
-
### Changed
|
|
10
|
-
|
|
11
|
-
### Removed
|
|
12
|
-
|
|
13
|
-
## [v3.
|
|
14
|
-
|
|
15
|
-
### Added
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|