@dice-roller/svg-presenter 0.0.0-stage → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +240 -2
- package/assets/dice/README.md +20 -0
- package/assets/dice/d10.svg +16 -0
- package/assets/dice/d12.svg +19 -0
- package/assets/dice/d2.svg +11 -0
- package/assets/dice/d20.svg +19 -0
- package/assets/dice/d4.svg +11 -0
- package/assets/dice/d6.svg +11 -0
- package/assets/dice/d8.svg +13 -0
- package/assets/dice/generic.svg +12 -0
- package/dist/SvgPresenter.d.ts +30 -0
- package/dist/SvgPresenter.d.ts.map +1 -0
- package/dist/SvgPresenter.js +557 -0
- package/dist/SvgPresenter.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/modifier-icons.d.ts +24 -0
- package/dist/modifier-icons.d.ts.map +1 -0
- package/dist/modifier-icons.js +132 -0
- package/dist/modifier-icons.js.map +1 -0
- package/dist/value-slot.d.ts +3 -0
- package/dist/value-slot.d.ts.map +1 -0
- package/dist/value-slot.js +27 -0
- package/dist/value-slot.js.map +1 -0
- package/package.json +40 -4
package/README.md
CHANGED
|
@@ -1,3 +1,241 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SVG presenter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CSS-stylable SVG output for [RPG Dice Roller](https://github.com/dice-roller/rpg-dice-roller) v6.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @dice-roller/svg-presenter @dice-roller/rpg-dice-roller@next
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
This package is not yet published. Run the local playground from the repository root with `npm run dev`, then open `/svg/`.
|
|
10
|
+
|
|
11
|
+
## SVG presenter
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Roll } from "@dice-roller/rpg-dice-roller";
|
|
15
|
+
import { SvgPresenter } from "@dice-roller/svg-presenter";
|
|
16
|
+
|
|
17
|
+
// Supply SVG template strings, keyed by shape (d2, d4, d6, etc.).
|
|
18
|
+
// Include a generic template for unsupported face counts.
|
|
19
|
+
const presenter = new SvgPresenter(artwork, { size: 140 });
|
|
20
|
+
const svg = new Roll("2d6 + 3").present(presenter);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The presenter supports rolls, histories and expression results. It uses the core
|
|
24
|
+
library's types and reads existing results without evaluating or rolling again.
|
|
25
|
+
The SVG renderer and text-slot helper live in `packages/svg/src/`. The artwork
|
|
26
|
+
gallery lives in `demo/svg/`, and shared fixed-result fixtures live in
|
|
27
|
+
`packages/svg/tests/fixtures/`.
|
|
28
|
+
|
|
29
|
+
The dice roller is a peer dependency requiring v6 (including prereleases), and a
|
|
30
|
+
development dependency using the published v6 beta. Vue and Vite are only used
|
|
31
|
+
by the local demo and are not package dependencies.
|
|
32
|
+
|
|
33
|
+
Import the blank dice artwork through the package's SVG exports, for example
|
|
34
|
+
`@dice-roller/svg-presenter/icons/d20.svg`. With Vite, append `?raw` to import it
|
|
35
|
+
as a template string. Supply all required artwork, including `generic`, to the
|
|
36
|
+
presenter as shown above.
|
|
37
|
+
|
|
38
|
+
Pool and group descriptions are displayed once alongside their results. Inline
|
|
39
|
+
descriptions follow the pool or group; block descriptions sit above it and wrap
|
|
40
|
+
as needed. Set `showDescriptions: false` to hide them. The local demo includes
|
|
41
|
+
nested examples and a matching appearance control.
|
|
42
|
+
|
|
43
|
+
## Selecting dice
|
|
44
|
+
|
|
45
|
+
Each rendered die has `data-*` attributes on its enclosing `<g>`, covering its
|
|
46
|
+
SVG, caption and modifier markers. The die type is the core factory name
|
|
47
|
+
(`standard`, `percentile`, `fudge`, `range`, `face`, or a registered custom name).
|
|
48
|
+
The shape describes the artwork actually used, independently of the die type.
|
|
49
|
+
Face counts come directly from the core snapshot: for example, default `dF`
|
|
50
|
+
currently has three equally likely faces and uses the d6 artwork.
|
|
51
|
+
|
|
52
|
+
| Attribute | Value |
|
|
53
|
+
| ---------------------------------- | --------------------------------------------------------------- |
|
|
54
|
+
| `data-die-type` | Core die factory name |
|
|
55
|
+
| `data-faces` | Face count, including repeated faces |
|
|
56
|
+
| `data-notation` | Die notation, such as `d20`, `d%`, or `dF` |
|
|
57
|
+
| `data-shape` | Artwork key, such as `d20`, `d6`, or `generic` |
|
|
58
|
+
| `data-min`, `data-max` | Lowest and highest possible values |
|
|
59
|
+
| `data-value`, `data-initial-value` | Final and original rolled values |
|
|
60
|
+
| `data-calculation-value` | Value used for scoring before exclusion |
|
|
61
|
+
| `data-use-in-total` | The die's own inclusion state (`true` / `false`) |
|
|
62
|
+
| `data-excluded` | Effective exclusion, including a dropped enclosing group member |
|
|
63
|
+
| `data-flags` | Space-separated modifier flags; empty if there are none |
|
|
64
|
+
|
|
65
|
+
```css
|
|
66
|
+
[data-die-type="standard"][data-faces="20"] .die-outline {
|
|
67
|
+
stroke: rebeccapurple;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[data-flags~="explode"] .die-value {
|
|
71
|
+
font-weight: 800;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[data-excluded="true"] {
|
|
75
|
+
opacity: 0.3;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
const dice = document.querySelectorAll('[data-die-type="fudge"]');
|
|
81
|
+
for (const die of dice) {
|
|
82
|
+
console.log(Number(die.dataset.value), Number(die.dataset.faces));
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Selectors work when the SVG is inserted inline in the document. Values remain
|
|
87
|
+
in the metadata when `showValues` is false; that option only hides visible text.
|
|
88
|
+
|
|
89
|
+
## Selecting dice pools
|
|
90
|
+
|
|
91
|
+
Every pool has a `g.dice-pool-result` wrapper with `data-pool="true"`.
|
|
92
|
+
It contains the pool's parentheses, dice and descriptions. A transparent hit area
|
|
93
|
+
lets blank spaces show the pool tooltip; dice and modifier icons keep their own
|
|
94
|
+
more specific tooltips. Pools inside a group member retain both nested wrappers.
|
|
95
|
+
|
|
96
|
+
| Attribute | Meaning |
|
|
97
|
+
| -------------------- | ------------------------------------------------------------------ |
|
|
98
|
+
| `data-notation` | Canonical pool notation, including modifiers, without descriptions |
|
|
99
|
+
| `data-quantity` | Initial evaluated dice quantity |
|
|
100
|
+
| `data-result-count` | Number of resulting dice, including generated and dropped results |
|
|
101
|
+
| `data-counted-count` | Results whose own `useInTotal` flag is true |
|
|
102
|
+
| `data-value` | Pool value after its own modifiers |
|
|
103
|
+
|
|
104
|
+
For example, a pool tooltip can show
|
|
105
|
+
`Dice pool: 3d8kh1; 3 results; 1 counted; total 8`.
|
|
106
|
+
Counts refer to the resulting snapshot, rather than discarded reroll attempts.
|
|
107
|
+
A pool in a dropped group member retains its own value and counted results; its
|
|
108
|
+
tooltip additionally notes exclusion by the enclosing group. The group member's
|
|
109
|
+
tooltip reports its effective contribution. Metadata and hover areas remain
|
|
110
|
+
available when visible labels, values, notation or totals are hidden.
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
const pools = document.querySelectorAll('g[data-pool="true"]');
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Hover highlights
|
|
117
|
+
|
|
118
|
+
Inline SVG highlights the most specific pool, group member or roll group under
|
|
119
|
+
pointer hover with a faint fill and rounded outline. Hover a pool's dice or blank
|
|
120
|
+
space for the pool highlight; hover an operator between pools for the member;
|
|
121
|
+
hover group braces, commas or its description for the whole group. Ancestor
|
|
122
|
+
highlights are suppressed while a nested region is hovered, including nested
|
|
123
|
+
roll groups. Dice and modifier icons retain their own tooltips.
|
|
124
|
+
|
|
125
|
+
Whole groups use `g.roll-group-result[data-group="true"]`, with `data-notation`,
|
|
126
|
+
`data-member-count`, `data-counted-count` and `data-value`. These wrappers remain
|
|
127
|
+
available when descriptions, labels, icons or totals are hidden.
|
|
128
|
+
|
|
129
|
+
```css
|
|
130
|
+
.result-preview {
|
|
131
|
+
--result-hover-color: currentColor;
|
|
132
|
+
--result-hover-fill-opacity: 0.05;
|
|
133
|
+
--result-hover-stroke-opacity: 0.45;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Hide visual highlights while retaining hover areas and tooltips. */
|
|
137
|
+
.result-preview.no-highlights {
|
|
138
|
+
--result-hover-fill-opacity: 0;
|
|
139
|
+
--result-hover-stroke-opacity: 0;
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Highlight outlines do not intercept pointer events or reserve layout space.
|
|
144
|
+
The SVG includes the CSS, using `:hover` and `:has()` in supporting browsers;
|
|
145
|
+
external page styles can customise an SVG embedded inline. An SVG used through
|
|
146
|
+
`<img>` does not expose these interactive regions to the containing page.
|
|
147
|
+
|
|
148
|
+
## Matching mathematical parentheses
|
|
149
|
+
|
|
150
|
+
Hover a function name or either of its parentheses to brighten the name and both
|
|
151
|
+
parentheses together. Hover either
|
|
152
|
+
mathematical grouping parenthesis to brighten its matching partner. Arguments
|
|
153
|
+
and nested pairs do not trigger the outer pair. Dice-pool parentheses retain
|
|
154
|
+
only their existing pool highlight.
|
|
155
|
+
|
|
156
|
+
This includes parentheses inserted by the presenter to preserve precedence.
|
|
157
|
+
No font-size or weight changes are used, so the highlight does not shift text.
|
|
158
|
+
Function and grouping scopes use `g.math-group-result` with `data-math-group`
|
|
159
|
+
set to `function` or `parentheses`. Functions also expose `data-function`.
|
|
160
|
+
These effects use CSS `:has()` and require an interactive SVG.
|
|
161
|
+
|
|
162
|
+
```css
|
|
163
|
+
.result-preview {
|
|
164
|
+
--math-hover-color: #bda0ff;
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Optional labels and totals
|
|
169
|
+
|
|
170
|
+
These appearance options default to `true`. Set any to `false` to hide that
|
|
171
|
+
part of the output; hidden labels do not reserve their usual layout space.
|
|
172
|
+
|
|
173
|
+
| Option | Controls |
|
|
174
|
+
| -------------------- | ----------------------------------------------------- |
|
|
175
|
+
| `showDiceLabels` | Die notation below each icon |
|
|
176
|
+
| `showModifierLabels` | Modifier labels below dice and group modifier markers |
|
|
177
|
+
| `showNotation` | The supplied notation above each roll |
|
|
178
|
+
| `showTotals` | Individual roll totals and the history total |
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
const presenter = new SvgPresenter(artwork, {
|
|
182
|
+
showDiceLabels: false,
|
|
183
|
+
showModifierLabels: false,
|
|
184
|
+
showNotation: false,
|
|
185
|
+
showTotals: false,
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Tooltips, `data-*` attributes, exclusion styling and calculated results remain
|
|
190
|
+
available independently of these visibility options.
|
|
191
|
+
|
|
192
|
+
## Modifier icons
|
|
193
|
+
|
|
194
|
+
The presenter displays open line symbols for explosions, compound and penetrating
|
|
195
|
+
explosions, rerolls, unique, min/max, target successes/failures, and critical
|
|
196
|
+
successes/failures. Critical success uses a star; critical failure uses a skull.
|
|
197
|
+
Compound explosions show overlapping purple and amber bursts. Combined compound
|
|
198
|
+
and penetrate outcomes show two separate symbols. Dropped results remain faded
|
|
199
|
+
and crossed out. Keep and sort do not need additional icons.
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
const presenter = new SvgPresenter(artwork, {
|
|
203
|
+
showModifierIcons: true,
|
|
204
|
+
modifierIconPosition: "below", // "corner" (default) or "below"
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
`showModifierIcons` is independent of `showModifierLabels`. Once and limited
|
|
209
|
+
variants share their family's symbol; labels and tooltips retain their details.
|
|
210
|
+
Icons represent actual result flags, rather than every modifier in the notation.
|
|
211
|
+
A uniqueness icon means a duplicate was rerolled, not that uniqueness is guaranteed.
|
|
212
|
+
Group modifier labels are smaller captions centred beneath the whole member and wrap
|
|
213
|
+
within its width. Group member flags are displayed on that member, without repeating them on every
|
|
214
|
+
nested die. Icons wrap into additional rows when needed.
|
|
215
|
+
|
|
216
|
+
Corner placement cuts transparent circular gaps out of the artwork behind each
|
|
217
|
+
symbol. It does not paint a background colour. Below placement generates no
|
|
218
|
+
artwork cutouts; the compound symbol still masks its rear burst internally.
|
|
219
|
+
Every render generates unique mask identifiers, so multiple outputs can share a
|
|
220
|
+
page safely. Keep the generated definitions with their SVG.
|
|
221
|
+
|
|
222
|
+
Each icon has `data-modifier` and a matching `modifier-*` class. Values are:
|
|
223
|
+
`explode`, `compound`, `penetrate`, `re-roll`, `unique`, `min`, `max`,
|
|
224
|
+
`target-success`, `target-failure`, `critical-success`, and `critical-failure`.
|
|
225
|
+
Icons remain meaningful in monochrome. Colours can be overridden with CSS:
|
|
226
|
+
|
|
227
|
+
```css
|
|
228
|
+
.result-preview {
|
|
229
|
+
--modifier-explode-color: #9b5d0a;
|
|
230
|
+
--modifier-critical-success-color: #96700b;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* One colour for all symbols, including compound's rear burst. */
|
|
234
|
+
.result-preview.monochrome {
|
|
235
|
+
--modifier-icon-color: currentColor;
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Every icon family supports `--modifier-{data-modifier}-color`. Compound's rear
|
|
240
|
+
burst follows `--modifier-explode-color`. The demo includes placement, visibility
|
|
241
|
+
and monochrome controls, plus fixed examples of every modifier family.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Dice artwork
|
|
2
|
+
|
|
3
|
+
Original, unnumbered SVG icons for the SVG presenter. Each uses a `0 0 100 100`
|
|
4
|
+
viewBox, `currentColor` strokes and a `.die-outline` class. Faceted dice also
|
|
5
|
+
provide `.die-facets`, so outline, facets and fill can be styled independently.
|
|
6
|
+
|
|
7
|
+
Use d10 artwork for percentile dice and d6 artwork for Fudge dice. Use `generic.svg`
|
|
8
|
+
for unsupported face counts. Add values, die labels and modifier indicators as
|
|
9
|
+
separate layers; they are not baked into these assets.
|
|
10
|
+
|
|
11
|
+
Each SVG owns an empty `<text data-slot="value">` element, including its position,
|
|
12
|
+
alignment, default font size and available width (`data-max-width`, in viewBox
|
|
13
|
+
units). Consumers provide a value, not coordinates. `packages/svg/src/value-slot.ts` fills
|
|
14
|
+
the slot with escaped text and conservatively reduces the font size for longer
|
|
15
|
+
values. This estimate is font-independent; custom fonts may need CSS adjustments.
|
|
16
|
+
An empty value leaves the artwork blank, as used for the zero face of Fudge dice.
|
|
17
|
+
|
|
18
|
+
The local gallery in `demo/svg/SvgDemo.vue` demonstrates the icons with values, including
|
|
19
|
+
the three Fudge faces and a three-digit percentile result. CSS styling requires
|
|
20
|
+
inline SVG; page styles do not reach inside an SVG loaded through an `<img>`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
class="die die-d10"
|
|
3
|
+
width="128" height="128" viewBox="0 0 100 100"
|
|
4
|
+
fill="none" stroke="currentColor" stroke-width="2.2"
|
|
5
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
6
|
+
role="img" aria-label="Ten-sided die">
|
|
7
|
+
<path class="die-outline" d="M50 5 88 37 94 62 50 95 6 62 12 37Z"/>
|
|
8
|
+
<path class="die-facets" stroke-width="1.4"
|
|
9
|
+
d="M50 5 22 57 50 76 78 57Z
|
|
10
|
+
M6 62 22 57
|
|
11
|
+
M78 57 94 62
|
|
12
|
+
M50 76V95"/>
|
|
13
|
+
<text class="die-value" data-slot="value"
|
|
14
|
+
x="50" y="49" text-anchor="middle" dominant-baseline="central"
|
|
15
|
+
font-size="22" data-max-width="35" fill="currentColor" stroke="none"></text>
|
|
16
|
+
</svg>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
class="die die-d12"
|
|
3
|
+
width="128" height="128" viewBox="0 0 100 100"
|
|
4
|
+
fill="none" stroke="currentColor" stroke-width="2.2"
|
|
5
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
6
|
+
role="img" aria-label="Twelve-sided die">
|
|
7
|
+
<path class="die-outline"
|
|
8
|
+
d="M50 5 76 14 93 37 93 65 76 86 50 95 24 86 7 65 7 37 24 14Z"/>
|
|
9
|
+
<path class="die-facets" stroke-width="1.4"
|
|
10
|
+
d="M50 22 80 44 68 77H32L20 44Z
|
|
11
|
+
M50 5V22
|
|
12
|
+
M80 44 93 37
|
|
13
|
+
M68 77 76 86
|
|
14
|
+
M32 77 24 86
|
|
15
|
+
M20 44 7 37"/>
|
|
16
|
+
<text class="die-value" data-slot="value"
|
|
17
|
+
x="50" y="53" text-anchor="middle" dominant-baseline="central"
|
|
18
|
+
font-size="22" data-max-width="44" fill="currentColor" stroke="none"></text>
|
|
19
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
class="die die-d2"
|
|
3
|
+
width="128" height="128" viewBox="0 0 100 100"
|
|
4
|
+
fill="none" stroke="currentColor" stroke-width="2.2"
|
|
5
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
6
|
+
role="img" aria-label="Two-sided die">
|
|
7
|
+
<circle class="die-outline" cx="50" cy="50" r="45"/>
|
|
8
|
+
<text class="die-value" data-slot="value"
|
|
9
|
+
x="50" y="50" text-anchor="middle" dominant-baseline="central"
|
|
10
|
+
font-size="22" data-max-width="62" fill="currentColor" stroke="none"></text>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
class="die die-d20"
|
|
3
|
+
width="128" height="128" viewBox="0 0 100 100"
|
|
4
|
+
fill="none" stroke="currentColor" stroke-width="2.2"
|
|
5
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
6
|
+
role="img" aria-label="Twenty-sided die">
|
|
7
|
+
<path class="die-outline" d="M50 5 90 27 90 73 50 95 10 73 10 27Z"/>
|
|
8
|
+
<path class="die-facets" stroke-width="1.4"
|
|
9
|
+
d="M50 5V20
|
|
10
|
+
M10 27 50 20 90 27
|
|
11
|
+
M90 27 82 72 90 73
|
|
12
|
+
M82 72 50 95 18 72
|
|
13
|
+
M18 72 10 73
|
|
14
|
+
M10 27 18 72
|
|
15
|
+
M50 20 18 72H82Z"/>
|
|
16
|
+
<text class="die-value" data-slot="value"
|
|
17
|
+
x="50" y="54" text-anchor="middle" dominant-baseline="central"
|
|
18
|
+
font-size="22" data-max-width="36" fill="currentColor" stroke="none"></text>
|
|
19
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
class="die die-d4"
|
|
3
|
+
width="128" height="128" viewBox="0 0 100 100"
|
|
4
|
+
fill="none" stroke="currentColor" stroke-width="2.2"
|
|
5
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
6
|
+
role="img" aria-label="Four-sided die">
|
|
7
|
+
<path class="die-outline" d="M50 7 94 87H6Z"/>
|
|
8
|
+
<text class="die-value" data-slot="value"
|
|
9
|
+
x="50" y="60" text-anchor="middle" dominant-baseline="central"
|
|
10
|
+
font-size="22" data-max-width="40" fill="currentColor" stroke="none"></text>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
class="die die-d6"
|
|
3
|
+
width="128" height="128" viewBox="0 0 100 100"
|
|
4
|
+
fill="none" stroke="currentColor" stroke-width="2.2"
|
|
5
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
6
|
+
role="img" aria-label="Six-sided die">
|
|
7
|
+
<rect class="die-outline" x="6" y="6" width="88" height="88" rx="2"/>
|
|
8
|
+
<text class="die-value" data-slot="value"
|
|
9
|
+
x="50" y="50" text-anchor="middle" dominant-baseline="central"
|
|
10
|
+
font-size="22" data-max-width="62" fill="currentColor" stroke="none"></text>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
class="die die-d8"
|
|
3
|
+
width="128" height="128" viewBox="0 0 100 100"
|
|
4
|
+
fill="none" stroke="currentColor" stroke-width="2.2"
|
|
5
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
6
|
+
role="img" aria-label="Eight-sided die">
|
|
7
|
+
<path class="die-outline" d="M50 5 89 28 89 72 50 95 11 72 11 28Z"/>
|
|
8
|
+
<path class="die-facets" stroke-width="1.4"
|
|
9
|
+
d="M50 5 11 72H89Z"/>
|
|
10
|
+
<text class="die-value" data-slot="value"
|
|
11
|
+
x="50" y="51" text-anchor="middle" dominant-baseline="central"
|
|
12
|
+
font-size="22" data-max-width="40" fill="currentColor" stroke="none"></text>
|
|
13
|
+
</svg>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
class="die die-generic"
|
|
3
|
+
width="128" height="128" viewBox="0 0 100 100"
|
|
4
|
+
fill="none" stroke="currentColor" stroke-width="2.2"
|
|
5
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
6
|
+
role="img" aria-label="Die with an arbitrary number of faces">
|
|
7
|
+
<path class="die-outline"
|
|
8
|
+
d="M34 6H66Q69 6 71 8L92 29Q94 31 94 34V66Q94 69 92 71L71 92Q69 94 66 94H34Q31 94 29 92L8 71Q6 69 6 66V34Q6 31 8 29L29 8Q31 6 34 6Z"/>
|
|
9
|
+
<text class="die-value" data-slot="value"
|
|
10
|
+
x="50" y="50" text-anchor="middle" dominant-baseline="central"
|
|
11
|
+
font-size="22" data-max-width="64" fill="currentColor" stroke="none"></text>
|
|
12
|
+
</svg>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ModifierIconPosition } from "./modifier-icons.js";
|
|
2
|
+
import type { HistoryData, RollData, Presentable, Presenter } from "@dice-roller/rpg-dice-roller";
|
|
3
|
+
export type SvgRoll = Pick<RollData, "notation" | "total" | "result">;
|
|
4
|
+
export type SvgHistory = Pick<HistoryData, "total"> & {
|
|
5
|
+
readonly rolls: readonly SvgRoll[];
|
|
6
|
+
};
|
|
7
|
+
export interface Appearance {
|
|
8
|
+
readonly size: number;
|
|
9
|
+
readonly stroke: string;
|
|
10
|
+
readonly fill: string;
|
|
11
|
+
readonly filled: boolean;
|
|
12
|
+
readonly showValues: boolean;
|
|
13
|
+
readonly showDescriptions?: boolean;
|
|
14
|
+
readonly showDiceLabels?: boolean;
|
|
15
|
+
readonly showModifierLabels?: boolean;
|
|
16
|
+
readonly showModifierIcons?: boolean;
|
|
17
|
+
readonly modifierIconPosition?: ModifierIconPosition;
|
|
18
|
+
readonly showNotation?: boolean;
|
|
19
|
+
readonly showTotals?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Returns a standalone SVG from evaluated result data. */
|
|
22
|
+
export declare function renderSvg(target: SvgHistory | SvgRoll, artwork: Readonly<Record<string, string>>, appearance: Appearance): string;
|
|
23
|
+
/** Formats v6 rolls, histories and expression results without evaluating them. */
|
|
24
|
+
export declare class SvgPresenter implements Presenter<string> {
|
|
25
|
+
readonly artwork: Readonly<Record<string, string>>;
|
|
26
|
+
readonly appearance: Appearance;
|
|
27
|
+
constructor(artwork: Readonly<Record<string, string>>, appearance?: Partial<Appearance>);
|
|
28
|
+
present(target: Presentable | SvgHistory | SvgRoll): string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=SvgPresenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SvgPresenter.d.ts","sourceRoot":"","sources":["../src/SvgPresenter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAKhE,OAAO,KAAK,EAEV,WAAW,EACX,QAAQ,EACR,WAAW,EACX,SAAS,EAEV,MAAM,8BAA8B,CAAC;AAItC,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,CAAC;AACtE,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAC;CACpC,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IACrD,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAuMD,2DAA2D;AAC3D,wBAAgB,SAAS,CACvB,MAAM,EAAE,UAAU,GAAG,OAAO,EAC5B,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACzC,UAAU,EAAE,UAAU,GACrB,MAAM,CAkgBR;AAED,kFAAkF;AAClF,qBAAa,YAAa,YAAW,SAAS,CAAC,MAAM,CAAC;IACpD,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;gBAG9B,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACzC,UAAU,GAAE,OAAO,CAAC,UAAU,CAAM;IAoBtC,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM;CAW5D"}
|