Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rax-canvas

Package Overview
Dependencies
Maintainers
5
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rax-canvas

canvas for Rax.

  • 1.0.0-beta.3
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-16.67%
Maintainers
5
Weekly downloads
 
Created
Source

npm 描述: Rax canvas api.

在weex上依赖 gcanvas 在小程序中依赖 canvas 在weex和h5中需要通过ref获取canvas实例,在小程序中需要通过id获取

安装

$ npm install rax-canvas --save

引用

import Canvas from 'rax-canvas';

属性

注: 1、支持列表中的 browser代表h5 weex代表weex miniApp代表小程序

属性类型默认值必填描述支持
styleobject-true通过style中的width和height指定canvas的高、宽browser weexminiApp

方法

获取到canvas示例后,具备canvas的通用方法

示例

在线 Demo

import { createElement, Component, render, createRef } from 'rax';
import Canvas from 'rax-canvas';
import DU from "driver-universal"

class CanvasSample extends Component {
  constructor(props) {
    super(props);
    this.raxCanvasDemo = createRef()
  }
  componentDidMount() {
    const context = this.raxCanvasDemo.current.getContext();
    context.fillStyle = 'red';
    context.fillRect(0, 0, 100, 100);
  }

  render() {
    return <Canvas style={{
      width: 750,
      height: 750
    }} ref={this.raxCanvasDemo} />;
  }
}

render(<CanvasSample />, document.body, { driver: DU });

Keywords

FAQs

Package last updated on 29 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc