@johnmorrisdotca/dougu-sports 0.0.1 → 0.2.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/CHANGELOG.md +61 -1
- package/LICENSES/README.md +4 -3
- package/NOTICE.md +54 -14
- package/README.md +251 -80
- package/dist/emblems/award/badge.d.ts +2 -0
- package/dist/emblems/award/badge.js +14 -0
- package/dist/emblems/award/crown.d.ts +2 -0
- package/dist/emblems/award/crown.js +15 -0
- package/dist/emblems/award/medal.d.ts +1 -1
- package/dist/emblems/award/medal.js +10 -15
- package/dist/emblems/award/shield.d.ts +2 -0
- package/dist/emblems/award/shield.js +11 -0
- package/dist/emblems/award/star.d.ts +2 -0
- package/dist/emblems/award/star.js +11 -0
- package/dist/emblems/ball/ball.afl.d.ts +1 -0
- package/dist/emblems/ball/ball.afl.js +24 -0
- package/dist/emblems/ball/ball.baseball.d.ts +1 -0
- package/dist/emblems/ball/ball.baseball.js +14 -0
- package/dist/emblems/ball/ball.basketball.d.ts +7 -0
- package/dist/emblems/ball/ball.basketball.js +32 -0
- package/dist/emblems/ball/ball.basketball3x3.d.ts +1 -0
- package/dist/emblems/ball/ball.basketball3x3.js +10 -0
- package/dist/emblems/ball/ball.basketball6.d.ts +1 -0
- package/dist/emblems/ball/ball.basketball6.js +10 -0
- package/dist/emblems/ball/ball.core.d.ts +111 -0
- package/dist/emblems/ball/ball.core.js +79 -0
- package/dist/emblems/ball/ball.cricket.d.ts +5 -0
- package/dist/emblems/ball/ball.cricket.js +31 -0
- package/dist/emblems/ball/ball.curlingstone.d.ts +3 -0
- package/dist/emblems/ball/ball.curlingstone.js +46 -0
- package/dist/emblems/ball/ball.discus.d.ts +1 -0
- package/dist/emblems/ball/ball.discus.js +24 -0
- package/dist/emblems/ball/ball.engine.d.ts +114 -0
- package/dist/emblems/ball/ball.engine.js +342 -0
- package/dist/emblems/ball/ball.family.dotted.d.ts +27 -0
- package/dist/emblems/ball/ball.family.dotted.js +20 -0
- package/dist/emblems/ball/ball.family.panelled.d.ts +7 -0
- package/dist/emblems/ball/ball.family.panelled.js +60 -0
- package/dist/emblems/ball/ball.family.prolate.d.ts +16 -0
- package/dist/emblems/ball/ball.family.prolate.js +29 -0
- package/dist/emblems/ball/ball.family.seamed.d.ts +31 -0
- package/dist/emblems/ball/ball.family.seamed.js +26 -0
- package/dist/emblems/ball/ball.fieldhockey.d.ts +1 -0
- package/dist/emblems/ball/ball.fieldhockey.js +15 -0
- package/dist/emblems/ball/ball.football.d.ts +3 -0
- package/dist/emblems/ball/ball.football.js +51 -0
- package/dist/emblems/ball/ball.gaelic.d.ts +2 -0
- package/dist/emblems/ball/ball.gaelic.js +30 -0
- package/dist/emblems/ball/ball.golf.d.ts +1 -0
- package/dist/emblems/ball/ball.golf.js +15 -0
- package/dist/emblems/ball/ball.hammer.d.ts +1 -0
- package/dist/emblems/ball/ball.hammer.js +31 -0
- package/dist/emblems/ball/ball.handball.d.ts +1 -0
- package/dist/emblems/ball/ball.handball.js +25 -0
- package/dist/emblems/ball/ball.index.d.ts +48 -0
- package/dist/emblems/ball/ball.index.js +103 -0
- package/dist/emblems/ball/ball.math.d.ts +38 -0
- package/dist/emblems/ball/ball.math.js +105 -0
- package/dist/emblems/ball/ball.object.d.ts +38 -0
- package/dist/emblems/ball/ball.object.js +20 -0
- package/dist/emblems/ball/ball.padel.d.ts +1 -0
- package/dist/emblems/ball/ball.padel.js +13 -0
- package/dist/emblems/ball/ball.pickleball.d.ts +2 -0
- package/dist/emblems/ball/ball.pickleball.js +26 -0
- package/dist/emblems/ball/ball.polyhedra.d.ts +15 -0
- package/dist/emblems/ball/ball.polyhedra.js +63 -0
- package/dist/emblems/ball/ball.puck.d.ts +3 -0
- package/dist/emblems/ball/ball.puck.js +22 -0
- package/dist/emblems/ball/ball.roundnet.d.ts +1 -0
- package/dist/emblems/ball/ball.roundnet.js +15 -0
- package/dist/emblems/ball/ball.rugby.d.ts +1 -0
- package/dist/emblems/ball/ball.rugby.js +35 -0
- package/dist/emblems/ball/ball.sepaktakraw.d.ts +1 -0
- package/dist/emblems/ball/ball.sepaktakraw.js +48 -0
- package/dist/emblems/ball/ball.shuttlecock.d.ts +6 -0
- package/dist/emblems/ball/ball.shuttlecock.js +93 -0
- package/dist/emblems/ball/ball.sliotar.d.ts +1 -0
- package/dist/emblems/ball/ball.sliotar.js +14 -0
- package/dist/emblems/ball/ball.smooth.d.ts +4 -0
- package/dist/emblems/ball/ball.smooth.js +51 -0
- package/dist/emblems/ball/ball.soccer.d.ts +2 -0
- package/dist/emblems/ball/ball.soccer.js +54 -0
- package/dist/emblems/ball/ball.softball.d.ts +1 -0
- package/dist/emblems/ball/ball.softball.js +14 -0
- package/dist/emblems/ball/ball.squash.d.ts +7 -0
- package/dist/emblems/ball/ball.squash.js +27 -0
- package/dist/emblems/ball/ball.stack.d.ts +48 -0
- package/dist/emblems/ball/ball.stack.js +127 -0
- package/dist/emblems/ball/ball.stitch.d.ts +10 -0
- package/dist/emblems/ball/ball.stitch.js +59 -0
- package/dist/emblems/ball/ball.tennis.d.ts +1 -0
- package/dist/emblems/ball/ball.tennis.js +13 -0
- package/dist/emblems/ball/ball.teqball.d.ts +1 -0
- package/dist/emblems/ball/ball.teqball.js +27 -0
- package/dist/emblems/ball/ball.volleyball.d.ts +3 -0
- package/dist/emblems/ball/ball.volleyball.js +56 -0
- package/dist/emblems/ball/ball.waterpolo.d.ts +1 -0
- package/dist/emblems/ball/ball.waterpolo.js +31 -0
- package/dist/emblems/crest/diamond.d.ts +2 -0
- package/dist/emblems/crest/diamond.js +18 -0
- package/dist/emblems/crest/pennant.d.ts +2 -0
- package/dist/emblems/crest/pennant.js +18 -0
- package/dist/emblems/crest/roundel.d.ts +2 -0
- package/dist/emblems/crest/roundel.js +18 -0
- package/dist/emblems/crest/shield.d.ts +2 -0
- package/dist/emblems/crest/shield.js +17 -0
- package/dist/emblems/emblem.api.d.ts +77 -9
- package/dist/emblems/emblem.api.js +56 -10
- package/dist/emblems/emblem.compose.d.ts +31 -0
- package/dist/emblems/emblem.compose.js +91 -0
- package/dist/emblems/emblem.core.d.ts +89 -7
- package/dist/emblems/emblem.core.js +85 -11
- package/dist/emblems/emblem.descriptions.d.ts +7 -0
- package/dist/emblems/emblem.descriptions.js +60 -0
- package/dist/emblems/emblem.display.d.ts +75 -0
- package/dist/emblems/emblem.display.js +214 -0
- package/dist/emblems/emblem.engrave.d.ts +50 -0
- package/dist/emblems/emblem.engrave.js +145 -0
- package/dist/emblems/emblem.equipment.d.ts +24 -0
- package/dist/emblems/emblem.equipment.js +57 -0
- package/dist/emblems/emblem.flip.d.ts +10 -0
- package/dist/emblems/emblem.flip.js +45 -0
- package/dist/emblems/emblem.ids.d.ts +44 -30
- package/dist/emblems/emblem.ids.js +51 -17
- package/dist/emblems/emblem.lathe.d.ts +62 -0
- package/dist/emblems/emblem.lathe.js +426 -0
- package/dist/emblems/emblem.medal.d.ts +6 -0
- package/dist/emblems/emblem.medal.js +38 -0
- package/dist/emblems/emblem.pennant.d.ts +3 -0
- package/dist/emblems/emblem.pennant.js +79 -0
- package/dist/emblems/emblem.registry.js +162 -4
- package/dist/emblems/emblem.shapes.d.ts +48 -12
- package/dist/emblems/emblem.shapes.js +138 -31
- package/dist/emblems/emblem.sprite.d.ts +38 -0
- package/dist/emblems/emblem.sprite.js +65 -0
- package/dist/emblems/emblem.uri.d.ts +22 -0
- package/dist/emblems/emblem.uri.js +29 -0
- package/dist/emblems/gear/gear.badmintonracket.d.ts +1 -0
- package/dist/emblems/gear/gear.badmintonracket.js +19 -0
- package/dist/emblems/gear/gear.baseballglove.d.ts +1 -0
- package/dist/emblems/gear/gear.baseballglove.js +21 -0
- package/dist/emblems/gear/gear.budo.d.ts +17 -0
- package/dist/emblems/gear/gear.budo.js +60 -0
- package/dist/emblems/gear/gear.core.d.ts +64 -0
- package/dist/emblems/gear/gear.core.js +127 -0
- package/dist/emblems/gear/gear.cricketbat.d.ts +1 -0
- package/dist/emblems/gear/gear.cricketbat.js +17 -0
- package/dist/emblems/gear/gear.field.d.ts +6 -0
- package/dist/emblems/gear/gear.field.js +81 -0
- package/dist/emblems/gear/gear.fieldhockeystick.d.ts +1 -0
- package/dist/emblems/gear/gear.fieldhockeystick.js +16 -0
- package/dist/emblems/gear/gear.footballhelmet.d.ts +1 -0
- package/dist/emblems/gear/gear.footballhelmet.js +16 -0
- package/dist/emblems/gear/gear.goaliemask.d.ts +1 -0
- package/dist/emblems/gear/gear.goaliemask.js +23 -0
- package/dist/emblems/gear/gear.goalnet.d.ts +1 -0
- package/dist/emblems/gear/gear.goalnet.js +25 -0
- package/dist/emblems/gear/gear.hockeystick.d.ts +1 -0
- package/dist/emblems/gear/gear.hockeystick.js +15 -0
- package/dist/emblems/gear/gear.index.d.ts +22 -0
- package/dist/emblems/gear/gear.index.js +49 -0
- package/dist/emblems/gear/gear.kendo.d.ts +2 -0
- package/dist/emblems/gear/gear.kendo.js +41 -0
- package/dist/emblems/gear/gear.kyudo.d.ts +2 -0
- package/dist/emblems/gear/gear.kyudo.js +31 -0
- package/dist/emblems/gear/gear.lacrossestick.d.ts +1 -0
- package/dist/emblems/gear/gear.lacrossestick.js +26 -0
- package/dist/emblems/gear/gear.rackets.d.ts +4 -0
- package/dist/emblems/gear/gear.rackets.js +60 -0
- package/dist/emblems/gear/gear.skates.d.ts +3 -0
- package/dist/emblems/gear/gear.skates.js +39 -0
- package/dist/emblems/gear/gear.sticks.d.ts +3 -0
- package/dist/emblems/gear/gear.sticks.js +34 -0
- package/dist/emblems/gear/gear.sumo.d.ts +2 -0
- package/dist/emblems/gear/gear.sumo.js +43 -0
- package/dist/emblems/gear/gear.tabletennispaddle.d.ts +1 -0
- package/dist/emblems/gear/gear.tabletennispaddle.js +16 -0
- package/dist/emblems/gear/gear.tennisracket.d.ts +1 -0
- package/dist/emblems/gear/gear.tennisracket.js +17 -0
- package/dist/emblems/gear/gear.track.d.ts +4 -0
- package/dist/emblems/gear/gear.track.js +45 -0
- package/dist/emblems/gear/gear.water.d.ts +2 -0
- package/dist/emblems/gear/gear.water.js +25 -0
- package/dist/emblems/medal/bronze.d.ts +2 -0
- package/dist/emblems/medal/bronze.js +4 -0
- package/dist/emblems/medal/gold.d.ts +2 -0
- package/dist/emblems/medal/gold.js +4 -0
- package/dist/emblems/medal/place-1.d.ts +2 -0
- package/dist/emblems/medal/place-1.js +4 -0
- package/dist/emblems/medal/place-2.d.ts +2 -0
- package/dist/emblems/medal/place-2.js +4 -0
- package/dist/emblems/medal/place-3.d.ts +2 -0
- package/dist/emblems/medal/place-3.js +4 -0
- package/dist/emblems/medal/silver.d.ts +2 -0
- package/dist/emblems/medal/silver.js +4 -0
- package/dist/emblems/pennant/championship.d.ts +2 -0
- package/dist/emblems/pennant/championship.js +4 -0
- package/dist/emblems/sport/afl.d.ts +2 -0
- package/dist/emblems/sport/afl.js +12 -0
- package/dist/emblems/sport/artisticswimming.d.ts +2 -0
- package/dist/emblems/sport/artisticswimming.js +16 -0
- package/dist/emblems/sport/athletics.d.ts +2 -0
- package/dist/emblems/sport/athletics.js +12 -0
- package/dist/emblems/sport/badminton.d.ts +2 -0
- package/dist/emblems/sport/badminton.js +13 -0
- package/dist/emblems/sport/cfl.d.ts +2 -0
- package/dist/emblems/sport/cfl.js +5 -0
- package/dist/emblems/sport/cricket.d.ts +2 -0
- package/dist/emblems/sport/cricket.js +14 -0
- package/dist/emblems/sport/curling.d.ts +2 -0
- package/dist/emblems/sport/curling.js +14 -0
- package/dist/emblems/sport/diving.d.ts +2 -0
- package/dist/emblems/sport/diving.js +18 -0
- package/dist/emblems/sport/fieldhockey.d.ts +2 -0
- package/dist/emblems/sport/fieldhockey.js +11 -0
- package/dist/emblems/sport/gaelic.d.ts +2 -0
- package/dist/emblems/sport/gaelic.js +11 -0
- package/dist/emblems/sport/handball.d.ts +2 -0
- package/dist/emblems/sport/handball.js +15 -0
- package/dist/emblems/sport/ifaf.d.ts +2 -0
- package/dist/emblems/sport/ifaf.js +5 -0
- package/dist/emblems/sport/judo.d.ts +2 -0
- package/dist/emblems/sport/judo.js +13 -0
- package/dist/emblems/sport/karate.d.ts +2 -0
- package/dist/emblems/sport/karate.js +13 -0
- package/dist/emblems/sport/kendo.d.ts +2 -0
- package/dist/emblems/sport/kendo.js +14 -0
- package/dist/emblems/sport/kyudo.d.ts +2 -0
- package/dist/emblems/sport/kyudo.js +15 -0
- package/dist/emblems/sport/lacrosse.d.ts +2 -0
- package/dist/emblems/sport/lacrosse.js +13 -0
- package/dist/emblems/sport/mlb.d.ts +2 -0
- package/dist/emblems/sport/mlb.js +28 -0
- package/dist/emblems/sport/nba.d.ts +2 -0
- package/dist/emblems/sport/nba.js +12 -0
- package/dist/emblems/sport/netball.d.ts +2 -0
- package/dist/emblems/sport/netball.js +14 -0
- package/dist/emblems/sport/nfl.d.ts +3 -0
- package/dist/emblems/sport/nfl.js +15 -0
- package/dist/emblems/sport/nhl.d.ts +2 -0
- package/dist/emblems/sport/nhl.js +13 -0
- package/dist/emblems/sport/padel.d.ts +2 -0
- package/dist/emblems/sport/padel.js +14 -0
- package/dist/emblems/sport/pickleball.d.ts +2 -0
- package/dist/emblems/sport/pickleball.js +13 -0
- package/dist/emblems/sport/racquetball.d.ts +2 -0
- package/dist/emblems/sport/racquetball.js +13 -0
- package/dist/emblems/sport/roundnet.d.ts +2 -0
- package/dist/emblems/sport/roundnet.js +15 -0
- package/dist/emblems/sport/rugby.d.ts +2 -0
- package/dist/emblems/sport/rugby.js +12 -0
- package/dist/emblems/sport/sepaktakraw.d.ts +2 -0
- package/dist/emblems/sport/sepaktakraw.js +11 -0
- package/dist/emblems/sport/skating.d.ts +2 -0
- package/dist/emblems/sport/skating.js +14 -0
- package/dist/emblems/sport/soccer.d.ts +2 -0
- package/dist/emblems/sport/soccer.js +31 -0
- package/dist/emblems/sport/squash.d.ts +2 -0
- package/dist/emblems/sport/squash.js +15 -0
- package/dist/emblems/sport/sumo.d.ts +2 -0
- package/dist/emblems/sport/sumo.js +15 -0
- package/dist/emblems/sport/swimming.d.ts +2 -0
- package/dist/emblems/sport/swimming.js +15 -0
- package/dist/emblems/sport/tabletennis.d.ts +2 -0
- package/dist/emblems/sport/tabletennis.js +12 -0
- package/dist/emblems/sport/tennis.d.ts +2 -0
- package/dist/emblems/sport/tennis.js +15 -0
- package/dist/emblems/sport/teqball.d.ts +2 -0
- package/dist/emblems/sport/teqball.js +15 -0
- package/dist/emblems/sport/volleyball.d.ts +2 -0
- package/dist/emblems/sport/volleyball.js +25 -0
- package/dist/emblems/sport/waterpolo.d.ts +2 -0
- package/dist/emblems/sport/waterpolo.js +15 -0
- package/dist/emblems/trophy/banner.d.ts +2 -0
- package/dist/emblems/trophy/banner.js +20 -0
- package/dist/emblems/trophy/baseball.d.ts +2 -0
- package/dist/emblems/trophy/baseball.js +15 -0
- package/dist/emblems/trophy/basketball.d.ts +2 -0
- package/dist/emblems/trophy/basketball.js +17 -0
- package/dist/emblems/trophy/belt.d.ts +2 -0
- package/dist/emblems/trophy/belt.js +17 -0
- package/dist/emblems/trophy/bowl.d.ts +2 -0
- package/dist/emblems/trophy/bowl.js +8 -0
- package/dist/emblems/trophy/canadian-bowl.d.ts +2 -0
- package/dist/emblems/trophy/canadian-bowl.js +23 -0
- package/dist/emblems/trophy/championship-banner.d.ts +2 -0
- package/dist/emblems/trophy/championship-banner.js +67 -0
- package/dist/emblems/trophy/cricket-urn.d.ts +2 -0
- package/dist/emblems/trophy/cricket-urn.js +23 -0
- package/dist/emblems/trophy/cup.d.ts +2 -0
- package/dist/emblems/trophy/cup.js +16 -0
- package/dist/emblems/trophy/football.d.ts +2 -0
- package/dist/emblems/trophy/football.js +11 -0
- package/dist/emblems/trophy/globe.d.ts +2 -0
- package/dist/emblems/trophy/globe.js +9 -0
- package/dist/emblems/trophy/hockey-cup.d.ts +2 -0
- package/dist/emblems/trophy/hockey-cup.js +22 -0
- package/dist/emblems/trophy/laurel.d.ts +2 -0
- package/dist/emblems/trophy/laurel.js +40 -0
- package/dist/emblems/trophy/lidded-cup.d.ts +2 -0
- package/dist/emblems/trophy/lidded-cup.js +21 -0
- package/dist/emblems/trophy/plaque.d.ts +2 -0
- package/dist/emblems/trophy/plaque.js +17 -0
- package/dist/emblems/trophy/ring.d.ts +2 -0
- package/dist/emblems/trophy/ring.js +30 -0
- package/dist/emblems/trophy/rosette.d.ts +2 -0
- package/dist/emblems/trophy/rosette.js +27 -0
- package/dist/emblems/trophy/rugby-cup.d.ts +2 -0
- package/dist/emblems/trophy/rugby-cup.js +23 -0
- package/dist/emblems/trophy/salver.d.ts +2 -0
- package/dist/emblems/trophy/salver.js +9 -0
- package/dist/emblems/trophy/soccer-ball.d.ts +2 -0
- package/dist/emblems/trophy/soccer-ball.js +9 -0
- package/dist/emblems/trophy/soccer-globe.d.ts +2 -0
- package/dist/emblems/trophy/soccer-globe.js +18 -0
- package/dist/emblems/trophy/sumo-cup.d.ts +2 -0
- package/dist/emblems/trophy/sumo-cup.js +28 -0
- package/dist/emblems/trophy/tennis-cup.d.ts +2 -0
- package/dist/emblems/trophy/tennis-cup.js +24 -0
- package/dist/emblems/trophy/tennis-plate.d.ts +2 -0
- package/dist/emblems/trophy/tennis-plate.js +16 -0
- package/dist/emblems-entry.d.ts +20 -7
- package/dist/emblems-entry.js +8 -2
- package/dist/index.d.ts +131 -1
- package/dist/index.js +131 -3
- package/dist/turn-control.d.ts +101 -0
- package/dist/turn-control.js +363 -0
- package/dist/turn-entry.d.ts +2 -0
- package/dist/turn-entry.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +33 -7
- package/LICENSES/Apache-2.0.txt +0 -55
- package/LICENSES/CC-BY-3.0.md +0 -15
- package/dist/emblems/ball/soccer.d.ts +0 -2
- package/dist/emblems/ball/soccer.js +0 -9
- package/dist/emblems/emblem.ball.d.ts +0 -28
- package/dist/emblems/emblem.ball.js +0 -70
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
// `bindTurn`: an emblem that a pointer, the arrow keys, the Space bar or a clock can turn. It draws `emblemFrame` into an element and listens to that element, and it is a module of its own, so importing an
|
|
2
|
+
// emblem never pulls it in. Nothing here moves by itself: an auto-turn starts only when the caller asks for it, and not at all under `prefers-reduced-motion` unless the caller forces it.
|
|
3
|
+
import { emblemFrame, emblemOf, renderEmblem } from "./emblems/emblem.api.js";
|
|
4
|
+
const WORDS = {
|
|
5
|
+
en: { role: "turnable emblem", hint: "Drag, or use the arrow keys, to turn it. Space starts and stops the turning." },
|
|
6
|
+
ja: { role: "回せるエンブレム", hint: "ドラッグするか矢印キーで回せます。スペースキーで自動回転を始めたり止めたりできます。" },
|
|
7
|
+
};
|
|
8
|
+
/** An angle wrapped into -180 (excluded) to 180, as the demo's slider is. */
|
|
9
|
+
export function wrapAngle(value) {
|
|
10
|
+
const turn = ((value % 360) + 360) % 360;
|
|
11
|
+
return turn > 180 ? turn - 360 : turn;
|
|
12
|
+
}
|
|
13
|
+
const finite = (value, fallback) => (typeof value === "number" && Number.isFinite(value) ? value : fallback);
|
|
14
|
+
const clamp = (value, low, high) => Math.max(low, Math.min(high, value));
|
|
15
|
+
const globals = globalThis;
|
|
16
|
+
/** Whether an emblem turns at all, read from the registry's own frames: a turned view that differs from the resting one. An emblem may say so itself with a `turnable` flag. */
|
|
17
|
+
const turns = new WeakMap();
|
|
18
|
+
function canTurn(emblem) {
|
|
19
|
+
const flag = emblem.turnable;
|
|
20
|
+
if (typeof flag === "boolean")
|
|
21
|
+
return flag;
|
|
22
|
+
let known = turns.get(emblem);
|
|
23
|
+
if (known === undefined) {
|
|
24
|
+
known = emblem.frame({ size: 16, yaw: 90 }) !== emblem.frame({ size: 16 });
|
|
25
|
+
turns.set(emblem, known);
|
|
26
|
+
}
|
|
27
|
+
return known;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Binds an emblem to an element so that it can be turned: it draws `emblemFrame` into `container`, and a drag turns it (left and right are yaw, up and down are pitch, and Shift on a ball is roll), the arrow keys turn
|
|
31
|
+
* it, Home or 0 puts it back, and Space starts and stops an auto-turn. An emblem that cannot turn is drawn as it is, and nothing is listened to. Nothing moves by itself: `autoPlay` is off by default and, under
|
|
32
|
+
* `prefers-reduced-motion`, only starts when it is `"force"`. The element gets `touch-action: none`, `user-select: none`, a grab cursor, a tab stop, a role description and a hint; `destroy()` takes them away.
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { bindTurn } from "@johnmorrisdotca/dougu-sports/turn";
|
|
36
|
+
* const turner = bindTurn(document.getElementById("cup")!, "trophy:tennis-cup", { size: 160 });
|
|
37
|
+
* turner.setAngles({ yaw: 40 });
|
|
38
|
+
* console.log(turner.angles.yaw);
|
|
39
|
+
* // 40
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function bindTurn(container, ref, options = {}) {
|
|
43
|
+
let current = ref;
|
|
44
|
+
let emblem = emblemOf(ref).emblem;
|
|
45
|
+
let turnable = false;
|
|
46
|
+
let sensitivity = 1.5;
|
|
47
|
+
let range = [-60, 60];
|
|
48
|
+
let keyStep = 5;
|
|
49
|
+
let speed = 36;
|
|
50
|
+
let pauseOnInteract = true;
|
|
51
|
+
let locale = "en";
|
|
52
|
+
let onTurn;
|
|
53
|
+
let onPlayChange;
|
|
54
|
+
let frame = {};
|
|
55
|
+
const angles = { yaw: 0, pitch: 0, roll: 0 };
|
|
56
|
+
let playing = false;
|
|
57
|
+
let held = false;
|
|
58
|
+
let frameId;
|
|
59
|
+
let renderId;
|
|
60
|
+
let last;
|
|
61
|
+
let attached = false;
|
|
62
|
+
let drag;
|
|
63
|
+
let destroyed = false;
|
|
64
|
+
/** What `bindTurn` changed on the element, to put back. */
|
|
65
|
+
let saved;
|
|
66
|
+
const configure = (o) => {
|
|
67
|
+
sensitivity = clamp(finite(o.sensitivity, 1.5), 0.05, 20);
|
|
68
|
+
const low = finite(o.pitchRange?.[0], -60);
|
|
69
|
+
const high = finite(o.pitchRange?.[1], 60);
|
|
70
|
+
range = low <= high ? [low, high] : [high, low];
|
|
71
|
+
keyStep = clamp(finite(o.keyStep, 5), 0.5, 90);
|
|
72
|
+
speed = clamp(finite(o.speed, 36), -720, 720);
|
|
73
|
+
pauseOnInteract = o.pauseOnInteract !== false;
|
|
74
|
+
locale = o.locale === "ja" ? "ja" : "en";
|
|
75
|
+
onTurn = typeof o.onTurn === "function" ? o.onTurn : undefined;
|
|
76
|
+
onPlayChange = typeof o.onPlayChange === "function" ? o.onPlayChange : undefined;
|
|
77
|
+
const rest = { ...o };
|
|
78
|
+
for (const name of ["sensitivity", "pitchRange", "keyStep", "onTurn", "autoPlay", "speed", "pauseOnInteract", "onPlayChange", "yaw", "pitch", "roll"])
|
|
79
|
+
delete rest[name];
|
|
80
|
+
frame = rest;
|
|
81
|
+
};
|
|
82
|
+
const place = (partial) => {
|
|
83
|
+
if (partial.yaw !== undefined)
|
|
84
|
+
angles.yaw = wrapAngle(finite(partial.yaw, angles.yaw));
|
|
85
|
+
if (partial.pitch !== undefined)
|
|
86
|
+
angles.pitch = clamp(finite(partial.pitch, angles.pitch), range[0], range[1]);
|
|
87
|
+
if (partial.roll !== undefined)
|
|
88
|
+
angles.roll = wrapAngle(finite(partial.roll, angles.roll));
|
|
89
|
+
};
|
|
90
|
+
const copy = () => ({ yaw: angles.yaw, pitch: angles.pitch, roll: angles.roll });
|
|
91
|
+
const draw = () => {
|
|
92
|
+
if (renderId !== undefined) {
|
|
93
|
+
globals.cancelAnimationFrame?.(renderId);
|
|
94
|
+
renderId = undefined;
|
|
95
|
+
}
|
|
96
|
+
const at = angles.yaw === 0 && angles.pitch === 0 && angles.roll === 0;
|
|
97
|
+
container.innerHTML = !turnable || at ? renderEmblem(current, frame) : emblemFrame(current, { ...frame, ...angles });
|
|
98
|
+
};
|
|
99
|
+
/** One drawing for any number of changes within a frame. */
|
|
100
|
+
const schedule = () => {
|
|
101
|
+
if (renderId !== undefined || destroyed)
|
|
102
|
+
return;
|
|
103
|
+
if (globals.requestAnimationFrame === undefined)
|
|
104
|
+
draw();
|
|
105
|
+
else
|
|
106
|
+
renderId = globals.requestAnimationFrame(() => {
|
|
107
|
+
renderId = undefined;
|
|
108
|
+
draw();
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
const changed = () => {
|
|
112
|
+
schedule();
|
|
113
|
+
onTurn?.(copy());
|
|
114
|
+
};
|
|
115
|
+
const setPlaying = (value) => {
|
|
116
|
+
if (playing === value)
|
|
117
|
+
return;
|
|
118
|
+
playing = value;
|
|
119
|
+
if (!value && frameId !== undefined) {
|
|
120
|
+
globals.cancelAnimationFrame?.(frameId);
|
|
121
|
+
frameId = undefined;
|
|
122
|
+
}
|
|
123
|
+
last = undefined;
|
|
124
|
+
if (value)
|
|
125
|
+
loop();
|
|
126
|
+
onPlayChange?.(value);
|
|
127
|
+
};
|
|
128
|
+
const hidden = () => globals.document?.hidden === true;
|
|
129
|
+
const tick = (time) => {
|
|
130
|
+
frameId = undefined;
|
|
131
|
+
if (!playing || destroyed)
|
|
132
|
+
return;
|
|
133
|
+
if (hidden()) {
|
|
134
|
+
last = undefined;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const dt = last === undefined ? 0 : clamp((time - last) / 1000, 0, 0.1);
|
|
138
|
+
last = time;
|
|
139
|
+
if (!held && dt > 0) {
|
|
140
|
+
place({ yaw: angles.yaw + speed * dt });
|
|
141
|
+
draw();
|
|
142
|
+
onTurn?.(copy());
|
|
143
|
+
}
|
|
144
|
+
loop();
|
|
145
|
+
};
|
|
146
|
+
const loop = () => {
|
|
147
|
+
if (frameId === undefined && playing && !destroyed && globals.requestAnimationFrame !== undefined)
|
|
148
|
+
frameId = globals.requestAnimationFrame(tick);
|
|
149
|
+
};
|
|
150
|
+
const visibility = () => {
|
|
151
|
+
if (playing && !hidden()) {
|
|
152
|
+
last = undefined;
|
|
153
|
+
loop();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
/** Something the reader did takes over from the auto-turn. */
|
|
157
|
+
const interrupt = () => {
|
|
158
|
+
if (pauseOnInteract)
|
|
159
|
+
setPlaying(false);
|
|
160
|
+
};
|
|
161
|
+
const down = (event) => {
|
|
162
|
+
if (event.button !== 0 || event.isPrimary === false)
|
|
163
|
+
return;
|
|
164
|
+
drag = { pointer: finite(event.pointerId, 0), x: finite(event.clientX, 0), y: finite(event.clientY, 0) };
|
|
165
|
+
container.setPointerCapture?.(drag.pointer);
|
|
166
|
+
container.style.cursor = "grabbing";
|
|
167
|
+
held = pauseOnInteract;
|
|
168
|
+
};
|
|
169
|
+
const move = (event) => {
|
|
170
|
+
if (drag === undefined || finite(event.pointerId, 0) !== drag.pointer)
|
|
171
|
+
return;
|
|
172
|
+
const x = finite(event.clientX, drag.x);
|
|
173
|
+
const y = finite(event.clientY, drag.y);
|
|
174
|
+
const dx = (x - drag.x) * sensitivity;
|
|
175
|
+
const dy = (y - drag.y) * sensitivity;
|
|
176
|
+
drag.x = x;
|
|
177
|
+
drag.y = y;
|
|
178
|
+
if (dx === 0 && dy === 0)
|
|
179
|
+
return;
|
|
180
|
+
if (event.shiftKey === true && emblem.kind === "ball")
|
|
181
|
+
place({ roll: angles.roll + dx, pitch: angles.pitch - dy });
|
|
182
|
+
else
|
|
183
|
+
place({ yaw: angles.yaw + dx, pitch: angles.pitch - dy });
|
|
184
|
+
changed();
|
|
185
|
+
};
|
|
186
|
+
const up = (event) => {
|
|
187
|
+
if (drag === undefined || finite(event.pointerId, 0) !== drag.pointer)
|
|
188
|
+
return;
|
|
189
|
+
container.releasePointerCapture?.(drag.pointer);
|
|
190
|
+
drag = undefined;
|
|
191
|
+
held = false;
|
|
192
|
+
last = undefined;
|
|
193
|
+
container.style.cursor = "grab";
|
|
194
|
+
};
|
|
195
|
+
const key = (event) => {
|
|
196
|
+
if (event.ctrlKey === true || event.metaKey === true || event.altKey === true)
|
|
197
|
+
return;
|
|
198
|
+
const step = event.shiftKey === true ? keyStep * 3 : keyStep;
|
|
199
|
+
switch (event.key) {
|
|
200
|
+
case "ArrowLeft":
|
|
201
|
+
place({ yaw: angles.yaw - step });
|
|
202
|
+
break;
|
|
203
|
+
case "ArrowRight":
|
|
204
|
+
place({ yaw: angles.yaw + step });
|
|
205
|
+
break;
|
|
206
|
+
case "ArrowUp":
|
|
207
|
+
place({ pitch: angles.pitch + step });
|
|
208
|
+
break;
|
|
209
|
+
case "ArrowDown":
|
|
210
|
+
place({ pitch: angles.pitch - step });
|
|
211
|
+
break;
|
|
212
|
+
case "Home":
|
|
213
|
+
case "0":
|
|
214
|
+
place({ yaw: 0, pitch: 0, roll: 0 });
|
|
215
|
+
break;
|
|
216
|
+
case " ":
|
|
217
|
+
case "Spacebar":
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
setPlaying(!playing);
|
|
220
|
+
return;
|
|
221
|
+
default:
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
event.preventDefault();
|
|
225
|
+
interrupt();
|
|
226
|
+
changed();
|
|
227
|
+
};
|
|
228
|
+
const LISTENERS = [
|
|
229
|
+
["pointerdown", down],
|
|
230
|
+
["pointermove", move],
|
|
231
|
+
["pointerup", up],
|
|
232
|
+
["pointercancel", up],
|
|
233
|
+
["lostpointercapture", up],
|
|
234
|
+
["keydown", key],
|
|
235
|
+
];
|
|
236
|
+
const attach = () => {
|
|
237
|
+
if (attached)
|
|
238
|
+
return;
|
|
239
|
+
attached = true;
|
|
240
|
+
const attributes = new Map();
|
|
241
|
+
const wanted = [
|
|
242
|
+
["tabindex", "0"],
|
|
243
|
+
["role", "group"],
|
|
244
|
+
["aria-roledescription", WORDS[locale].role],
|
|
245
|
+
["aria-description", WORDS[locale].hint],
|
|
246
|
+
];
|
|
247
|
+
for (const [name, value] of wanted) {
|
|
248
|
+
const before = container.getAttribute(name);
|
|
249
|
+
attributes.set(name, before);
|
|
250
|
+
// A tab stop or a role the page gave the element stays; the two descriptions are ours.
|
|
251
|
+
if (before === null || name.startsWith("aria-"))
|
|
252
|
+
container.setAttribute(name, value);
|
|
253
|
+
}
|
|
254
|
+
const style = container.style;
|
|
255
|
+
saved = { attributes, style: { touchAction: style.touchAction, userSelect: style.userSelect, cursor: style.cursor, webkitUserSelect: style.webkitUserSelect } };
|
|
256
|
+
style.touchAction = "none";
|
|
257
|
+
style.userSelect = "none";
|
|
258
|
+
if (style.webkitUserSelect !== undefined)
|
|
259
|
+
style.webkitUserSelect = "none";
|
|
260
|
+
style.cursor = "grab";
|
|
261
|
+
for (const [type, listener] of LISTENERS)
|
|
262
|
+
container.addEventListener(type, listener);
|
|
263
|
+
globals.document?.addEventListener("visibilitychange", visibility);
|
|
264
|
+
};
|
|
265
|
+
const detach = () => {
|
|
266
|
+
if (!attached)
|
|
267
|
+
return;
|
|
268
|
+
attached = false;
|
|
269
|
+
for (const [type, listener] of LISTENERS)
|
|
270
|
+
container.removeEventListener(type, listener);
|
|
271
|
+
globals.document?.removeEventListener("visibilitychange", visibility);
|
|
272
|
+
if (saved !== undefined) {
|
|
273
|
+
for (const [name, before] of saved.attributes) {
|
|
274
|
+
if (before === null)
|
|
275
|
+
container.removeAttribute(name);
|
|
276
|
+
else
|
|
277
|
+
container.setAttribute(name, before);
|
|
278
|
+
}
|
|
279
|
+
container.style.touchAction = saved.style.touchAction;
|
|
280
|
+
container.style.userSelect = saved.style.userSelect;
|
|
281
|
+
if (saved.style.webkitUserSelect !== undefined)
|
|
282
|
+
container.style.webkitUserSelect = saved.style.webkitUserSelect;
|
|
283
|
+
container.style.cursor = saved.style.cursor;
|
|
284
|
+
saved = undefined;
|
|
285
|
+
}
|
|
286
|
+
drag = undefined;
|
|
287
|
+
held = false;
|
|
288
|
+
};
|
|
289
|
+
const settle = () => {
|
|
290
|
+
emblem = emblemOf(current).emblem;
|
|
291
|
+
turnable = canTurn(emblem);
|
|
292
|
+
if (turnable)
|
|
293
|
+
attach();
|
|
294
|
+
else {
|
|
295
|
+
detach();
|
|
296
|
+
setPlaying(false);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
configure(options);
|
|
300
|
+
place({ yaw: options.yaw, pitch: options.pitch, roll: options.roll });
|
|
301
|
+
settle();
|
|
302
|
+
draw();
|
|
303
|
+
if (turnable && options.autoPlay !== undefined && options.autoPlay !== false) {
|
|
304
|
+
const reduced = globals.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
|
|
305
|
+
if (options.autoPlay === "force" || !reduced)
|
|
306
|
+
setPlaying(true);
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
get angles() {
|
|
310
|
+
return copy();
|
|
311
|
+
},
|
|
312
|
+
get playing() {
|
|
313
|
+
return playing;
|
|
314
|
+
},
|
|
315
|
+
get turnable() {
|
|
316
|
+
return turnable;
|
|
317
|
+
},
|
|
318
|
+
setAngles(partial) {
|
|
319
|
+
if (destroyed)
|
|
320
|
+
return;
|
|
321
|
+
place(partial);
|
|
322
|
+
interrupt();
|
|
323
|
+
draw();
|
|
324
|
+
},
|
|
325
|
+
update(next, o = {}) {
|
|
326
|
+
if (destroyed)
|
|
327
|
+
return;
|
|
328
|
+
current = next;
|
|
329
|
+
configure(o);
|
|
330
|
+
place({ yaw: o.yaw, pitch: o.pitch, roll: o.roll });
|
|
331
|
+
// The pitch the new range allows.
|
|
332
|
+
place({ pitch: angles.pitch });
|
|
333
|
+
detach();
|
|
334
|
+
settle();
|
|
335
|
+
draw();
|
|
336
|
+
},
|
|
337
|
+
play() {
|
|
338
|
+
if (!turnable || destroyed)
|
|
339
|
+
return false;
|
|
340
|
+
setPlaying(true);
|
|
341
|
+
return true;
|
|
342
|
+
},
|
|
343
|
+
pause() {
|
|
344
|
+
setPlaying(false);
|
|
345
|
+
},
|
|
346
|
+
togglePlay() {
|
|
347
|
+
if (!turnable || destroyed)
|
|
348
|
+
return false;
|
|
349
|
+
setPlaying(!playing);
|
|
350
|
+
return playing;
|
|
351
|
+
},
|
|
352
|
+
destroy() {
|
|
353
|
+
if (destroyed)
|
|
354
|
+
return;
|
|
355
|
+
setPlaying(false);
|
|
356
|
+
destroyed = true;
|
|
357
|
+
if (renderId !== undefined)
|
|
358
|
+
globals.cancelAnimationFrame?.(renderId);
|
|
359
|
+
renderId = undefined;
|
|
360
|
+
detach();
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
}
|
package/dist/turn-entry.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { ballFrame, emblemFrame } from "./emblems/emblem.api.ts";
|
|
2
2
|
export type { FrameOptions } from "./emblems/emblem.core.ts";
|
|
3
|
+
export { bindTurn } from "./turn-control.ts";
|
|
4
|
+
export type { TurnAngles, TurnContainer, TurnControlOptions, TurnController, TurnEvent } from "./turn-control.ts";
|
package/dist/turn-entry.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
// The turning entry point: an emblem at an angle. `emblemFrame` turns any emblem about its vertical axis and tilts it; `ballFrame` rolls a ball. Each frame is plain SVG, so a turn is a loop over
|
|
2
2
|
// the angle, drawn by the caller (a slider, a requestAnimationFrame, a CSS-free animation).
|
|
3
3
|
export { ballFrame, emblemFrame } from "./emblems/emblem.api.js";
|
|
4
|
+
export { bindTurn } from "./turn-control.js";
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.0
|
|
1
|
+
export declare const VERSION = "0.2.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.0
|
|
1
|
+
export const VERSION = "0.2.0";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/dougu-sports",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "Dougu Sports 道具, sports emblems as SVG strings: trophies, medals, crests, and the ball and gear of every sport, in metal, line or flat colour, with optional 3D turning. Light and dark, accessible, tree-shakeable. Zero dependencies.",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Dougu Sports 道具, sports emblems as SVG strings: trophies, medals, crests, sport icons, and the ball and gear of every sport, in metal, line or flat colour, with optional 3D turning. Light and dark, accessible, tree-shakeable. Zero dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sports",
|
|
7
7
|
"emblem",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"ball",
|
|
13
13
|
"sports-equipment",
|
|
14
14
|
"sports-icons",
|
|
15
|
+
"pennant",
|
|
15
16
|
"icons",
|
|
16
17
|
"svg",
|
|
17
18
|
"3d",
|
|
@@ -57,6 +58,31 @@
|
|
|
57
58
|
"import": "./dist/turn-entry.js",
|
|
58
59
|
"default": "./dist/turn-entry.js"
|
|
59
60
|
},
|
|
61
|
+
"./award/*": {
|
|
62
|
+
"types": "./dist/emblems/award/*.d.ts",
|
|
63
|
+
"import": "./dist/emblems/award/*.js",
|
|
64
|
+
"default": "./dist/emblems/award/*.js"
|
|
65
|
+
},
|
|
66
|
+
"./trophy/*": {
|
|
67
|
+
"types": "./dist/emblems/trophy/*.d.ts",
|
|
68
|
+
"import": "./dist/emblems/trophy/*.js",
|
|
69
|
+
"default": "./dist/emblems/trophy/*.js"
|
|
70
|
+
},
|
|
71
|
+
"./medal/*": {
|
|
72
|
+
"types": "./dist/emblems/medal/*.d.ts",
|
|
73
|
+
"import": "./dist/emblems/medal/*.js",
|
|
74
|
+
"default": "./dist/emblems/medal/*.js"
|
|
75
|
+
},
|
|
76
|
+
"./crest/*": {
|
|
77
|
+
"types": "./dist/emblems/crest/*.d.ts",
|
|
78
|
+
"import": "./dist/emblems/crest/*.js",
|
|
79
|
+
"default": "./dist/emblems/crest/*.js"
|
|
80
|
+
},
|
|
81
|
+
"./sport/*": {
|
|
82
|
+
"types": "./dist/emblems/sport/*.d.ts",
|
|
83
|
+
"import": "./dist/emblems/sport/*.js",
|
|
84
|
+
"default": "./dist/emblems/sport/*.js"
|
|
85
|
+
},
|
|
60
86
|
"./ball/*": {
|
|
61
87
|
"types": "./dist/emblems/ball/*.d.ts",
|
|
62
88
|
"import": "./dist/emblems/ball/*.js",
|
|
@@ -67,10 +93,10 @@
|
|
|
67
93
|
"import": "./dist/emblems/gear/*.js",
|
|
68
94
|
"default": "./dist/emblems/gear/*.js"
|
|
69
95
|
},
|
|
70
|
-
"./
|
|
71
|
-
"types": "./dist/emblems/
|
|
72
|
-
"import": "./dist/emblems/
|
|
73
|
-
"default": "./dist/emblems/
|
|
96
|
+
"./pennant/*": {
|
|
97
|
+
"types": "./dist/emblems/pennant/*.d.ts",
|
|
98
|
+
"import": "./dist/emblems/pennant/*.js",
|
|
99
|
+
"default": "./dist/emblems/pennant/*.js"
|
|
74
100
|
}
|
|
75
101
|
},
|
|
76
102
|
"files": [
|
|
@@ -88,7 +114,7 @@
|
|
|
88
114
|
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json",
|
|
89
115
|
"lint": "eslint .",
|
|
90
116
|
"typecheck": "tsc -p tsconfig.check.json",
|
|
91
|
-
"test": "node --test test/*.test.ts",
|
|
117
|
+
"test": "node --test test/*.test.ts test/*.test.js",
|
|
92
118
|
"test:package": "pnpm build && node scripts/check-package.mjs",
|
|
93
119
|
"test:readme": "pnpm build && node scripts/make-gallery.mjs --check && node scripts/check-readme-examples.mjs",
|
|
94
120
|
"check": "pnpm lint && pnpm typecheck && pnpm test && pnpm build && node scripts/check-package.mjs",
|
package/LICENSES/Apache-2.0.txt
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
|
|
5
|
-
http://www.apache.org/licenses/
|
|
6
|
-
|
|
7
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
-
|
|
9
|
-
1. Definitions.
|
|
10
|
-
|
|
11
|
-
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
16
|
-
|
|
17
|
-
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
18
|
-
|
|
19
|
-
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
20
|
-
|
|
21
|
-
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
22
|
-
|
|
23
|
-
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
24
|
-
|
|
25
|
-
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
26
|
-
|
|
27
|
-
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
28
|
-
|
|
29
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
30
|
-
|
|
31
|
-
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
-
|
|
33
|
-
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
34
|
-
|
|
35
|
-
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
36
|
-
|
|
37
|
-
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
38
|
-
|
|
39
|
-
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
40
|
-
|
|
41
|
-
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
42
|
-
|
|
43
|
-
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
-
|
|
45
|
-
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
-
|
|
47
|
-
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
-
|
|
49
|
-
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
-
|
|
51
|
-
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
-
|
|
53
|
-
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
-
|
|
55
|
-
END OF TERMS AND CONDITIONS
|
package/LICENSES/CC-BY-3.0.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Creative Commons Attribution 3.0 Unported
|
|
2
|
-
|
|
3
|
-
The icons of [game-icons.net](https://game-icons.net/) are under this licence, each by its own author. The full legal code is at
|
|
4
|
-
<https://creativecommons.org/licenses/by/3.0/legalcode>, and the summary a reader can follow is at
|
|
5
|
-
<https://creativecommons.org/licenses/by/3.0/>.
|
|
6
|
-
|
|
7
|
-
What the licence asks of this package, and what it does:
|
|
8
|
-
|
|
9
|
-
- **Credit the author**: every emblem made from a game-icons.net icon has a row in [NOTICE.md](../NOTICE.md) naming the icon, its
|
|
10
|
-
author and its page on game-icons.net, and the README and the demo point to that file.
|
|
11
|
-
- **Link to the licence**: the row names the licence and links to it.
|
|
12
|
-
- **Say that the icon was changed**: the row says how it was changed (recoloured to the three styles, scaled, its path simplified).
|
|
13
|
-
|
|
14
|
-
No emblem uses a game-icons.net icon yet. The legal code is linked and not copied here: the text a reader needs to check is the one
|
|
15
|
-
the Creative Commons publishes.
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// A soccer ball: a white sphere with twelve dark pentagons at the corners of an icosahedron. Drawn for this package. A sample of the ball area (see docs/layout.md).
|
|
2
|
-
import { defineBall, ICOSAHEDRON } from "../emblem.ball.js";
|
|
3
|
-
/** A soccer ball. Turned, it rolls: the pentagons move across the face and the ones that come round the edge are drawn flattened against it. */
|
|
4
|
-
export const BALL_SOCCER = /* @__PURE__ */ defineBall("ball:soccer", "Soccer ball", "サッカーボール", "ours", {
|
|
5
|
-
base: "#f6f6f2",
|
|
6
|
-
ink: "#20262d",
|
|
7
|
-
rest: { yaw: 18, pitch: 22 },
|
|
8
|
-
marks: ICOSAHEDRON.map((at) => ({ at, sides: 5, radius: 0.36 })),
|
|
9
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type Emblem, type EmblemSource } from "./emblem.core.ts";
|
|
2
|
-
type Vec = readonly [number, number, number];
|
|
3
|
-
/** One patch: where it sits on the unit sphere, how many sides, and its angular radius in radians. */
|
|
4
|
-
export interface Mark {
|
|
5
|
-
at: Vec;
|
|
6
|
-
sides: number;
|
|
7
|
-
radius: number;
|
|
8
|
-
}
|
|
9
|
-
/** What a ball is drawn from. */
|
|
10
|
-
export interface BallModel {
|
|
11
|
-
/** The ball's own colour, as `#rrggbb`. */
|
|
12
|
-
base: string;
|
|
13
|
-
/** The colour of the patches, as `#rrggbb`; a `tint` replaces it. */
|
|
14
|
-
ink: string;
|
|
15
|
-
marks: readonly Mark[];
|
|
16
|
-
/** The resting view, in degrees: what `yaw: 0, pitch: 0` shows. */
|
|
17
|
-
rest: {
|
|
18
|
-
yaw: number;
|
|
19
|
-
pitch: number;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/** A point turned `yaw` about the vertical axis, then `pitch` about the horizontal one (degrees). Up is +y, the eye is at +z. */
|
|
23
|
-
export declare function turn(v: Vec, yaw: number, pitch: number): Vec;
|
|
24
|
-
/** A ball. Its still drawing is its resting view; `frame` rolls it by `yaw` and `pitch` degrees from there. */
|
|
25
|
-
export declare function defineBall(id: string, en: string, ja: string, source: EmblemSource, model: BallModel): Emblem<BallModel>;
|
|
26
|
-
/** The twelve corners of an icosahedron, as unit vectors: where a football's pentagons sit. */
|
|
27
|
-
export declare const ICOSAHEDRON: readonly Vec[];
|
|
28
|
-
export {};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// A ball: marks on a sphere, which the turning view rolls. The marks are polygons laid on the surface; each is projected by the turn and drawn when it faces the eye. Imports only the core.
|
|
2
|
-
import { degrees, hexOf, n2, paintFor, readColour, resolve, wrap } from "./emblem.core.js";
|
|
3
|
-
const unit = (v) => {
|
|
4
|
-
const length = Math.hypot(v[0], v[1], v[2]);
|
|
5
|
-
return [v[0] / length, v[1] / length, v[2] / length];
|
|
6
|
-
};
|
|
7
|
-
const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
8
|
-
/** A point turned `yaw` about the vertical axis, then `pitch` about the horizontal one (degrees). Up is +y, the eye is at +z. */
|
|
9
|
-
export function turn(v, yaw, pitch) {
|
|
10
|
-
const a = (yaw * Math.PI) / 180;
|
|
11
|
-
const b = (pitch * Math.PI) / 180;
|
|
12
|
-
const x1 = v[0] * Math.cos(a) + v[2] * Math.sin(a);
|
|
13
|
-
const z1 = -v[0] * Math.sin(a) + v[2] * Math.cos(a);
|
|
14
|
-
return [x1, v[1] * Math.cos(b) - z1 * Math.sin(b), v[1] * Math.sin(b) + z1 * Math.cos(b)];
|
|
15
|
-
}
|
|
16
|
-
/** The corners of a mark on the sphere. */
|
|
17
|
-
function corners(mark) {
|
|
18
|
-
const c = unit(mark.at);
|
|
19
|
-
const u = unit(cross(c, Math.abs(c[1]) < 0.9 ? [0, 1, 0] : [1, 0, 0]));
|
|
20
|
-
const v = cross(c, u);
|
|
21
|
-
return Array.from({ length: mark.sides }, (_, i) => {
|
|
22
|
-
const t = (2 * Math.PI * i) / mark.sides;
|
|
23
|
-
const s = Math.sin(mark.radius);
|
|
24
|
-
return unit([c[0] * Math.cos(mark.radius) + (u[0] * Math.cos(t) + v[0] * Math.sin(t)) * s, c[1] * Math.cos(mark.radius) + (u[1] * Math.cos(t) + v[1] * Math.sin(t)) * s, c[2] * Math.cos(mark.radius) + (u[2] * Math.cos(t) + v[2] * Math.sin(t)) * s]);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const RADIUS = 28;
|
|
28
|
-
function drawBall(title, model, options, yaw, pitch) {
|
|
29
|
-
const r = resolve(options);
|
|
30
|
-
const base = readColour(model.base);
|
|
31
|
-
const ink = r.tint ?? readColour(model.ink);
|
|
32
|
-
const paint = paintFor(r.style, base, "radial");
|
|
33
|
-
const view = { yaw: model.rest.yaw + yaw, pitch: model.rest.pitch + pitch };
|
|
34
|
-
const patches = model.marks
|
|
35
|
-
.map((mark) => {
|
|
36
|
-
if (turn(unit(mark.at), view.yaw, view.pitch)[2] <= -0.1)
|
|
37
|
-
return "";
|
|
38
|
-
const points = corners(mark).map((corner) => {
|
|
39
|
-
const [x, y, z] = turn(corner, view.yaw, view.pitch);
|
|
40
|
-
const edge = z < 0 ? Math.hypot(x, y) || 1 : 1;
|
|
41
|
-
return `${n2(32 + (RADIUS * x) / edge)} ${n2(32 - (RADIUS * y) / edge)}`;
|
|
42
|
-
});
|
|
43
|
-
return `<path d="M${points.join("L")}Z" fill="${r.style === "line" ? "none" : hexOf(ink)}" stroke-width="1.4"/>`;
|
|
44
|
-
})
|
|
45
|
-
.join("");
|
|
46
|
-
return wrap({ title, size: r.size, style: r.style, theme: r.theme, defs: paint.defs, body: `<circle cx="32" cy="32" r="${RADIUS}" fill="${paint.main}"/>${patches}` });
|
|
47
|
-
}
|
|
48
|
-
/** A ball. Its still drawing is its resting view; `frame` rolls it by `yaw` and `pitch` degrees from there. */
|
|
49
|
-
export function defineBall(id, en, ja, source, model) {
|
|
50
|
-
const draw = (options, yaw, pitch) => drawBall(en, model, options, yaw, pitch);
|
|
51
|
-
return {
|
|
52
|
-
id,
|
|
53
|
-
en,
|
|
54
|
-
ja,
|
|
55
|
-
source,
|
|
56
|
-
kind: "ball",
|
|
57
|
-
model,
|
|
58
|
-
svg: (options) => draw(options, 0, 0),
|
|
59
|
-
frame: (options) => draw(options, degrees(options?.yaw), degrees(options?.pitch)),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/** The twelve corners of an icosahedron, as unit vectors: where a football's pentagons sit. */
|
|
63
|
-
export const ICOSAHEDRON = (() => {
|
|
64
|
-
const phi = (1 + Math.sqrt(5)) / 2;
|
|
65
|
-
const raw = [];
|
|
66
|
-
for (const a of [-1, 1])
|
|
67
|
-
for (const b of [-phi, phi])
|
|
68
|
-
raw.push([0, a, b], [a, b, 0], [b, 0, a]);
|
|
69
|
-
return raw.map(unit);
|
|
70
|
-
})();
|