Skip to content

Commit 1df7060

Browse files
Release 0.0.2 (#103)
* bump version * lib: Expose version constant * doc: Mention version in manual * doc: Various fixes and additions * chart: Remove dead code
1 parent 989304b commit 1df7060

14 files changed

+145
-161
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ For information, see the [manual](manual.pdf?raw=true).
5656

5757
To use this package, simply add the following code to your document:
5858
```
59-
#import "@preview/cetz:0.0.1"
59+
#import "@preview/cetz:0.0.2"
6060
6161
#cetz.canvas({
6262
import cetz.draw: *
@@ -75,7 +75,7 @@ just install
7575
The installed version can be imported by prefixing the package name with `@local`.
7676

7777
```typ
78-
#import "@local/cetz:0.0.1"
78+
#import "@local/cetz:0.0.2"
7979
8080
#cetz.canvas({
8181
import cetz.draw: *

draw.typ

+6-6
Original file line numberDiff line numberDiff line change
@@ -780,14 +780,14 @@
780780
),)
781781
}
782782

783-
/// NOTE: This function is supposed to be REPLACED by a
784-
/// new coordinate syntax!
785-
///
786783
/// Create anchors along a path
787784
///
785+
/// NOTE: This function is supposed to be replaced by a
786+
/// new coordinate syntax!
787+
///
788788
/// - path (path): Path
789-
/// - anchors (positional): Dictionaries of the format:
790-
/// (name: string, pos: float)
789+
/// - anchors (positional): List of dictionaries of the format:
790+
/// `(name: string, pos: float)`, where pos is in range [0, 1].
791791
/// - name (string): Element name, uses paths name, if auto
792792
#let place-anchors(path, ..anchors, name: auto) = {
793793
let name = if name == auto and "name" in path.first() {
@@ -866,7 +866,7 @@
866866
),)
867867
}
868868

869-
/// Emit on anchor per intersection of all elements
869+
/// Emit one anchor per intersection of all elements
870870
/// inside body.
871871
///
872872
/// - body (elements): Element body

gallery/3d-chart.typ

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "@local/cetz:0.0.1": canvas, draw
1+
#import "@local/cetz:0.0.2": canvas, draw
22

33
#set page(width: auto, height: auto, margin: .5cm)
44

gallery/barchart.typ

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "@local/cetz:0.0.1": canvas, chart
1+
#import "@local/cetz:0.0.2": canvas, chart
22

33
#set page(width: auto, height: auto, margin: .5cm)
44

gallery/karls-picture.typ

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "@local/cetz:0.0.1"
1+
#import "@local/cetz:0.0.2"
22

33
#set page(width: auto, height: auto, margin: .5cm)
44

gallery/plot.typ

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "@local/cetz:0.0.1": canvas, plot
1+
#import "@local/cetz:0.0.2": canvas, plot
22

33
#set page(width: auto, height: auto, margin: .5cm)
44

gallery/tree.typ

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "@local/cetz:0.0.1": canvas, draw, tree
1+
#import "@local/cetz:0.0.2": canvas, draw, tree
22

33
#set page(width: auto, height: auto, margin: .5cm)
44

lib.typ

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#let version = (0,0,2)
2+
13
#import "canvas.typ": canvas
24
#import "draw.typ"
35
#import "coordinate.typ"

lib/chart.typ

-101
Original file line numberDiff line numberDiff line change
@@ -367,104 +367,3 @@
367367
}
368368
})
369369
}
370-
371-
#let radarchart(data,
372-
labels: none,
373-
value-key: auto,
374-
mode: "basic",
375-
size: 1,
376-
step: auto,
377-
data-style: palette.red) = {
378-
import draw: *
379-
380-
if value-key == auto {
381-
if data.len() > 0 {
382-
value-key = (..range(data.first().len()))
383-
}
384-
}
385-
386-
if type(size) != "array" {
387-
size = (size, size)
388-
}
389-
390-
assert(type(value-key) == "array",
391-
message: "Argument value-key must be of type array")
392-
assert(value-key.len() >= 2,
393-
message: "Data needs to have at least 2 dimensions")
394-
395-
let num-axes = value-key.len()
396-
397-
let max-value = calc.max(..data.map(
398-
t => calc.max(..value-key.map(k => t.at(k)))))
399-
400-
let axis-list = (
401-
for n in range(num-axes) {
402-
((
403-
key: value-key.at(n),
404-
translate: (v) => {
405-
let angle = 90deg - 360deg / num-axes * n
406-
(v * calc.cos(angle), v * calc.sin(angle))
407-
}
408-
),)
409-
}
410-
)
411-
412-
if step == auto {
413-
step = axes.find-max-n-ticks(0, max-value, n: 7)
414-
if step == none {
415-
step = max-value / 7
416-
}
417-
}
418-
let num-steps = int(max-value / step)
419-
420-
if type(data-style) != "function" {
421-
data-style = (i) => { data-style }
422-
}
423-
424-
group(ctx => {
425-
let style = util.merge-dictionary(radarchart-default-style,
426-
styles.resolve(ctx.style, (:), root: "radarchart"))
427-
428-
set-viewport((0, 0), size, bounds: (2 * max-value, 2 * max-value, 1))
429-
translate((max-value, max-value, 0))
430-
431-
let scaling = (size.at(0) / (2 * max-value), size.at(1) / (2 * max-value))
432-
433-
for i in range(axis-list.len()) {
434-
line((0, 0), (axis-list.at(i).translate)(max-value), ..style.grid)
435-
436-
for n in range(num-steps + 1) {
437-
let v = step * n
438-
line((axis-list.at(calc.rem(i - 1, num-axes)).translate)(v),
439-
(axis-list.at(i).translate)(v), ..style.grid)
440-
}
441-
}
442-
443-
for n in range(num-steps + 1) {
444-
let v = step * n
445-
content((axis-list.at(0).translate)(v), $#v$,
446-
anchor: "bottom-right",
447-
padding: style.label-padding / scaling.at(0))
448-
}
449-
450-
let enum-keys = value-key.enumerate()
451-
for (i, item) in data.enumerate() {
452-
let pts = enum-keys.map(
453-
((i, k)) => (axis-list.at(i).translate)(item.at(k)))
454-
455-
let item-style = util.merge-dictionary(style, data-style(i))
456-
let mark-radius = (
457-
item-style.mark.size / scaling.at(0),
458-
item-style.mark.size / scaling.at(1)
459-
)
460-
461-
// Fill data polygon
462-
//line(..pts, close: true, ..item-style)
463-
464-
// Draw data points
465-
for pt in pts {
466-
circle(pt, ..item-style.mark, radius: mark-radius)
467-
}
468-
}
469-
})
470-
}

manual.pdf

9.86 KB
Binary file not shown.

0 commit comments

Comments
 (0)