0.0.17 • Published 4 years ago

colouring-book-tmp v0.0.17

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

<colouring-book> Published on npm

This webcomponent follows the open-wc recommendations.

With special thanks to https://github.com/collinph/jl-coloringbook for the original concept and <canvas> code

Installation

npm i colouring-book

API

Properties/Attributes

NameTypeDefaultDescription
identityStringannonymousa string containing a unique ID for each user (used for local caching of coluring in).
imagesArray''An array of URLs for each page to be coloured in - defaults to first image in array.
colourPaletteArraysee exampleAn array of colours (in html/css format) that can be selected by the user - defaults to first colour.
noPrintBooleanfalseRestricts the user from printing pages with their colouring in.
noSaveBooleanfalseRestricts the user from saving pages locally as .png files.
noThumbnailsBooleanfalseApplies the colouring in to the thumbnail images of each page.
previewString''When set to right the thumbnails will appear on the right of the image, default is above images.

Events

Event NameTargetDetailDescription
image-selectedcolouring-bookimageFired when a new image is selectd.
add-pathcolouring-bookimage, pathFired when the a new coluring path is added to an image.
remove-pathcolouring-bookimage, pathFired when a path is removed from an image.
clearcolouring-bookimageFired when all path's are removed from an image.

Example

    const img = ['images/L0_P_U1_IW2.pdf-1.png','images/L0_P_U1_IW2.pdf-2.png'];
    const cols=[
            'rgba(87, 87, 87,0.8)',
            'rgba(220, 35, 35,0.8)',
            'rgba(42, 75, 215,0.8)',
            'rgba(29, 105, 20,0.8)',
            'rgba(129, 74, 25,0.8)',
            'rgba(129, 38, 192,0.8)',
            'rgba(160, 160, 160,0.8)',
            'rgba(129, 197, 122,0.8)',
            'rgba(157, 175, 255,0.8)',
            'rgba(41, 208, 208,0.8)',
            'rgba(255, 146, 51,0.8)',
            'rgba(255, 238, 51,0.8)',
            'rgba(233, 222, 187,0.8)',
            'rgba(255, 205, 243,0.8)',
            'white'];
    render(
      html`
        <colouring-book noPrint noSave .images=${img} .colourPalette=${cols} onThumbnails @add-path=${(e) => _addPath(e)}> 
        </colouring-book>
        `
    );

Usage

<script type="module">
  import 'colouring-book/colouring-book.js';
</script>

<colouring-book></colouring-book>

Local Demo with es-dev-server

npm start

To run a local development server that serves the basic demo located in demo/index.html