mirror of
https://github.com/rough-stuff/rough.git
synced 2026-01-19 19:29:17 -05:00
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
import { RoughGenerator } from './generator';
|
|
import { RoughSVGBase } from './svg-base';
|
|
export class RoughSVG extends RoughSVGBase {
|
|
constructor(svg, config) {
|
|
super(svg);
|
|
this.gen = new RoughGenerator(config || null, this.svg);
|
|
}
|
|
get generator() {
|
|
return this.gen;
|
|
}
|
|
getDefaultOptions() {
|
|
return this.gen.defaultOptions;
|
|
}
|
|
opsToPath(drawing) {
|
|
return this.gen.opsToPath(drawing);
|
|
}
|
|
line(x1, y1, x2, y2, options) {
|
|
const d = this.gen.line(x1, y1, x2, y2, options);
|
|
return this.draw(d);
|
|
}
|
|
rectangle(x, y, width, height, options) {
|
|
const d = this.gen.rectangle(x, y, width, height, options);
|
|
return this.draw(d);
|
|
}
|
|
ellipse(x, y, width, height, options) {
|
|
const d = this.gen.ellipse(x, y, width, height, options);
|
|
return this.draw(d);
|
|
}
|
|
circle(x, y, diameter, options) {
|
|
const d = this.gen.circle(x, y, diameter, options);
|
|
return this.draw(d);
|
|
}
|
|
linearPath(points, options) {
|
|
const d = this.gen.linearPath(points, options);
|
|
return this.draw(d);
|
|
}
|
|
polygon(points, options) {
|
|
const d = this.gen.polygon(points, options);
|
|
return this.draw(d);
|
|
}
|
|
arc(x, y, width, height, start, stop, closed = false, options) {
|
|
const d = this.gen.arc(x, y, width, height, start, stop, closed, options);
|
|
return this.draw(d);
|
|
}
|
|
curve(points, options) {
|
|
const d = this.gen.curve(points, options);
|
|
return this.draw(d);
|
|
}
|
|
path(d, options) {
|
|
const drawing = this.gen.path(d, options);
|
|
return this.draw(drawing);
|
|
}
|
|
}
|