jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.29k stars 454 forks source link

Added Two.Arc #638

Closed jonobr1 closed 2 years ago

jonobr1 commented 2 years ago

Resolves this issue: https://github.com/jonobr1/two.js/issues/605

By adding a Two.Arc class to /extras. You can use like so:

import { Arc } from 'two.js/extras/jsm/arc.js';
const x = two.width / 2;
const y = two.height / 2;
const width = 50;
const height = 33;
const startAngle = 0;
const endAngle = Math.PI * 0.5;
const arc = new Arc(x, y, width, height, startAngle, endAngle);
two.add(arc); // Don't forget to add it to a scene!

and it has the same properties as any Two.Path:

arc.fill = 'red';
arc.dashes = [5, 2];
arc.stroke = 'black';
arc.linewidth = 1;
arc.scale = 5;