• Stars
    star
    10
  • Rank 1,807,489 (Top 36 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript library for editing curves

D3 Curve Editor Build Status

JavaScript library for editing curves

curve editor

Usage

Include it in your html:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/d3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/d3-curve-editor.min.js"></script>
<link  href="https://cdn.jsdelivr.net/npm/[email protected]/build/d3-curve-editor.css" rel="stylesheet" type="text/css"></link>

Or install from NPM

import * as D3CE from 'd3-curve-editor';

Create SVG container

<svg tabindex="1" id="editor"></svg>

Add lines

var lines = [];
lines.push(new D3CE.Line("#47a",[
                     new D3CE.CurvePoint(0,0).isFixed(true),
                    new D3CE.CurvePoint(1,1)
            ]));
lines.push(new D3CE.Line("#fd3",[
                    new D3CE.CurvePoint(0.2,0),
                    new D3CE.CurvePoint(1,0.4)
            ]));

Initialize editor

var container = querySelector('#editor');

var editor = new D3CE.CurveEditor(container,lines,{curve: d3.curveCatmullRom});
editor.eventListener.on('change',()=>{});

For details see demo

Dependencies

License

MIT