Skip to content

Commit

Permalink
Release 0.0.2 (#103)
Browse files Browse the repository at this point in the history
* bump version

* lib: Expose version constant

* doc: Mention version in manual

* doc: Various fixes and additions

* chart: Remove dead code
  • Loading branch information
johannes-wolf authored Jul 31, 2023
1 parent 989304b commit 1df7060
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 161 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ For information, see the [manual](manual.pdf?raw=true).

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

```typ
#import "@local/cetz:0.0.1"
#import "@local/cetz:0.0.2"
#cetz.canvas({
import cetz.draw: *
Expand Down
12 changes: 6 additions & 6 deletions draw.typ
Original file line number Diff line number Diff line change
Expand Up @@ -780,14 +780,14 @@
),)
}

/// NOTE: This function is supposed to be REPLACED by a
/// new coordinate syntax!
///
/// Create anchors along a path
///
/// NOTE: This function is supposed to be replaced by a
/// new coordinate syntax!
///
/// - path (path): Path
/// - anchors (positional): Dictionaries of the format:
/// (name: string, pos: float)
/// - anchors (positional): List of dictionaries of the format:
/// `(name: string, pos: float)`, where pos is in range [0, 1].
/// - name (string): Element name, uses paths name, if auto
#let place-anchors(path, ..anchors, name: auto) = {
let name = if name == auto and "name" in path.first() {
Expand Down Expand Up @@ -866,7 +866,7 @@
),)
}

/// Emit on anchor per intersection of all elements
/// Emit one anchor per intersection of all elements
/// inside body.
///
/// - body (elements): Element body
Expand Down
2 changes: 1 addition & 1 deletion gallery/3d-chart.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@local/cetz:0.0.1": canvas, draw
#import "@local/cetz:0.0.2": canvas, draw

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

Expand Down
2 changes: 1 addition & 1 deletion gallery/barchart.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@local/cetz:0.0.1": canvas, chart
#import "@local/cetz:0.0.2": canvas, chart

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

Expand Down
2 changes: 1 addition & 1 deletion gallery/karls-picture.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@local/cetz:0.0.1"
#import "@local/cetz:0.0.2"

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

Expand Down
2 changes: 1 addition & 1 deletion gallery/plot.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@local/cetz:0.0.1": canvas, plot
#import "@local/cetz:0.0.2": canvas, plot

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

Expand Down
2 changes: 1 addition & 1 deletion gallery/tree.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@local/cetz:0.0.1": canvas, draw, tree
#import "@local/cetz:0.0.2": canvas, draw, tree

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

Expand Down
2 changes: 2 additions & 0 deletions lib.typ
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#let version = (0,0,2)

#import "canvas.typ": canvas
#import "draw.typ"
#import "coordinate.typ"
Expand Down
101 changes: 0 additions & 101 deletions lib/chart.typ
Original file line number Diff line number Diff line change
Expand Up @@ -367,104 +367,3 @@
}
})
}

#let radarchart(data,
labels: none,
value-key: auto,
mode: "basic",
size: 1,
step: auto,
data-style: palette.red) = {
import draw: *

if value-key == auto {
if data.len() > 0 {
value-key = (..range(data.first().len()))
}
}

if type(size) != "array" {
size = (size, size)
}

assert(type(value-key) == "array",
message: "Argument value-key must be of type array")
assert(value-key.len() >= 2,
message: "Data needs to have at least 2 dimensions")

let num-axes = value-key.len()

let max-value = calc.max(..data.map(
t => calc.max(..value-key.map(k => t.at(k)))))

let axis-list = (
for n in range(num-axes) {
((
key: value-key.at(n),
translate: (v) => {
let angle = 90deg - 360deg / num-axes * n
(v * calc.cos(angle), v * calc.sin(angle))
}
),)
}
)

if step == auto {
step = axes.find-max-n-ticks(0, max-value, n: 7)
if step == none {
step = max-value / 7
}
}
let num-steps = int(max-value / step)

if type(data-style) != "function" {
data-style = (i) => { data-style }
}

group(ctx => {
let style = util.merge-dictionary(radarchart-default-style,
styles.resolve(ctx.style, (:), root: "radarchart"))

set-viewport((0, 0), size, bounds: (2 * max-value, 2 * max-value, 1))
translate((max-value, max-value, 0))

let scaling = (size.at(0) / (2 * max-value), size.at(1) / (2 * max-value))

for i in range(axis-list.len()) {
line((0, 0), (axis-list.at(i).translate)(max-value), ..style.grid)

for n in range(num-steps + 1) {
let v = step * n
line((axis-list.at(calc.rem(i - 1, num-axes)).translate)(v),
(axis-list.at(i).translate)(v), ..style.grid)
}
}

for n in range(num-steps + 1) {
let v = step * n
content((axis-list.at(0).translate)(v), $#v$,
anchor: "bottom-right",
padding: style.label-padding / scaling.at(0))
}

let enum-keys = value-key.enumerate()
for (i, item) in data.enumerate() {
let pts = enum-keys.map(
((i, k)) => (axis-list.at(i).translate)(item.at(k)))

let item-style = util.merge-dictionary(style, data-style(i))
let mark-radius = (
item-style.mark.size / scaling.at(0),
item-style.mark.size / scaling.at(1)
)

// Fill data polygon
//line(..pts, close: true, ..item-style)

// Draw data points
for pt in pts {
circle(pt, ..item-style.mark, radius: mark-radius)
}
}
})
}
Binary file modified manual.pdf
Binary file not shown.
Loading

0 comments on commit 1df7060

Please sign in to comment.