2.0.8-semantically-released • Published 4 years ago

ng-whiteboard-nl v2.0.8-semantically-released

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

Build Status License: MIT

ng-whiteboard-nl

Lightweight angular whiteboard Demo

Features:

  • Supports touch.
  • Custom colors.
  • Custom background colors. Thanks to Nader Magdy
  • Custom background images.
  • Custom stroke size.
  • Save drawn as (svg | png | jpeg) images.
  • Experimental (undo-redo).

And more to come...

Install

  1. Install npm module:

    npm install ng-whiteboard-nl --save
  2. Add the module to your project

    import { NgWhiteboardModule } from 'ng-whiteboard-nl';
    ...
    
    @NgModule({
        imports: [
            ...
            NgWhiteboardModule
        ]
        ...
    )}
  3. Insert the Whiteboard Component element in the html.

    <ng-whiteboard></ng-whiteboard>

Options

InputTypeDefaultRequiredDescription
colorstring#000000noSet brush color
backgroundColorstring#ffffffnoSet whiteboard background color
sizestring5pxnoSet brush size
linejoinstringroundnoDefine the shape of two lines when joined together ('miter' , 'round' , 'bevel' , 'miter-clip' , 'arcs')
linecapstringroundnoDefine start and end shape of line ('butt', 'square' , 'round')
whiteboardOptionsWhiteboardOptionsnoObject of all inputs

Outputs

NameDescription
(init)Fired on Component initialize
(save)Fired on Saving, include base64
(clear)Fired on clearing
(erase)Fired on Cleaning
(undo)Fired on undoing last draw
(redo)Fired on Repainting last draw

Methods

NameARGSDefaultsDescription
savename: string, format: stringname: 'New image', format: 'png'Save current board
erasenullnullClean the whiteboard
undonullnullUndo last line
redonullnullRepaint last line
addImageimage: (string; ArrayBuffer)nulladd images to the board

to use these Methods inject NgWhiteboardService in your project

import { NgWhiteboardService } from 'ng-whiteboard-nl';
...

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
   styleUrls: ['./app.component.scss']
   ...
)}

  constructor(private whiteboardService: NgWhiteboardService) {
   this.whiteboardService.save();
  }

Contributing

The project is open for contributors! Please file an issue or make a PR:)