|
106 | 106 | ),
|
107 | 107 | ),
|
108 | 108 | ),
|
| 109 | + distal: ( |
| 110 | + tick: ( |
| 111 | + flip: true, |
| 112 | + label: ( |
| 113 | + anchor: "east", |
| 114 | + ) |
| 115 | + ) |
| 116 | + ), |
109 | 117 | )
|
110 | 118 |
|
111 | 119 | /// Default schoolbook style
|
|
160 | 168 |
|
161 | 169 |
|
162 | 170 | ///
|
163 |
| -#let cartesian-scientific(projections: none, style: (:)) = { |
| 171 | +#let cartesian-scientific(projections: none, name: none, style: (:)) = { |
164 | 172 | return (
|
165 |
| - name: none, |
| 173 | + name: name, |
166 | 174 | draw: (ptx) => {
|
167 | 175 | let proj = projections.at(0)
|
168 | 176 | let axes = proj.axes
|
|
224 | 232 | }
|
225 | 233 |
|
226 | 234 | ///
|
227 |
| -#let schoolbook(projections: none, zero: (0, 0), ..style) = { |
| 235 | +#let schoolbook(projections: none, name: none, zero: (0, 0), ..style) = { |
228 | 236 | return (
|
229 |
| - name: none, |
| 237 | + name: name, |
230 | 238 | draw: (ptx) => {
|
231 | 239 | let proj = projections.at(0)
|
232 | 240 | let axes = proj.axes
|
|
288 | 296 | }
|
289 | 297 | )
|
290 | 298 | }
|
| 299 | + |
| 300 | +/// Polar frame |
| 301 | +#let polar(projections: none, name: none, ..style) = { |
| 302 | + assert(projections.len() == 1, |
| 303 | + message: "Unexpected number of projections!") |
| 304 | + |
| 305 | + return ( |
| 306 | + name: name, |
| 307 | + draw: (ptx) => { |
| 308 | + let proj = projections.first() |
| 309 | + let angular = proj.axes.at(0) |
| 310 | + let distal = proj.axes.at(1) |
| 311 | + |
| 312 | + let (origin, outer) = (proj.transform)((0, distal.min), (0, distal.max)) |
| 313 | + let radius = vector.dist(origin, outer) |
| 314 | + |
| 315 | + let style = _prepare-style(ptx, cetz.styles.resolve(ptx.cetz-ctx.style, |
| 316 | + root: "axes", merge: style.named(), base: default-style)) |
| 317 | + let angular-style = _get-axis-style(ptx, style, "angular") |
| 318 | + let distal-style = _get-axis-style(ptx, style, "distal") |
| 319 | + |
| 320 | + let r-start = origin |
| 321 | + let r-end = vector.add(origin, (0, radius)) |
| 322 | + draw.line(r-start, r-end, stroke: distal-style.stroke) |
| 323 | + if "computed-ticks" in distal { |
| 324 | + //ticks.draw-cartesian-grid(min-y, max-y, 1, y, y.computed-ticks, min-x, max-x, y-style) |
| 325 | + ticks.draw-cartesian(r-start, r-end, distal.computed-ticks, distal-style) |
| 326 | + } |
| 327 | + |
| 328 | + let padding = angular-style.padding.first() |
| 329 | + draw.circle(origin, radius: radius + padding, |
| 330 | + stroke: angular-style.stroke) |
| 331 | + if "computed-ticks" in angular { |
| 332 | + // TODO |
| 333 | + } |
| 334 | + }, |
| 335 | + ) |
| 336 | +} |
0 commit comments