• Stars
    star
    983
  • Rank 46,580 (Top 1.0 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Canvas component for React Native

react-native-canvas

A Canvas component for React Native

npm install react-native-webview
react-native link react-native-webview
npm install react-native-canvas

Usage

import React, { Component } from 'react';
import Canvas from 'react-native-canvas';

class App extends Component {

  handleCanvas = (canvas) => {
    const ctx = canvas.getContext('2d');
    ctx.fillStyle = 'purple';
    ctx.fillRect(0, 0, 100, 100);
  }

  render() {
    return (
      <Canvas ref={this.handleCanvas}/>
    )
  }
}

API

Canvas

Canvas#height

Reflects the height of the canvas in pixels

Canvas#width

Reflects the width of the canvas in pixels

Canvas#getContext()

Returns a canvas rendering context. Currently only supports 2d context.

Canvas#toDataURL()

Returns a Promise that resolves to DataURL.

CanvasRenderingContext2D

Standard CanvasRenderingContext2D. MDN. Only difference is await should be used to retrieve values from methods.

const ctx = canvas.getContext('2d');

Image

WebView Image constructor. Unlike in the browsers accepts canvas as first argument. MDN

const image = new Image(canvas, height, width);

Path2D

Path2D API constructor. Unlike in the browsers, this requires the canvas as first argument. See also https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D.

const path = new Path2D(canvas);

More Repositories

1

react-spreadsheet

Simple, customizable yet performant spreadsheet for React
TypeScript
1,261
star
2

stylesheet

Dynamic CSS for user interfaces
JavaScript
42
star
3

proposal-function-expression-decorators

Decorators support for function expressions
HTML
26
star
4

plot-react

React wrapper for @observablehq/plot
TypeScript
19
star
5

react-universal-markdown

Markdown component for Web and Native powered by CommonMark
JavaScript
11
star
6

delux

Beautiful, light and simple state manager inspired by Redux
JavaScript
5
star
7

autobabel

Transform ES6 and JSX files into ES5 automatically using Babel
JavaScript
5
star
8

jsx-template

Static template engine based on the JSX Specification
JavaScript
5
star
9

kupot

TypeScript
4
star
10

react-keen

React bindings for Keen IO SDK
JavaScript
4
star
11

progress-circle

Circular progress bar made with React, SVG and CSS transitions.
JavaScript
3
star
12

freshdev

Autoreloads unpacked Chrome extensions
CSS
3
star
13

flow-imports

POC for import following Flowtype checks
JavaScript
3
star
14

cypher_query_builder

Python Query builder for Cypher, the graph query language
Python
2
star
15

figma-rtl

RTL Plugin for Figma
JavaScript
2
star
16

express-jwt-users

JWT user authentication router
JavaScript
2
star
17

shepard-tone

Web Audio implementation of Shepard Tone
TypeScript
2
star
18

python-flame-chart

Python Profiling Flame Chart Viewer
JavaScript
1
star
19

site

Personal site
TypeScript
1
star
20

react-diagrams

Declarative version of storm-react-diagrams
JavaScript
1
star
21

minerva

The Knowledge Store
Rust
1
star
22

google-mymaps-to-markdown

Transforms your map into a locations list
JavaScript
1
star
23

react-giphy

React components for GIPHY
JavaScript
1
star
24

editor

Github Pages editor
JavaScript
1
star
25

express-native-promise-router

Promise compatible Express Router
JavaScript
1
star
26

enormis

Simple modern MongoDB driver
JavaScript
1
star
27

flatShadow

Add long flat shadows to text using JavaScript
JavaScript
1
star
28

react-google-login

Get users into your apps quickly and securely, using a registration system they already use and trust -- their Google account with React
JavaScript
1
star
29

gcp-functions-deploy-test

Test repository for demonstrating a problem with deploying to GCP functions
JavaScript
1
star
30

git-publish

Publish packages as Git tags instead of to NPM
JavaScript
1
star
31

whatsapp-chat-viewer

Web chat viewer for exported WhatsApp chats
JavaScript
1
star
32

expo-2d-context-test

TypeScript
1
star
33

google-maps-list-filler

JavaScript
1
star
34

create-react-library

Create React libraries with no configuration.
JavaScript
1
star
35

delux-fetch

Fetch middleware for Delux
JavaScript
1
star
36

excel-formula-to-form

Convert Excel formulas to an HTML form
JavaScript
1
star