1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// use crate::Point;
// use super::{Config, Options, OpSet, ResolvedOptions, Drawable, SVGNS, RoughGenerator };
// pub struct RoughSVG {
// gen: RoughGenerator,
// svg: SVGSVGElement,
// }
// impl RoughSVG {
// pub fn new(svg: SVGSVGElement, config: Config) -> Self {
// Self {
// svg,
// gen: RoughGenerator::new(config)
// }
// }
// pub fn draw(&self, drawable: Drawable) -> SVGGElement {
// // let sets = drawable.sets || [];
// // let o = drawable.options || self.getDefaultOptions();
// // let doc = self.svg.ownerDocument || window.document;
// // let g = doc.createElementNS(SVGNS, 'g');
// // for (let drawing of sets) {
// // let path = null;
// // switch (drawing.type) {
// // case 'path': {
// // path = doc.createElementNS(SVGNS, 'path');
// // path.setAttribute('d', self.opsToPath(drawing));
// // path.setAttribute('stroke', o.stroke);
// // path.setAttribute('stroke-width', o.strokeWidth + '');
// // path.setAttribute('fill', 'none');
// // if (o.strokeLineDash) {
// // path.setAttribute('stroke-dasharray', o.strokeLineDash.join(' ').trim());
// // }
// // if (o.strokeLineDashOffset) {
// // path.setAttribute('stroke-dashoffset', `${o.strokeLineDashOffset}`);
// // }
// // break;
// // }
// // case 'fillPath': {
// // path = doc.createElementNS(SVGNS, 'path');
// // path.setAttribute('d', self.opsToPath(drawing));
// // path.setAttribute('stroke', 'none');
// // path.setAttribute('stroke-width', '0');
// // path.setAttribute('fill', o.fill || '');
// // if (drawable.shape === 'curve' || drawable.shape === 'polygon') {
// // path.setAttribute('fill-rule', 'evenodd');
// // }
// // break;
// // }
// // case 'fillSketch': {
// // path = self.fillSketch(doc, drawing, o);
// // break;
// // }
// // }
// // if (path) {
// // g.appendChild(path);
// // }
// // }
// // return g;
// }
// fn fill_sketch(&self, doc: Document, drawing: OpSet, o: ResolvedOptions) -> SVGPathElement {
// // let fweight = o.fillWeight;
// // if (fweight < 0) {
// // fweight = o.strokeWidth / 2;
// // }
// // let path = doc.createElementNS(SVGNS, 'path');
// // path.setAttribute('d', self.opsToPath(drawing));
// // path.setAttribute('stroke', o.fill || '');
// // path.setAttribute('stroke-width', fweight + '');
// // path.setAttribute('fill', 'none');
// // if (o.fillLineDash) {
// // path.setAttribute('stroke-dasharray', o.fillLineDash.join(' ').trim());
// // }
// // if (o.fillLineDashOffset) {
// // path.setAttribute('stroke-dashoffset', `${o.fillLineDashOffset}`);
// // }
// // return path;
// }
// pub fn get_generator(&self) -> RoughGenerator {
// // self.gen
// unimplemented!()
// }
// pub fn get_default_options(&self) -> ResolvedOptions {
// // self.gen.defaultOptions
// unimplemented!()
// }
// pub fn ops_to_path(&self, drawing: OpSet) -> String {
// // self.gen.opsToPath(drawing)
// unimplemented!()
// }
// pub fn line(&self, x1: f64, y1: f64, x2: f64, y2: f64, options: Options) -> SVGGElement {
// // let d = self.gen.line(x1, y1, x2, y2, options);
// // self.draw(d)
// unimplemented!()
// }
// pub fn rectangle(&self, x: f64, y: f64, width: f64, height: f64, options: Options) -> SVGGElement {
// // let d = self.gen.rectangle(x, y, width, height, options);
// // self.draw(d)
// unimplemented!()
// }
// pub fn ellipse(&self, x: f64, y: f64, width: f64, height: f64, options: Options) -> SVGGElement {
// // let d = self.gen.ellipse(x, y, width, height, options);
// // self.draw(d)
// unimplemented!()
// }
// pub fn circle(&self, x: f64, y: f64, diameter: f64, options: Options) -> SVGGElement {
// let d = self.gen.circle(x, y, diameter, options);
// self.draw(d)
// }
// pub fn linear_path(&self, points: Vec<Point>, options: Options) -> SVGGElement {
// let d = self.gen.linearPath(points, options);
// self.draw(d)
// }
// pub fn polygon(&self, points: Vec<Point>, options: Options) -> SVGGElement {
// let d = self.gen.polygon(points, options);
// self.draw(d)
// }
// pub fn arc(&self, x: f64, y: f64, width: f64, height: f64, start: f64, stop: f64, closed: bool, options: Options) -> SVGGElement {
// // closed: boolean = false
// let d = self.gen.arc(x, y, width, height, start, stop, closed, options);
// self.draw(d)
// }
// pub fn curve(&self, points: Vec<Point>, options: Options) -> SVGGElement {
// let d = self.gen.curve(points, options);
// self.draw(d)
// }
// pub fn path(&self, d: &str, options: Options) -> SVGGElement {
// let drawing = self.gen.path(d, options);
// self.draw(drawing)
// }
// }