0.0.1 • Published 1 year ago

applepksketcher v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

applePkSketch

A React Native component for drawing perfect apple pencileKit

This package apply only fo rthe ios device

Installation

npm install @shopify/react-native-skia rn-perfect-sketch-canvas

Usage

import React, { useRef } from 'react';
import { StyleSheet, SafeAreaView, Button } from 'react-native';
import { SketchCanvas, SketchCanvasRef } from 'rn-perfect-sketch-canvas';

export default function App() {
  const canvasRef = useRef<SketchCanvasRef>(null);

  return (
    <SafeAreaView style={styles.container}>
      <SketchCanvas
        ref={canvasRef}
        strokeColor={'black'}
        strokeWidth={8}
        containerStyle={styles.container}
      />
      <Button onPress={canvasRef.current?.reset} title="Reset" />
      <Button onPress={canvaRef?.current?.isDrawToggle()} title="enableDraw" />
      <Button onPress={canvaRef?.current?.isZoomToggle()} title="disableDraw" />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

Props

PropertyTypeDefaultDescription
containerStyleobject{}Styles to be applied on canvas component.
strokeColorstringblackColor of stroke.
strokeWidthnumber8Size (diameter) of the stroke.
topChildrenReactNodeNode to be put on top of sketch
bottomChildrenReactNodeNode to be put on bottom of sketch (Background)

Methods

MethodDescription
reset()Clear all the paths.
undo()Undo
redo()Redo
toBase64(format?: ImageFormat, quality?: number)Get the base64 of image.
toImage()Get a snapshot from the canvas in the surface.
toSvg(width: number, height: number, backgroundColor?: string)Get the svg string of all paths.
toPoints()Get the array of point groups that got drawn in the canvas.
addPoints(points: [x, y][][])Draws from an array of point groups.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Inspired By

Please check out these previous works that helped inspire the creation of rn-perfect-sketch-canvas.

License

MIT