@scratch/scratch-svg-renderer 11.0.0-UEPR-176

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/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright (c) 2016, Massachusetts Institute of Technology
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # scratch-svg-renderer
2
+
3
+ [![CI/CD](https://github.com/scratchfoundation/scratch-svg-renderer/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/scratchfoundation/scratch-svg-renderer/actions/workflows/ci-cd.yml)
4
+
5
+ A class built for importing SVGs into [Scratch](https://github.com/scratchfoundation/scratch-gui). Imports an SVG
6
+ string to a DOM element or an HTML canvas. Handles some of the quirks with Scratch 2.0 SVGs, which sometimes misreport
7
+ their width, height and view box.
8
+
9
+ ## Installation
10
+
11
+ This requires you to have Git and Node.js installed.
12
+
13
+ To install as a dependency for your own application:
14
+
15
+ ```bash
16
+ npm install scratch-svg-renderer
17
+ ```
18
+
19
+ To set up a development environment to edit scratch-svg-renderer yourself:
20
+
21
+ ```bash
22
+ git clone https://github.com/scratchfoundation/scratch-svg-renderer.git
23
+ cd scratch-svg-renderer
24
+ npm install
25
+ ```
26
+
27
+ ## How to include in a Node.js App
28
+
29
+ ```js
30
+ import SvgRenderer from '@scratch/scratch-svg-renderer';
31
+
32
+ const svgRenderer = new SvgRenderer();
33
+
34
+ const svgData = "<svg>...</svg>";
35
+ const scale = 1;
36
+ const quirksMode = false; // If true, emulate Scratch 2.0 SVG rendering "quirks"
37
+ function doSomethingWith(canvas) {...};
38
+
39
+ svgRenderer.loadSVG(svgData, quirksMode, () => {
40
+ svgRenderer.draw(scale);
41
+ doSomethingWith(svgRenderer.canvas);
42
+ });
43
+ ```
44
+
45
+ ## How to run locally as part of scratch-gui
46
+
47
+ To run scratch-svg-renderer locally as part of scratch-gui, for development:
48
+
49
+ 1. Set up local repositories (or pull updated code):
50
+ 1. scratch-svg-renderer (this repo)
51
+ 2. [scratch-render](https://github.com/scratchfoundation/scratch-render)
52
+ 3. [scratch-paint](https://github.com/scratchfoundation/scratch-paint)
53
+ 4. [scratch-gui](https://github.com/scratchfoundation/scratch-gui)
54
+ 2. In each of the local repos above, run `npm install`
55
+ 3. Run `npm link` in each of these local repos:
56
+ 1. scratch-svg-renderer
57
+ 2. scratch-render
58
+ 3. scratch-paint
59
+ 4. Run `npm link scratch-svg-renderer` in each of these local repos:
60
+ 1. scratch-render
61
+ 2. scratch-paint
62
+ 3. scratch-gui
63
+ 5. In your local scratch-gui repo:
64
+ 1. run `npm link scratch-render`
65
+ 2. run `npm link scratch-paint`
66
+ 6. In scratch-gui, follow its instructions to run it or build its code
67
+
68
+ ## Donate
69
+
70
+ We provide [Scratch](https://scratch.mit.edu) free of charge, and want to keep it that way! Please consider making a
71
+ [donation](https://secure.donationpay.org/scratchfoundation/) to support our continued engineering, design, community,
72
+ and resource development efforts. Donations of any size are appreciated. Thank you!
73
+
74
+ ## Committing
75
+
76
+ This project uses [semantic release](https://github.com/semantic-release/semantic-release) to ensure version bumps
77
+ follow semver so that projects depending on it don't break unexpectedly.
78
+
79
+ In order to automatically determine version updates, semantic release expects commit messages to follow the
80
+ [conventional-changelog](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md)
81
+ specification.
82
+
83
+ You can use the [commitizen CLI](https://github.com/commitizen/cz-cli) to make commits formatted in this way:
84
+
85
+ ```bash
86
+ npm install -g commitizen@latest cz-conventional-changelog@latest
87
+ ```
88
+
89
+ Now you're ready to make commits using `git cz`.