🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

react-native-vexflow-canvas

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-vexflow-canvas

Canvas Element & SVGContext for using VexFlow in React Native.

1.0.9
latest
Source
npm
Version published
Weekly downloads
16
-27.27%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-vexflow-canvas 🎇

This a simple package that enables using VexFlow in React Native. Below, you can find an example on how to use VexCanvas. If you like, you can also read the small documentation which is also down below.

Example usage:

import VexCanvas from "react-native-vexflow-canvas";

// some other imports... 

const MyVexView = () => {
    const draw = (ref) => {
        const context = ref.getContext(); // get the context from the canvas.
        context.clear(); // To have a clean canvas in every render.

        /*
            Your VexFlow Code After Here
        */

        const stave = new Stave(0, 0, 250, 250);

        stave.setContext(context);
        stave.draw();
    };

    return (<View>
                <VexCanvas
                    draw={draw} // this prop allows access to Canvas, and thus the context. Pass a function to it.
                ></VexCanvas>
            </View>
    );
};

Documentation 📑

The package provides two main utilities: VexCanvas and RNVexFlowSVGContext.

VexCanvas

PropDescripton 
widthwidth of the canvas.
heightheight of the canvas.
drawcallback function which takes a reference to canvas. you can use it to access the context.
MethodDescripton 
getContext()returns the context (RNVexFlowSVGContext).

RNVexFlowSVGContext

This is a class that VexFlow will use to create a SVG element (react-native-svg).

MethodDescripton 
render()returns a React element that is filled with correct SVG elements (like text, path etc.)

There are other methods of RNVexFlowSVGContext that are only used by VexFlow to fill the canvas. You can check them out in the source code.

Keywords

VexFlow

FAQs

Package last updated on 26 Sep 2022

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