Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/preview/bar-point/0.1.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 hmort

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
82 changes: 82 additions & 0 deletions packages/preview/bar-point/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Draw backgammon board positions and display checker movement from a given position within a [Typst](https://typst.app) document.

<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/img/bar-point-examples.png">
<img alt="bar-point board examples" src="/docs/img/bar-point-examples.png">
</picture>

## usage
Add the following to the top of the file:


```typ
#import "@preview/bar-point:0.1.0": backgammon-board
```

*bar-point* uses the single function `backgammon-board` to render the board and movement arrows

## basic example
```typ
#import "@preview/bar-point:0.1.0": backgammon-board

// define a board position
#let opening-layout = (
-2, 0, 0, 0, 0, 5, // points 01 to 06 (light home board)
0, 3, 0, 0, 0, -5, // points 07 to 12
5, 0, 0, 0, -3, 0, // points 13 to 18
-5, 0, 0, 0, 0, 2 // points 19 to 24 (dark home board)
)

// create a new board using the given position
#backgammon-board(opening-layout)
```

## themes
use the `theme` parameter to change the theme.
Available themes:
* `"default-green"`
* `"tournament-blue"`
* `"woodland-brown"`
* `"high-contrast-dark"`
* `"print-grayscale"`

## `backgammon-board()` parameters

| Parameter | Type | Default Value | Description |
| :--- | :--- | :--- | :--- |
| **`checkers`** | `array` | *(positional)* | A 24-integer layout matrix array mapping checker frequencies. Positive integers represent light checkers, negative integers represent dark checkers |
| **`turn`** | `string` | `"light"` | Marks the active player turn phase. Accepts either `"light"` or `"dark"` |
| **`bar`** | `array` | `(0, 0)` | A two-integer array tracking pieces trapped on the central bar column formatted as `(light, dark)` |
| **`dice`** | `array` | `(1, 1)` | A two-integer array specifying active values displayed on the dice blocks, e.g. `(4, 2)` |
| **`cube`** | `dictionary` | `(value: 64, owner: none)` | Tracks the doubling cube state using keys `value` (integer) and `owner` (`none`, `"light"`, or `"dark"`) |
| **`borne-off`** | `array` | `(0, 0)` | A two-integer array capturing pieces that have been borne off completely formatted as `(light, dark)` |
| **`clockwise`** | `boolean` | `false` | When `false`, points 1–6 sit in the lower-right quadrant; when `true`, points 1–6 move to the lower-left |
| **`swap-colours`** | `boolean` | `false` | A purely cosmetic override that swaps checker colours without altering numerical data |
| **`swap-players`** | `boolean` | `false` | When `true`, completely negates the positional matrix values to view the entire match from the opponent's seating perspective with accurate analytics |
| **`ace-point`** | `string` | `"light"` | Sets whether the 1-point belongs to `"light"` or `"dark"`, automatically positioning scoreboards and bar alignments |
| **`moves`** | `array` | `()` | A collection of integer coordinate pairs outlining active token trajectories, e.g. `((24, 20), (13, 11))` |
| **`show-bg`** | `boolean` | `true` | Toggles the solid background arena panel display |
| **`show-border`** | `boolean` | `true` | Toggles the bounding perimeter framing lines |
| **`show-pips`** | `boolean` | `true` | Toggles the center column score totals text overlay |
| **`show-labels`** | `boolean` | `true` | Toggles the 1–24 numerical point indexes around borders |
| **`show-dice`** | `boolean` | `true` | Toggles the rendering of the active player dice boxes |
| **`show-cube`** | `boolean` | `true` | Toggles the rendering of the active match doubling cube |
| **`show-home-markers`** | `boolean` | `true` | Toggles horizontal accent stripes highlighting homeboard sectors |
| **`show-tray-borders`** | `boolean` | `true` | Toggles framing borders on borne-off side slots |
| **`theme`** | `string` | `"default-green"` | Selects a predefined design profile from the built-in themes database |
| **`font`** | `string` | `none` | Applies a custom choice of monospace font asset family, or defaults to your theme's preset choice if `none` |
| **`adjust-theme`** | `dictionary` | `(:)` | Pipes a map of custom color modifications directly into the rendering pipeline to override style assets |
| **`rounded`** | `boolean` | `true` | Configures whether panels use smooth soft corners or sharp crisp square edge alignments |
| **`scale`** | `float` | `1.0` | Applies structural geometric uniform canvas multiplier adjustments |
| **`label-size`** | `length` | `9pt` | Specifies typographic font bounds for indices and score markers |
| **`marker-thickness`** | `length` | `2.5pt` | Dictates line weights for home sector bars |
| **`tray-checker-size`** | `float` | `0.0` | Introduces customizable micro-spacing gaps inside the borne-off tray blocks |
| **`arrow-mark`** | `string` | `"circle"` | Declares the arrowhead mark shape used for bezier motion paths. Supports standard cetz marks such as `"circle"`, `"arrow"`, `">"`, `"stealth"`, `"\|"`, `"x"`, and `"diamond"` |


## dependencies
*bar-point* makes use of the fantastic [CeTZ](https://typst.app/universe/package/cetz) for rendering the board and moves

## license

This project is open-source software distributed under the terms of the permissive **MIT License**. See the [LICENSE](./LICENSE)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions packages/preview/bar-point/0.1.0/examples/examples.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#set page(width: auto, height: auto, margin: 1cm)
#import "/src/lib.typ": backgammon-board
#import "positions.typ":*

== position 1 layout
// default layout
#backgammon-board(opening-layout)
#backgammon-board(opening-layout, theme: "woodland-brown")
#backgammon-board(opening-layout, theme: "woodland-brown", swap-colours: true, show-bg: true, clockwise: true, show-home-markers: false)


// grayscale example with all parameters
#backgammon-board(
position-1-layout,

// core game configuration and movement rules
turn: "light",
bar: (1, 2),
dice: (1, 1),
cube: (value: 64, owner: none),
borne-off: (8, 3),
clockwise: false,
swap-colours: false,
ace-point: "dark",
moves: ((0,6),(0,7),(0,12)),

// visibility toggles
show-bg: false,
show-border: true,
show-pips: true,
show-labels: true,
show-dice: true,
show-cube: true,
show-home-markers: true,
show-tray-borders: false,

// theme and visual appearance
//theme: "print-grayscale",
font: none,
adjust-theme: (:),
rounded: true,
scale: 1.0,
label-size: 9pt,
marker-thickness: 2.5pt,
tray-checker-size: 1.0,
arrow-mark: "circle",
)

// construct a 2x2 grid matrix container block with a comfortable separation pitch
#grid(
columns: 2,
gutter: .5cm,

// --------------------------------------------------------------------------
// board 1
// --------------------------------------------------------------------------
backgammon-board(
position-1-layout,
theme: "default-green",
scale: 0.65,
turn: "dark",
dice: (3, 1),
show-home-markers: true,
borne-off: (4,9),
tray-checker-size: 0.8,
moves: ((5,2),(1,0)),
ace-point: "dark"
),

// --------------------------------------------------------------------------
// board 2
// --------------------------------------------------------------------------
backgammon-board(
position-1-layout,
theme: "tournament-blue",
show-bg: true,
scale: 0.65,
turn: "dark",
dice: (6, 4),
cube: (value: 2, owner: "dark"),
show-home-markers: true,
clockwise: true,
ace-point: "dark"

),

// --------------------------------------------------------------------------
// board 3
// --------------------------------------------------------------------------
backgammon-board(
position-1-layout,
theme: "woodland-brown",
scale: 0.65,
swap-colours: true,
show-home-markers: false,
show-bg: true,
ace-point: "dark"
),

// --------------------------------------------------------------------------
// board 4
// --------------------------------------------------------------------------
backgammon-board(
position-1-layout,
theme: "print-grayscale",
scale: 0.65,
show-home-markers: false,
show-pips: true,
ace-point: "dark",
bar: (5,2),
),
)


13 changes: 13 additions & 0 deletions packages/preview/bar-point/0.1.0/examples/positions.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#let opening-layout = (
-2, 0, 0, 0, 0, 15, // points 1 to 6 (light home board)
0, 3, 0, 0, 0, -5, // points 7 to 12
5, 0, 0, 0, -3, 0, // points 13 to 18
-5, 0, 0, 0, 0, 2 // points 19 to 24 (dark home board)
)

#let position-1-layout = (
-3, 0, -2, -4, -2, 0, // points 1 to 6
0, 0, 0, 0, 0, 0, // points 7 to 12
0, 0, 0, 0, 0, 0, // points 13 to 18
0, 0, 0, 1, 2, 3 // points 19 to 24
)
5 changes: 5 additions & 0 deletions packages/preview/bar-point/0.1.0/src/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// ============================================================================
// lib.typ - public package entrypoint gatekeeper file
// ============================================================================

#import "src.typ": backgammon-board
Loading
Loading