1.0.9 • Published 2 years ago

react-native-vexflow-canvas v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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.

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago