diff --git a/README.md b/README.md index 7c405315..8aeea4f8 100644 --- a/README.md +++ b/README.md @@ -69,11 +69,6 @@ npm install --save scratch-paint ``` For an example of how to use scratch-paint as a library, check out the `scratch-paint/src/playground` directory. -In `playground.jsx`, you can change the image that is passed in (which may either be nothing, an SVG string or a base64 data URI) and edit the handler `onUpdateImage`, which is called with the new image (either an SVG string or an ImageData) each time the vector drawing is edited. - -If the `imageId` parameter changes, then the paint editor will be cleared, the undo stack reset, and the image re-imported. - -SVGs of up to size 480 x 360 will fit into the view window of the paint editor, while bitmaps of size up to 960 x 720 will fit into the paint editor. One unit of an SVG will appear twice as tall and wide as one unit of a bitmap. This quirky import behavior comes from needing to support legacy projects in Scratch. In your parent component: ``` @@ -82,13 +77,33 @@ import PaintEditor from 'scratch-paint'; ``` +`image`: may either be nothing, an SVG string or a base64 data URI) +SVGs of up to size 480 x 360 will fit into the view window of the paint editor, while bitmaps of size up to 960 x 720 will fit into the paint editor. One unit of an SVG will appear twice as tall and wide as one unit of a bitmap. This quirky import behavior comes from needing to support legacy projects in Scratch. + +`imageId`: If this parameter changes, then the paint editor will be cleared, the undo stack reset, and the image re-imported. + +`imageFormat`: 'svg', 'png', or 'jpg'. Other formats are currently not supported. + +`rotationCenterX`: x coordinate relative to the top left corner of the sprite of the point that should be centered. + +`rotationCenterY`: y coordinate relative to the top left corner of the sprite of the point that should be centered. + +`rtl`: True if the paint editor should be laid out right to left (meant for right to left languages) + +`onUpdateImage`: A handler called with the new image (either an SVG string or an ImageData) each time the drawing is edited. + +`zoomLevelId`: All costumes with the same zoom level ID will share the same saved zoom level. When a new zoom level ID is encountered, the paint editor will zoom to fit the current costume comfortably. Leave undefined to perform no zoom to fit. + + In the top-level combineReducers function: ``` import {ScratchPaintReducer} from 'scratch-paint'; diff --git a/src/components/paint-editor/paint-editor.jsx b/src/components/paint-editor/paint-editor.jsx index d8857e38..de1b433a 100644 --- a/src/components/paint-editor/paint-editor.jsx +++ b/src/components/paint-editor/paint-editor.jsx @@ -210,6 +210,7 @@ const PaintEditorComponent = props => ( imageId={props.imageId} rotationCenterX={props.rotationCenterX} rotationCenterY={props.rotationCenterY} + zoomLevelId={props.zoomLevelId} onUpdateImage={props.onUpdateImage} />