Skip to content

Commit

Permalink
doc: Update manual
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Dec 9, 2023
1 parent af4f1b9 commit da43bb2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
20 changes: 18 additions & 2 deletions manual.typ
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,32 @@ for (c, s, f, cont) in (
Defines a point relative to a named element using anchors, see @anchors.

#def-arg("name", `<string>`, [The name of the element that you wish to use to specify a coordinate.])
#def-arg("anchor", `<string>`, [An anchor of the element. If one is not given a default anchor will be used. On most elements this is `center` but it can be different.])
#def-arg("anchor", `<number, angle, string>`, [An anchor of the element. If one is not given a default anchor will be used. On most elements this is `center` but it can be different.])

You can also use implicit syntax of a dot separated string in the form `"name.anchor"`.
You can also use implicit syntax of a dot separated string in the form `"name.anchor"`
for named anchors.

```example
line((0,0), (3,2), name: "line")
circle("line.end", name: "circle")
rect("line.start", "circle.east")
```

Using the dictionary anchor syntax, you can not only use named anchors, but also
query the element for distance or angle anchors on it's path:

```example
circle((0,0), name: "circle")
// Anchor at 30 degree
content((name: "circle", anchor: 30deg), box(fill: white, $ 30 degree $))
// Anchor at 30% of the path length
content((name: "circle", anchor: 30%), box(fill: white, $ 30 % $))
// Anchor at 3.14 of the path
content((name: "circle", anchor: 3.14), box(fill: white, $ p = 3.14 $))
```

Note, that not all elements provide angle or distance based anchors!

== Tangent
This system allows you to compute the point that lies tangent to a shape. In detail, consider an element and a point. Now draw a straight line from the point so that it "touches" the element (more formally, so that it is _tangent_ to this element). The point where the line touches the shape is the point referred to by this coordinate system.

Expand Down
2 changes: 1 addition & 1 deletion src/draw/grouping.typ
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
/// #show-parameter-block("padding", ("none", "number", "array", "dictionary"), default: none, [How much padding to add around the group's bounding box. `none` applies no padding. A number applies padding to all sides equally. A dictionary applies padding following Typst's `pad` function: https://typst.app/docs/reference/layout/pad/. An array follows CSS like padding: `(y, x)`, `(top, x, bottom)` or `(top, right, bottom, left)`.])
///
/// = Anchors
/// Supports compass anchors. These are created based on the axis aligned bounding box of all the child elements of the group.
/// Supports compass, distance and angle anchors. These are created based on the axis aligned bounding box of all the child elements of the group.
///
/// You can add custom anchors to the group by using the `anchor` element while in the scope of said group, see `anchor` for more details. You can also copy over anchors from named child element by using the `copy-anchors` element as they are not accessible from outside the group.
///
Expand Down
18 changes: 14 additions & 4 deletions src/draw/shapes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
/// #show-parameter-block("radius", ("number", "array"), [A number that defines the size of the circle's radius. Can also be set to a tuple of two numbers to define the radii of an ellipse, the first number is the `x` radius and the second is the `y` radius.], default: 1)
///
/// = Anchors
/// Supports compass anchors. The "center" anchor is the default.
///
/// Supports compass, distance and angle anchors. The "center" anchor is the default.
///
/// - position (coordinate): The position to place the circle on.
/// - name (none,string):
/// - anchor (none,string):
Expand Down Expand Up @@ -180,7 +180,7 @@
/// This overrides the default of `true`, that allows chaining of (arc) elements.], default: true)
///
/// = Anchors
/// Supports compass anchors when `mode` is "PIE"
/// Supports compass, distance anchors, plus angle anchors if mode is "PIE"
/// / center: The center of the arc, this is the default anchor.
/// / arc-center: The midpoint of the arc's curve.
/// / chord-center: Center of chord of the arc drawn between the start and end point.
Expand Down Expand Up @@ -527,7 +527,9 @@
/// Supports mark styling.
///
/// = Anchors
/// Supports distance anchors.
/// / start: The line's start position
/// / mid: The line's mid position
/// / end: The line's end position
///
/// - ..pts-style (coordinates, style): Positional two or more coordinates to draw lines between. Accepts style key-value pairs.
Expand Down Expand Up @@ -998,7 +1000,7 @@
/// ])
///
/// = Anchors
/// Supports compass anchors.
/// Supports compass, distance and angle anchors.
///
/// - a (coordinate): Coordinate of the bottom left corner of the rectangle.
/// - b (coordinate): Coordinate of the top right corner of the rectangle. You can draw a rectangle with a specified width and height by using relative coordinates for this parameter `(rel: (width, height))`.
Expand Down Expand Up @@ -1179,8 +1181,10 @@
/// Supports marks.
///
/// = Anchors
/// Supports distance anchors.
/// / ctrl-n: nth control point where n is an integer starting at 0
/// / start: The start position of the curve.
/// / mid: The mid position of the curve
/// / end: The end position of the curve.
///
/// - start (coordinate): Start position
Expand Down Expand Up @@ -1302,7 +1306,9 @@
/// Supports marks.
///
/// = Anchors
/// Supports distance anchors.
/// / start: The position of the start of the curve.
/// / mid: The mid position of the curve
/// / end: The position of the end of the curve.
/// / pt-n: The nth given position (0 indexed so "pt-0" is equal to "start")
///
Expand Down Expand Up @@ -1389,7 +1395,9 @@
/// #show-parameter-block("rho", "idk", [])
///
/// = Anchors
/// Supports distance anchors.
/// / start: The position of the start of the curve.
/// / mid: The mid position of the curve
/// / end: The position of the end of the curve.
/// / pt-n: The nth given position (0 indexed, so "pt-0" is equal to "start")
///
Expand Down Expand Up @@ -1475,7 +1483,9 @@
/// = parameters
///
/// = Anchors
/// Supports distance anchors.
/// / start: The start of the merged path.
/// / mid: The mid position of the merged path.
/// / end: The end of the merged path.
///
/// - body (elements): Elements with paths to be merged together.
Expand Down

0 comments on commit da43bb2

Please sign in to comment.