프로젝트
GitHub에서 보기
iddan/react-native-canvas
소개
React Native용 Canvas 컴포넌트
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- -2
- in 15 days
- -3
- in 1 month
- -2
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Original🎆 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';
const App = () => {
const handleCanvas = (canvas) => {
if (!canvas) return;
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'purple';
ctx.fillRect(0, 0, 100, 100);
};
return (
<Canvas ref={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);
관련 프로젝트 살펴보기
불러오는 중…