1 | <?php |
||
10 | class SvgBuilder implements PlotBuilder |
||
11 | { |
||
12 | /** |
||
13 | * Current position. |
||
14 | */ |
||
15 | protected $x = 0; |
||
16 | protected $y = 0; |
||
17 | |||
18 | /** |
||
19 | * Extent of drawing |
||
20 | */ |
||
21 | protected $maxX = 0; |
||
22 | protected $maxY = 0; |
||
23 | |||
24 | protected $instructions = []; |
||
25 | |||
26 | protected $axesFlipped = false; |
||
27 | protected $penIsDown = true; |
||
28 | protected $tool = 'regular'; |
||
29 | protected $unit = 'mm'; |
||
30 | protected $scale = 0.1; |
||
31 | |||
32 | /** |
||
33 | * Adds a new plot of x and y to machine instructions. |
||
34 | */ |
||
35 | public function plot(int $x, int $y): PlotBuilder |
||
63 | |||
64 | /** |
||
65 | * Changes the pen of the plotter. |
||
66 | */ |
||
67 | public function changePen(int $pen): PlotBuilder |
||
71 | |||
72 | /** |
||
73 | * Compiles a string in target format with machine instructions. |
||
74 | */ |
||
75 | public function compile(): string |
||
102 | |||
103 | /** |
||
104 | * Pushes a command to the instructions. |
||
105 | */ |
||
106 | public function pushCommand(string $command): PlotBuilder |
||
110 | |||
111 | /** |
||
112 | * Lifts the pen up. |
||
113 | */ |
||
114 | public function penUp(): PlotBuilder |
||
120 | |||
121 | /** |
||
122 | * Pushes the pen down on paper. |
||
123 | */ |
||
124 | public function penDown(): PlotBuilder |
||
130 | |||
131 | /** |
||
132 | * Changes the plotter pen to use flexcut. |
||
133 | */ |
||
134 | public function flexCut(): PlotBuilder |
||
140 | |||
141 | /** |
||
142 | * Change to the regular plotter pen. |
||
143 | */ |
||
144 | public function regularCut(): PlotBuilder |
||
150 | |||
151 | /** |
||
152 | * Changes the pen pressure in gram. |
||
153 | */ |
||
154 | public function pressure(int $gramPressure): PlotBuilder |
||
158 | |||
159 | /** |
||
160 | * Specifies measuring unit. |
||
161 | * 1 selects 0.001 inch |
||
162 | * 5 selects 0.005 inch |
||
163 | * M selects 0.1 mm |
||
164 | */ |
||
165 | public function setMeasuringUnit($unit): PlotBuilder |
||
186 | |||
187 | /** |
||
188 | * Changes the plotter velocity. |
||
189 | */ |
||
190 | public function velocity(int $velocity): PlotBuilder |
||
194 | |||
195 | /** |
||
196 | * Flips the x, y coordinates. |
||
197 | */ |
||
198 | public function flipAxes(): PlotBuilder |
||
204 | |||
205 | /** |
||
206 | * Cuts off paper when a operation finishes. |
||
207 | */ |
||
208 | public function cutOff(): PlotBuilder |
||
212 | |||
213 | protected function pushInstruction(string $name, array $parameters): PlotBuilder |
||
223 | |||
224 | } |
||
225 |