Skip to content

dekrain/path-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Path2D Parser

A parser for HTML5 Path2D Canvas object.

Installation

git clone [email protected]:dekrain/path-parser.git

How to use

On node.js

const Path2DParser = require('path-parser');
const f = Path2DParser(code);
// or
const f = Path2DParser.open(path);

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

In browser

<canvas id="cnv"></canvas>
<script src="path/to/path-parser.js"></script>
<script>
var path = Path2DParser(code);
var cnv = document.getElementById('cnv');
var ctx = cnv.getContext('2d')

ctx.fill(path);
// or
ctx.stroke(path);
</script>

Syntax highlighting

#!/usr/bin/env node
console.log(Path2DParser.format(code))

Screen: https://raw.githubusercontent.com/dekrain/path-parser/master/screen-node.png

More informations

var inf = Path2DParser(code, true);
var tokens = inf.tokens;
var AST = inf.ast;

var path = inf.result; // Browser
// or
var f = inf.result; // Node.js

About

A parser for my Path2D format (*.path)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published