npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

expo-perfect-canvas

v1.0.2

Published

High-performance React Native drawing canvas with perfect-freehand and haptic feedback

Readme

Expo Perfect Canvas

A high-performance React Native drawing canvas with perfect-freehand integration, haptic feedback, and modern gesture handling.

Features

  • 🎨 Perfect Freehand Integration - Natural, pressure-sensitive strokes
  • 📱 Haptic Feedback - Enhanced drawing experience with Expo Haptics
  • 🚀 High Performance - Optimized with React Native Skia and Reanimated
  • 🔄 Undo/Redo - Full history management
  • 🔍 Zoom & Pan - Optional multi-touch gestures
  • 📐 Path Simplification - Automatic optimization for better performance
  • 💾 Export Options - SVG, Base64, and image snapshots
  • 🎯 TypeScript - Full type safety

Installation

npm install expo-perfect-canvas

# Required peer dependencies
npm install @shopify/react-native-skia react-native-gesture-handler react-native-reanimated expo-haptics perfect-freehand

Or with yarn:

yarn add expo-perfect-canvas

# Required peer dependencies  
yarn add @shopify/react-native-skia react-native-gesture-handler react-native-reanimated expo-haptics perfect-freehand

iOS Setup

cd ios && pod install

Basic Usage

import React, { useRef } from 'react';
import { View, Button } from 'react-native';
import { PerfectCanvas } from 'expo-perfect-canvas';

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

  return (
    <View style={{ flex: 1 }}>
      <PerfectCanvas
        ref={canvasRef}
        strokeColor="#000000"
        strokeWidth={8}
        enableHaptics={true}
        hapticStyle="light"
      />
      <Button
        title="Undo"
        onPress={() => canvasRef.current?.undo()}
      />
    </View>
  );
}

Advanced Usage

import React, { useRef, useState } from 'react';
import { View, Button } from 'react-native';
import { PerfectCanvas } from 'expo-perfect-canvas';

export default function AdvancedCanvas() {
  const canvasRef = useRef(null);
  const [color, setColor] = useState('#000000');
  const [width, setWidth] = useState(8);

  const handleExport = async () => {
    const base64 = await canvasRef.current?.toBase64();
    console.log('Exported:', base64);
  };

  return (
    <View style={{ flex: 1 }}>
      <PerfectCanvas
        ref={canvasRef}
        strokeColor={color}
        strokeWidth={width}
        strokeOpacity={0.9}
        strokeOptions={{
          thinning: 0.5,
          smoothing: 0.5,
          streamline: 0.5,
        }}
        enableHaptics={true}
        hapticStyle="medium"
        enableZoom={true}
        zoomRange={[0.5, 3]}
        simplifyPaths={true}
        simplifyTolerance={2}
        onDrawEnd={(path) => console.log('Path completed:', path)}
        backgroundColor="#f0f0f0"
      />
      
      <View style={{ flexDirection: 'row', padding: 10 }}>
        <Button title="Undo" onPress={() => canvasRef.current?.undo()} />
        <Button title="Redo" onPress={() => canvasRef.current?.redo()} />
        <Button title="Clear" onPress={() => canvasRef.current?.clear()} />
        <Button title="Export" onPress={handleExport} />
      </View>
    </View>
  );
}

API Reference

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | strokeColor | string | 'black' | Stroke color | | strokeWidth | number | 8 | Stroke width | | strokeOpacity | number | 1 | Stroke opacity (0-1) | | strokeOptions | StrokeOptions | {} | Perfect-freehand options | | enableHaptics | boolean | true | Enable haptic feedback | | hapticStyle | 'light' \| 'medium' \| 'heavy' | 'light' | Haptic feedback intensity | | enableZoom | boolean | false | Enable pinch zoom | | zoomRange | [number, number] | [0.5, 3] | Min and max zoom levels | | simplifyPaths | boolean | true | Simplify paths for performance | | simplifyTolerance | number | 1 | Path simplification tolerance | | backgroundColor | string | 'white' | Canvas background color | | onDrawStart | () => void | - | Called when drawing starts | | onDrawEnd | (path: PathData) => void | - | Called when drawing ends |

Methods (via ref)

| Method | Description | |--------|-------------| | undo(steps?: number) | Undo last action(s) | | redo(steps?: number) | Redo action(s) | | clear() | Clear canvas | | reset() | Reset canvas and history | | getSnapshot() | Get image snapshot | | toBase64(format?, quality?) | Export as base64 | | toSvg(width?, height?, bgColor?) | Export as SVG | | getPaths() | Get all paths | | setPaths(paths) | Set paths | | setStrokeColor(color) | Change stroke color | | setStrokeWidth(width) | Change stroke width | | setStrokeOpacity(opacity) | Change stroke opacity | | setBackgroundColor(color) | Change canvas background color | | setEnableHaptics(enabled) | Enable/disable haptic feedback | | setHapticStyle(style) | Change haptic feedback style |

Performance Tips

  1. Enable path simplification for better performance with complex drawings
  2. Adjust simplifyTolerance based on your needs (higher = fewer points)
  3. Use onDemand render mode for static drawings
  4. Limit history size with maxHistorySize prop
  5. Disable haptics if not needed for better performance

Author

Jan Horak

License

MIT