@guilhermebkel/scenec 0.2.0 → 0.2.1
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 +22 -12
- package/dist/Adapters/FontAdapter.js +5 -1
- package/dist/Commands/BestCommand.d.ts +11 -0
- package/dist/Commands/BestCommand.js +73 -0
- package/dist/Commands/RenderCommand.d.ts +2 -0
- package/dist/Commands/RenderCommand.js +7 -0
- package/dist/Modules/BestModule.d.ts +41 -0
- package/dist/Modules/BestModule.js +159 -0
- package/dist/Modules/CompilationModule.d.ts +5 -0
- package/dist/Modules/CompilationModule.js +92 -19
- package/dist/Modules/CritiqueModule.d.ts +3 -0
- package/dist/Modules/CritiqueModule.js +60 -5
- package/dist/Protocols/AssetProtocol.d.ts +6 -1
- package/dist/Protocols/AssetProtocol.js +17 -1
- package/dist/Protocols/CommandProtocol.d.ts +2 -0
- package/dist/Protocols/CompilationProtocol.d.ts +27 -1
- package/dist/Protocols/CritiqueProtocol.d.ts +17 -1
- package/dist/Protocols/CritiqueProtocol.js +11 -1
- package/dist/Protocols/KitProtocol.d.ts +8 -2
- package/dist/Protocols/KitProtocol.js +8 -2
- package/dist/Protocols/PersonProtocol.d.ts +4 -0
- package/dist/Protocols/PersonProtocol.js +2 -0
- package/dist/Protocols/SceneProtocol.d.ts +204 -5
- package/dist/Protocols/SceneProtocol.js +60 -7
- package/dist/Resources/Assets/BaseAsset.d.ts +1 -0
- package/dist/Resources/Assets/BaseAsset.js +1 -0
- package/dist/Resources/Assets/BigPlantAsset.js +8 -1
- package/dist/Resources/Assets/BlackboardAsset.d.ts +11 -0
- package/dist/Resources/Assets/BlackboardAsset.js +20 -0
- package/dist/Resources/Assets/BushAsset.js +1 -1
- package/dist/Resources/Assets/ChairAsset.d.ts +5 -0
- package/dist/Resources/Assets/ChairAsset.js +23 -0
- package/dist/Resources/Assets/ChatBubbleAsset.d.ts +11 -0
- package/dist/Resources/Assets/ChatBubbleAsset.js +18 -0
- package/dist/Resources/Assets/CloudAsset.js +3 -1
- package/dist/Resources/Assets/ConfettiAsset.d.ts +10 -0
- package/dist/Resources/Assets/ConfettiAsset.js +18 -0
- package/dist/Resources/Assets/CursorAsset.d.ts +11 -0
- package/dist/Resources/Assets/CursorAsset.js +17 -0
- package/dist/Resources/Assets/DeskAsset.js +7 -2
- package/dist/Resources/Assets/FirstAidKitAsset.d.ts +10 -0
- package/dist/Resources/Assets/FirstAidKitAsset.js +19 -0
- package/dist/Resources/Assets/GlobeAsset.d.ts +10 -0
- package/dist/Resources/Assets/GlobeAsset.js +18 -0
- package/dist/Resources/Assets/HouseAsset.js +22 -6
- package/dist/Resources/Assets/LaptopAsset.js +5 -1
- package/dist/Resources/Assets/PlantAsset.js +1 -1
- package/dist/Resources/Assets/PodiumAsset.d.ts +11 -0
- package/dist/Resources/Assets/PodiumAsset.js +20 -0
- package/dist/Resources/Assets/RefrigeratorAsset.d.ts +11 -0
- package/dist/Resources/Assets/RefrigeratorAsset.js +21 -0
- package/dist/Resources/Assets/SinkAsset.d.ts +11 -0
- package/dist/Resources/Assets/SinkAsset.js +21 -0
- package/dist/Resources/Assets/SofaAsset.d.ts +5 -0
- package/dist/Resources/Assets/SofaAsset.js +30 -2
- package/dist/Resources/Assets/StarsAsset.d.ts +6 -0
- package/dist/Resources/Assets/StarsAsset.js +37 -24
- package/dist/Resources/Assets/StethoscopeAsset.d.ts +10 -0
- package/dist/Resources/Assets/StethoscopeAsset.js +18 -0
- package/dist/Resources/Assets/StoveAsset.d.ts +11 -0
- package/dist/Resources/Assets/StoveAsset.js +20 -0
- package/dist/Resources/Assets/ToggleAsset.d.ts +11 -0
- package/dist/Resources/Assets/ToggleAsset.js +21 -0
- package/dist/Resources/Assets/TreeAsset.d.ts +5 -0
- package/dist/Resources/Assets/TreeAsset.js +32 -7
- package/dist/Resources/Assets/WaterCoolerAsset.d.ts +11 -0
- package/dist/Resources/Assets/WaterCoolerAsset.js +20 -0
- package/dist/Resources/Assets/WhiteboardAsset.d.ts +10 -0
- package/dist/Resources/Assets/WhiteboardAsset.js +18 -0
- package/dist/Resources/Kits/BaseKit.d.ts +2 -1
- package/dist/Resources/Kits/BaseKit.js +1 -0
- package/dist/Resources/Kits/ClayKit.d.ts +9 -0
- package/dist/Resources/Kits/ClayKit.js +11 -0
- package/dist/Resources/Kits/DuotoneKit.d.ts +16 -0
- package/dist/Resources/Kits/DuotoneKit.js +18 -0
- package/dist/Resources/Kits/IsometricKit.d.ts +8 -0
- package/dist/Resources/Kits/IsometricKit.js +10 -0
- package/dist/Resources/Kits/OutlineKit.d.ts +3 -0
- package/dist/Resources/Kits/OutlineKit.js +1 -1
- package/dist/Resources/Kits/PaperKit.d.ts +2 -0
- package/dist/Resources/Kits/PaperKit.js +1 -0
- package/dist/Resources/Kits/PosterKit.d.ts +14 -0
- package/dist/Resources/Kits/PosterKit.js +16 -0
- package/dist/Resources/Kits/SketchKit.d.ts +2 -1
- package/dist/Resources/Kits/SketchKit.js +1 -0
- package/dist/Services/AssetService.js +29 -1
- package/dist/Services/BackgroundService.d.ts +10 -2
- package/dist/Services/BackgroundService.js +52 -11
- package/dist/Services/CatalogService.d.ts +1 -0
- package/dist/Services/CatalogService.js +8 -3
- package/dist/Services/ColorCritiqueService.d.ts +42 -0
- package/dist/Services/ColorCritiqueService.js +232 -0
- package/dist/Services/ContextService.js +9 -5
- package/dist/Services/DescriptionService.d.ts +2 -1
- package/dist/Services/DescriptionService.js +8 -2
- package/dist/Services/DetailService.d.ts +7 -0
- package/dist/Services/DetailService.js +18 -0
- package/dist/Services/FocusCritiqueService.d.ts +23 -0
- package/dist/Services/FocusCritiqueService.js +166 -0
- package/dist/Services/FramingService.d.ts +31 -0
- package/dist/Services/FramingService.js +108 -0
- package/dist/Services/GazeService.js +3 -1
- package/dist/Services/GroundDetailService.d.ts +50 -0
- package/dist/Services/GroundDetailService.js +115 -0
- package/dist/Services/KitService.d.ts +11 -2
- package/dist/Services/KitService.js +45 -10
- package/dist/Services/LightingService.d.ts +15 -0
- package/dist/Services/LightingService.js +124 -6
- package/dist/Services/PaletteService.d.ts +108 -0
- package/dist/Services/PaletteService.js +282 -0
- package/dist/Services/PieceService.d.ts +4 -0
- package/dist/Services/PieceService.js +28 -7
- package/dist/Services/PlacementService.js +7 -1
- package/dist/Services/PlaneBackgroundService.d.ts +4 -0
- package/dist/Services/PlaneBackgroundService.js +42 -3
- package/dist/Services/PlaneProjectionService.d.ts +4 -0
- package/dist/Services/PlaneProjectionService.js +33 -4
- package/dist/Services/RasterService.js +20 -3
- package/dist/Services/RidgeService.d.ts +31 -0
- package/dist/Services/RidgeService.js +85 -0
- package/dist/Services/ScaleCritiqueService.d.ts +11 -0
- package/dist/Services/ScaleCritiqueService.js +57 -0
- package/dist/Services/SkyDetailService.d.ts +39 -0
- package/dist/Services/SkyDetailService.js +95 -0
- package/dist/Services/{ContactCritiqueService.d.ts → TangentCritiqueService.d.ts} +10 -6
- package/dist/Services/TangentCritiqueService.js +136 -0
- package/dist/Services/TextService.d.ts +43 -3
- package/dist/Services/TextService.js +288 -32
- package/dist/Services/ThumbnailCritiqueService.d.ts +30 -0
- package/dist/Services/ThumbnailCritiqueService.js +130 -0
- package/dist/Utils/ColorUtil.d.ts +14 -0
- package/dist/Utils/ColorUtil.js +68 -5
- package/dist/Utils/DetailUtil.d.ts +7 -0
- package/dist/Utils/DetailUtil.js +15 -0
- package/dist/Utils/FontMetricsUtil.d.ts +7 -0
- package/dist/Utils/FontMetricsUtil.js +694 -0
- package/dist/Utils/OklabUtil.d.ts +18 -0
- package/dist/Utils/OklabUtil.js +89 -0
- package/dist/Utils/PersonArmUtil.d.ts +13 -1
- package/dist/Utils/PersonArmUtil.js +53 -5
- package/dist/Utils/PersonHeadUtil.js +3 -1
- package/dist/Utils/PersonOutfitUtil.d.ts +16 -0
- package/dist/Utils/PersonOutfitUtil.js +89 -13
- package/dist/Utils/PersonUtil.d.ts +2 -0
- package/dist/Utils/PersonUtil.js +14 -4
- package/dist/Utils/SanitizeUtil.js +1 -0
- package/dist/Utils/ShapeUtil.d.ts +9 -0
- package/dist/Utils/ShapeUtil.js +26 -0
- package/dist/Utils/TypesettingUtil.d.ts +17 -0
- package/dist/Utils/TypesettingUtil.js +92 -0
- package/dist/cli.js +32 -3
- package/dist/render.d.ts +3 -1
- package/dist/render.js +5 -0
- package/fonts/DMSerifDisplay-Regular.ttf +0 -0
- package/fonts/OFL.txt +2 -0
- package/fonts/PatrickHand-Regular.ttf +0 -0
- package/package.json +1 -1
- package/skills/draw-scene/SKILL.md +2 -1
- package/skills/draw-scene/recipes/carousel.yaml +1 -1
- package/skills/draw-scene/recipes/conference-keynote.yaml +43 -0
- package/skills/draw-scene/recipes/product-feature.yaml +41 -0
- package/skills/draw-scene/recipes/product-illustration.yaml +2 -1
- package/skills/draw-scene/references/catalog.md +19 -1
- package/skills/draw-scene/references/dsl.md +24 -6
- package/dist/Services/ContactCritiqueService.js +0 -101
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { GeneratedTheme } from "../Protocols/SceneProtocol.js";
|
|
2
|
+
import type { Theme } from "../Protocols/ThemeProtocol.js";
|
|
3
|
+
export declare class PaletteService {
|
|
4
|
+
private static readonly DEFAULT_HARMONY;
|
|
5
|
+
private static readonly DEFAULT_MOOD;
|
|
6
|
+
private static readonly FULL_TURN;
|
|
7
|
+
private static readonly WCAG_AA_RATIO;
|
|
8
|
+
private static readonly DEFAULT_PRIMARY;
|
|
9
|
+
private static readonly ANALOGOUS_SECONDARY_RAD;
|
|
10
|
+
private static readonly ANALOGOUS_ACCENT_RAD;
|
|
11
|
+
private static readonly ACCENT_EXTRA_RAD;
|
|
12
|
+
private static readonly SPLIT_SECONDARY_RAD;
|
|
13
|
+
private static readonly SPLIT_ACCENT_RAD;
|
|
14
|
+
private static readonly TRIAD_SECONDARY_RAD;
|
|
15
|
+
private static readonly TRIAD_ACCENT_RAD;
|
|
16
|
+
private static readonly HARMONY_TO_OFFSETS;
|
|
17
|
+
private static readonly DAY_SKY_TOP_L;
|
|
18
|
+
private static readonly DAY_SKY_TOP_C;
|
|
19
|
+
private static readonly DAY_SKY_BOTTOM_L;
|
|
20
|
+
private static readonly DAY_SKY_BOTTOM_C;
|
|
21
|
+
private static readonly DAY_GROUND_L;
|
|
22
|
+
private static readonly DAY_GROUND_C;
|
|
23
|
+
private static readonly DAY_GROUND_DARK_L;
|
|
24
|
+
private static readonly DAY_WALL_L;
|
|
25
|
+
private static readonly DAY_WALL_C;
|
|
26
|
+
private static readonly DAY_FLOOR_L;
|
|
27
|
+
private static readonly DAY_FLOOR_C;
|
|
28
|
+
private static readonly DUSK_SKY_TOP_L;
|
|
29
|
+
private static readonly DUSK_SKY_TOP_C;
|
|
30
|
+
private static readonly DUSK_SKY_BOTTOM_L;
|
|
31
|
+
private static readonly DUSK_SKY_BOTTOM_C;
|
|
32
|
+
private static readonly DUSK_GROUND_L;
|
|
33
|
+
private static readonly DUSK_GROUND_C;
|
|
34
|
+
private static readonly DUSK_GROUND_DARK_L;
|
|
35
|
+
private static readonly DUSK_WALL_L;
|
|
36
|
+
private static readonly DUSK_WALL_C;
|
|
37
|
+
private static readonly DUSK_FLOOR_L;
|
|
38
|
+
private static readonly DUSK_FLOOR_C;
|
|
39
|
+
private static readonly NIGHT_SKY_TOP_L;
|
|
40
|
+
private static readonly NIGHT_SKY_TOP_C;
|
|
41
|
+
private static readonly NIGHT_SKY_BOTTOM_L;
|
|
42
|
+
private static readonly NIGHT_SKY_BOTTOM_C;
|
|
43
|
+
private static readonly NIGHT_GROUND_L;
|
|
44
|
+
private static readonly NIGHT_GROUND_C;
|
|
45
|
+
private static readonly NIGHT_GROUND_DARK_L;
|
|
46
|
+
private static readonly NIGHT_WALL_L;
|
|
47
|
+
private static readonly NIGHT_WALL_C;
|
|
48
|
+
private static readonly NIGHT_FLOOR_L;
|
|
49
|
+
private static readonly NIGHT_FLOOR_C;
|
|
50
|
+
private static readonly MOOD_TO_BANDS;
|
|
51
|
+
private static readonly DUSK_SKY_TOP_HUE;
|
|
52
|
+
private static readonly DUSK_SKY_BOTTOM_HUE;
|
|
53
|
+
private static readonly NIGHT_SKY_TOP_HUE;
|
|
54
|
+
private static readonly NIGHT_SKY_BOTTOM_HUE;
|
|
55
|
+
private static readonly SKY_BASE_HUE;
|
|
56
|
+
private static readonly MOOD_TO_SKY_HUES;
|
|
57
|
+
private static readonly INK_LIGHTNESS;
|
|
58
|
+
private static readonly INK_CHROMA;
|
|
59
|
+
private static readonly GLASS_L;
|
|
60
|
+
private static readonly GLASS_C;
|
|
61
|
+
private static readonly GLASS_H;
|
|
62
|
+
private static readonly GLASS_LCH;
|
|
63
|
+
private static readonly METAL_L;
|
|
64
|
+
private static readonly METAL_C;
|
|
65
|
+
private static readonly METAL_H;
|
|
66
|
+
private static readonly METAL_LCH;
|
|
67
|
+
private static readonly TRUNK_L;
|
|
68
|
+
private static readonly TRUNK_C;
|
|
69
|
+
private static readonly TRUNK_H;
|
|
70
|
+
private static readonly TRUNK_LCH;
|
|
71
|
+
private static readonly WOOD_L;
|
|
72
|
+
private static readonly WOOD_C;
|
|
73
|
+
private static readonly WOOD_H;
|
|
74
|
+
private static readonly WOOD_LCH;
|
|
75
|
+
private static readonly WOOD_DARK_L;
|
|
76
|
+
private static readonly WOOD_DARK_LCH;
|
|
77
|
+
private static readonly SEA_L;
|
|
78
|
+
private static readonly SEA_C;
|
|
79
|
+
private static readonly SEA_H;
|
|
80
|
+
private static readonly SEA_LCH;
|
|
81
|
+
private static readonly SEA_LIGHT_L;
|
|
82
|
+
private static readonly SEA_LIGHT_C;
|
|
83
|
+
private static readonly SEA_LIGHT_LCH;
|
|
84
|
+
private static readonly FOLIAGE_HUE;
|
|
85
|
+
private static readonly FOLIAGE_CHROMA;
|
|
86
|
+
private static readonly FOLIAGE_STEP_0;
|
|
87
|
+
private static readonly FOLIAGE_STEP_1;
|
|
88
|
+
private static readonly FOLIAGE_STEP_2;
|
|
89
|
+
private static readonly FOLIAGE_STEPS;
|
|
90
|
+
private static readonly FOLIAGE_PULL_FACTOR;
|
|
91
|
+
private static readonly GROUND_BASE_HUE;
|
|
92
|
+
private static readonly GROUND_HUE_FACTOR;
|
|
93
|
+
private static readonly FLOOR_HUE;
|
|
94
|
+
private static readonly ACCENT_MAX_L;
|
|
95
|
+
private static readonly ACCENT_L_BOOST;
|
|
96
|
+
private static readonly ACCENT_MAX_C;
|
|
97
|
+
private static readonly ACCENT_C_BOOST;
|
|
98
|
+
private static readonly TEXT_LIGHT;
|
|
99
|
+
private static readonly TEXT_DARK;
|
|
100
|
+
static generate(spec: GeneratedTheme): Theme;
|
|
101
|
+
private static seedHex;
|
|
102
|
+
private static resolveTrio;
|
|
103
|
+
private static secondaryOf;
|
|
104
|
+
private static accentOf;
|
|
105
|
+
private static resolveBackgrounds;
|
|
106
|
+
private static resolveFoliage;
|
|
107
|
+
private static resolveText;
|
|
108
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { ColorUtil } from "../Utils/ColorUtil.js";
|
|
2
|
+
import { IdUtil } from "../Utils/IdUtil.js";
|
|
3
|
+
import { OklabUtil } from "../Utils/OklabUtil.js";
|
|
4
|
+
class PaletteService {
|
|
5
|
+
static DEFAULT_HARMONY = "analogous";
|
|
6
|
+
static DEFAULT_MOOD = "day";
|
|
7
|
+
static FULL_TURN = Math.PI * 2;
|
|
8
|
+
static WCAG_AA_RATIO = 4.5;
|
|
9
|
+
static DEFAULT_PRIMARY = "#2F6BFF";
|
|
10
|
+
static ANALOGOUS_SECONDARY_RAD = 0.5236;
|
|
11
|
+
static ANALOGOUS_ACCENT_RAD = -0.5236;
|
|
12
|
+
static ACCENT_EXTRA_RAD = 0.2618;
|
|
13
|
+
static SPLIT_SECONDARY_RAD = 2.618;
|
|
14
|
+
static SPLIT_ACCENT_RAD = 3.665;
|
|
15
|
+
static TRIAD_SECONDARY_RAD = 2.0944;
|
|
16
|
+
static TRIAD_ACCENT_RAD = 4.1888;
|
|
17
|
+
static HARMONY_TO_OFFSETS = {
|
|
18
|
+
analogous: {
|
|
19
|
+
secondaryRad: PaletteService.ANALOGOUS_SECONDARY_RAD,
|
|
20
|
+
accentRad: PaletteService.ANALOGOUS_ACCENT_RAD
|
|
21
|
+
},
|
|
22
|
+
complementary: {
|
|
23
|
+
secondaryRad: Math.PI,
|
|
24
|
+
accentRad: Math.PI + PaletteService.ACCENT_EXTRA_RAD
|
|
25
|
+
},
|
|
26
|
+
split: {
|
|
27
|
+
secondaryRad: PaletteService.SPLIT_SECONDARY_RAD,
|
|
28
|
+
accentRad: PaletteService.SPLIT_ACCENT_RAD
|
|
29
|
+
},
|
|
30
|
+
triad: {
|
|
31
|
+
secondaryRad: PaletteService.TRIAD_SECONDARY_RAD,
|
|
32
|
+
accentRad: PaletteService.TRIAD_ACCENT_RAD
|
|
33
|
+
},
|
|
34
|
+
mono: {
|
|
35
|
+
secondaryRad: 0,
|
|
36
|
+
accentRad: 0
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
static DAY_SKY_TOP_L = 0.94;
|
|
40
|
+
static DAY_SKY_TOP_C = 0.02;
|
|
41
|
+
static DAY_SKY_BOTTOM_L = 0.97;
|
|
42
|
+
static DAY_SKY_BOTTOM_C = 0.01;
|
|
43
|
+
static DAY_GROUND_L = 0.72;
|
|
44
|
+
static DAY_GROUND_C = 0.1;
|
|
45
|
+
static DAY_GROUND_DARK_L = 0.62;
|
|
46
|
+
static DAY_WALL_L = 0.95;
|
|
47
|
+
static DAY_WALL_C = 0.01;
|
|
48
|
+
static DAY_FLOOR_L = 0.76;
|
|
49
|
+
static DAY_FLOOR_C = 0.02;
|
|
50
|
+
static DUSK_SKY_TOP_L = 0.48;
|
|
51
|
+
static DUSK_SKY_TOP_C = 0.12;
|
|
52
|
+
static DUSK_SKY_BOTTOM_L = 0.76;
|
|
53
|
+
static DUSK_SKY_BOTTOM_C = 0.14;
|
|
54
|
+
static DUSK_GROUND_L = 0.45;
|
|
55
|
+
static DUSK_GROUND_C = 0.08;
|
|
56
|
+
static DUSK_GROUND_DARK_L = 0.35;
|
|
57
|
+
static DUSK_WALL_L = 0.82;
|
|
58
|
+
static DUSK_WALL_C = 0.04;
|
|
59
|
+
static DUSK_FLOOR_L = 0.58;
|
|
60
|
+
static DUSK_FLOOR_C = 0.04;
|
|
61
|
+
static NIGHT_SKY_TOP_L = 0.18;
|
|
62
|
+
static NIGHT_SKY_TOP_C = 0.06;
|
|
63
|
+
static NIGHT_SKY_BOTTOM_L = 0.28;
|
|
64
|
+
static NIGHT_SKY_BOTTOM_C = 0.08;
|
|
65
|
+
static NIGHT_GROUND_L = 0.26;
|
|
66
|
+
static NIGHT_GROUND_C = 0.05;
|
|
67
|
+
static NIGHT_GROUND_DARK_L = 0.18;
|
|
68
|
+
static NIGHT_WALL_L = 0.32;
|
|
69
|
+
static NIGHT_WALL_C = 0.02;
|
|
70
|
+
static NIGHT_FLOOR_L = 0.24;
|
|
71
|
+
static NIGHT_FLOOR_C = 0.02;
|
|
72
|
+
static MOOD_TO_BANDS = {
|
|
73
|
+
day: {
|
|
74
|
+
skyTopL: PaletteService.DAY_SKY_TOP_L,
|
|
75
|
+
skyTopC: PaletteService.DAY_SKY_TOP_C,
|
|
76
|
+
skyBottomL: PaletteService.DAY_SKY_BOTTOM_L,
|
|
77
|
+
skyBottomC: PaletteService.DAY_SKY_BOTTOM_C,
|
|
78
|
+
groundL: PaletteService.DAY_GROUND_L,
|
|
79
|
+
groundC: PaletteService.DAY_GROUND_C,
|
|
80
|
+
groundDarkL: PaletteService.DAY_GROUND_DARK_L,
|
|
81
|
+
groundDarkC: PaletteService.DAY_GROUND_C,
|
|
82
|
+
wallL: PaletteService.DAY_WALL_L,
|
|
83
|
+
wallC: PaletteService.DAY_WALL_C,
|
|
84
|
+
floorL: PaletteService.DAY_FLOOR_L,
|
|
85
|
+
floorC: PaletteService.DAY_FLOOR_C,
|
|
86
|
+
shadow: "rgba(31,42,61,0.13)"
|
|
87
|
+
},
|
|
88
|
+
dusk: {
|
|
89
|
+
skyTopL: PaletteService.DUSK_SKY_TOP_L,
|
|
90
|
+
skyTopC: PaletteService.DUSK_SKY_TOP_C,
|
|
91
|
+
skyBottomL: PaletteService.DUSK_SKY_BOTTOM_L,
|
|
92
|
+
skyBottomC: PaletteService.DUSK_SKY_BOTTOM_C,
|
|
93
|
+
groundL: PaletteService.DUSK_GROUND_L,
|
|
94
|
+
groundC: PaletteService.DUSK_GROUND_C,
|
|
95
|
+
groundDarkL: PaletteService.DUSK_GROUND_DARK_L,
|
|
96
|
+
groundDarkC: PaletteService.DUSK_GROUND_C,
|
|
97
|
+
wallL: PaletteService.DUSK_WALL_L,
|
|
98
|
+
wallC: PaletteService.DUSK_WALL_C,
|
|
99
|
+
floorL: PaletteService.DUSK_FLOOR_L,
|
|
100
|
+
floorC: PaletteService.DUSK_FLOOR_C,
|
|
101
|
+
shadow: "rgba(20,10,35,0.22)"
|
|
102
|
+
},
|
|
103
|
+
night: {
|
|
104
|
+
skyTopL: PaletteService.NIGHT_SKY_TOP_L,
|
|
105
|
+
skyTopC: PaletteService.NIGHT_SKY_TOP_C,
|
|
106
|
+
skyBottomL: PaletteService.NIGHT_SKY_BOTTOM_L,
|
|
107
|
+
skyBottomC: PaletteService.NIGHT_SKY_BOTTOM_C,
|
|
108
|
+
groundL: PaletteService.NIGHT_GROUND_L,
|
|
109
|
+
groundC: PaletteService.NIGHT_GROUND_C,
|
|
110
|
+
groundDarkL: PaletteService.NIGHT_GROUND_DARK_L,
|
|
111
|
+
groundDarkC: PaletteService.NIGHT_GROUND_C,
|
|
112
|
+
wallL: PaletteService.NIGHT_WALL_L,
|
|
113
|
+
wallC: PaletteService.NIGHT_WALL_C,
|
|
114
|
+
floorL: PaletteService.NIGHT_FLOOR_L,
|
|
115
|
+
floorC: PaletteService.NIGHT_FLOOR_C,
|
|
116
|
+
shadow: "rgba(5,10,25,0.30)"
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
static DUSK_SKY_TOP_HUE = 5.5;
|
|
120
|
+
static DUSK_SKY_BOTTOM_HUE = 1;
|
|
121
|
+
static NIGHT_SKY_TOP_HUE = 4.6;
|
|
122
|
+
static NIGHT_SKY_BOTTOM_HUE = 4.8;
|
|
123
|
+
static SKY_BASE_HUE = 4.2;
|
|
124
|
+
static MOOD_TO_SKY_HUES = {
|
|
125
|
+
day: (primaryHue) => {
|
|
126
|
+
const averaged = (primaryHue + PaletteService.SKY_BASE_HUE) / 2;
|
|
127
|
+
return { top: averaged, bottom: averaged };
|
|
128
|
+
},
|
|
129
|
+
dusk: () => ({ top: PaletteService.DUSK_SKY_TOP_HUE, bottom: PaletteService.DUSK_SKY_BOTTOM_HUE }),
|
|
130
|
+
night: () => ({ top: PaletteService.NIGHT_SKY_TOP_HUE, bottom: PaletteService.NIGHT_SKY_BOTTOM_HUE })
|
|
131
|
+
};
|
|
132
|
+
static INK_LIGHTNESS = 0.22;
|
|
133
|
+
static INK_CHROMA = 0.04;
|
|
134
|
+
static GLASS_L = 0.85;
|
|
135
|
+
static GLASS_C = 0.04;
|
|
136
|
+
static GLASS_H = 4.2;
|
|
137
|
+
static GLASS_LCH = [PaletteService.GLASS_L, PaletteService.GLASS_C, PaletteService.GLASS_H];
|
|
138
|
+
static METAL_L = 0.65;
|
|
139
|
+
static METAL_C = 0.02;
|
|
140
|
+
static METAL_H = 4.4;
|
|
141
|
+
static METAL_LCH = [PaletteService.METAL_L, PaletteService.METAL_C, PaletteService.METAL_H];
|
|
142
|
+
static TRUNK_L = 0.45;
|
|
143
|
+
static TRUNK_C = 0.05;
|
|
144
|
+
static TRUNK_H = 1;
|
|
145
|
+
static TRUNK_LCH = [PaletteService.TRUNK_L, PaletteService.TRUNK_C, PaletteService.TRUNK_H];
|
|
146
|
+
static WOOD_L = 0.65;
|
|
147
|
+
static WOOD_C = 0.08;
|
|
148
|
+
static WOOD_H = 1.1;
|
|
149
|
+
static WOOD_LCH = [PaletteService.WOOD_L, PaletteService.WOOD_C, PaletteService.WOOD_H];
|
|
150
|
+
static WOOD_DARK_L = 0.5;
|
|
151
|
+
static WOOD_DARK_LCH = [
|
|
152
|
+
PaletteService.WOOD_DARK_L,
|
|
153
|
+
PaletteService.WOOD_C,
|
|
154
|
+
PaletteService.WOOD_H
|
|
155
|
+
];
|
|
156
|
+
static SEA_L = 0.58;
|
|
157
|
+
static SEA_C = 0.08;
|
|
158
|
+
static SEA_H = 4;
|
|
159
|
+
static SEA_LCH = [PaletteService.SEA_L, PaletteService.SEA_C, PaletteService.SEA_H];
|
|
160
|
+
static SEA_LIGHT_L = 0.75;
|
|
161
|
+
static SEA_LIGHT_C = 0.06;
|
|
162
|
+
static SEA_LIGHT_LCH = [
|
|
163
|
+
PaletteService.SEA_LIGHT_L,
|
|
164
|
+
PaletteService.SEA_LIGHT_C,
|
|
165
|
+
PaletteService.SEA_H
|
|
166
|
+
];
|
|
167
|
+
static FOLIAGE_HUE = 2.4;
|
|
168
|
+
static FOLIAGE_CHROMA = 0.12;
|
|
169
|
+
static FOLIAGE_STEP_0 = 0.6;
|
|
170
|
+
static FOLIAGE_STEP_1 = 0.68;
|
|
171
|
+
static FOLIAGE_STEP_2 = 0.5;
|
|
172
|
+
static FOLIAGE_STEPS = [
|
|
173
|
+
PaletteService.FOLIAGE_STEP_0,
|
|
174
|
+
PaletteService.FOLIAGE_STEP_1,
|
|
175
|
+
PaletteService.FOLIAGE_STEP_2
|
|
176
|
+
];
|
|
177
|
+
static FOLIAGE_PULL_FACTOR = 0.15;
|
|
178
|
+
static GROUND_BASE_HUE = 2.3;
|
|
179
|
+
static GROUND_HUE_FACTOR = 0.1;
|
|
180
|
+
static FLOOR_HUE = 1.2;
|
|
181
|
+
static ACCENT_MAX_L = 0.85;
|
|
182
|
+
static ACCENT_L_BOOST = 0.08;
|
|
183
|
+
static ACCENT_MAX_C = 0.2;
|
|
184
|
+
static ACCENT_C_BOOST = 0.05;
|
|
185
|
+
static TEXT_LIGHT = "#FFFFFF";
|
|
186
|
+
static TEXT_DARK = "#1A1A1A";
|
|
187
|
+
static generate(spec) {
|
|
188
|
+
const primarySeed = PaletteService.seedHex(spec.from);
|
|
189
|
+
const harmony = spec.harmony ?? PaletteService.DEFAULT_HARMONY;
|
|
190
|
+
const mood = spec.mood ?? PaletteService.DEFAULT_MOOD;
|
|
191
|
+
const { primary, secondary, accent, primaryHue } = PaletteService.resolveTrio(primarySeed, spec.from, harmony);
|
|
192
|
+
const bands = IdUtil.lookup(PaletteService.MOOD_TO_BANDS, mood) ?? PaletteService.MOOD_TO_BANDS.day;
|
|
193
|
+
const backgrounds = PaletteService.resolveBackgrounds(primaryHue, mood, bands);
|
|
194
|
+
const foliage = PaletteService.resolveFoliage(primaryHue);
|
|
195
|
+
const ink = OklabUtil.lchToHex([PaletteService.INK_LIGHTNESS, PaletteService.INK_CHROMA, primaryHue]);
|
|
196
|
+
const textPair = PaletteService.resolveText(ink, backgrounds.skyTop, backgrounds.wall, backgrounds.groundDark);
|
|
197
|
+
return {
|
|
198
|
+
primary,
|
|
199
|
+
secondary,
|
|
200
|
+
accent,
|
|
201
|
+
...backgrounds,
|
|
202
|
+
foliage,
|
|
203
|
+
trunk: OklabUtil.lchToHex(PaletteService.TRUNK_LCH),
|
|
204
|
+
wood: OklabUtil.lchToHex(PaletteService.WOOD_LCH),
|
|
205
|
+
woodDark: OklabUtil.lchToHex(PaletteService.WOOD_DARK_LCH),
|
|
206
|
+
ink,
|
|
207
|
+
paper: PaletteService.TEXT_LIGHT,
|
|
208
|
+
glass: OklabUtil.lchToHex(PaletteService.GLASS_LCH),
|
|
209
|
+
metal: OklabUtil.lchToHex(PaletteService.METAL_LCH),
|
|
210
|
+
text: textPair.text,
|
|
211
|
+
textOnDark: textPair.textOnDark,
|
|
212
|
+
shadow: bands.shadow,
|
|
213
|
+
sea: OklabUtil.lchToHex(PaletteService.SEA_LCH),
|
|
214
|
+
seaLight: OklabUtil.lchToHex(PaletteService.SEA_LIGHT_LCH)
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
static seedHex(from) {
|
|
218
|
+
const seed = Array.isArray(from) ? from[0] ?? PaletteService.DEFAULT_PRIMARY : from;
|
|
219
|
+
return seed.startsWith("#") ? seed : `#${seed}`;
|
|
220
|
+
}
|
|
221
|
+
static resolveTrio(primaryHex, from, harmony) {
|
|
222
|
+
const [red, green, blue] = OklabUtil.rgbOfHex(primaryHex);
|
|
223
|
+
const lab = OklabUtil.fromRgb(red, green, blue);
|
|
224
|
+
const [lightness, chroma, hue] = OklabUtil.labToLch(lab);
|
|
225
|
+
const offsets = IdUtil.lookup(PaletteService.HARMONY_TO_OFFSETS, harmony) ?? PaletteService.HARMONY_TO_OFFSETS.analogous;
|
|
226
|
+
const seeds = Array.isArray(from) ? from : [from];
|
|
227
|
+
const secondaryTargetHue = (hue + offsets.secondaryRad + PaletteService.FULL_TURN) % PaletteService.FULL_TURN;
|
|
228
|
+
const secondary = PaletteService.secondaryOf(seeds, lightness, chroma, secondaryTargetHue);
|
|
229
|
+
const accentTargetHue = (hue + offsets.accentRad + PaletteService.FULL_TURN) % PaletteService.FULL_TURN;
|
|
230
|
+
const accent = PaletteService.accentOf(seeds, lightness, chroma, accentTargetHue);
|
|
231
|
+
return { primary: primaryHex, secondary, accent, primaryHue: hue };
|
|
232
|
+
}
|
|
233
|
+
static secondaryOf(seeds, lightness, chroma, targetHue) {
|
|
234
|
+
const secondarySeed = seeds[1];
|
|
235
|
+
if (secondarySeed != null) {
|
|
236
|
+
return secondarySeed.startsWith("#") ? secondarySeed : `#${secondarySeed}`;
|
|
237
|
+
}
|
|
238
|
+
return OklabUtil.lchToHex([lightness, chroma, targetHue]);
|
|
239
|
+
}
|
|
240
|
+
static accentOf(seeds, lightness, chroma, targetHue) {
|
|
241
|
+
const accentSeed = seeds[2];
|
|
242
|
+
if (accentSeed != null) {
|
|
243
|
+
return accentSeed.startsWith("#") ? accentSeed : `#${accentSeed}`;
|
|
244
|
+
}
|
|
245
|
+
const boostedL = Math.min(PaletteService.ACCENT_MAX_L, lightness + PaletteService.ACCENT_L_BOOST);
|
|
246
|
+
const boostedC = Math.min(PaletteService.ACCENT_MAX_C, chroma + PaletteService.ACCENT_C_BOOST);
|
|
247
|
+
return OklabUtil.lchToHex([boostedL, boostedC, targetHue]);
|
|
248
|
+
}
|
|
249
|
+
static resolveBackgrounds(primaryHue, mood, bands) {
|
|
250
|
+
const skyHuesResolver = IdUtil.lookup(PaletteService.MOOD_TO_SKY_HUES, mood) ?? PaletteService.MOOD_TO_SKY_HUES.day;
|
|
251
|
+
const skyHues = skyHuesResolver(primaryHue);
|
|
252
|
+
const groundHue = (PaletteService.GROUND_BASE_HUE + primaryHue * PaletteService.GROUND_HUE_FACTOR) % PaletteService.FULL_TURN;
|
|
253
|
+
return {
|
|
254
|
+
skyTop: OklabUtil.lchToHex([bands.skyTopL, bands.skyTopC, skyHues.top]),
|
|
255
|
+
skyBottom: OklabUtil.lchToHex([bands.skyBottomL, bands.skyBottomC, skyHues.bottom]),
|
|
256
|
+
ground: OklabUtil.lchToHex([bands.groundL, bands.groundC, groundHue]),
|
|
257
|
+
groundDark: OklabUtil.lchToHex([bands.groundDarkL, bands.groundDarkC, groundHue]),
|
|
258
|
+
wall: OklabUtil.lchToHex([bands.wallL, bands.wallC, primaryHue]),
|
|
259
|
+
floor: OklabUtil.lchToHex([bands.floorL, bands.floorC, PaletteService.FLOOR_HUE])
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
static resolveFoliage(primaryHue) {
|
|
263
|
+
const pulledHue = (PaletteService.FOLIAGE_HUE + primaryHue * PaletteService.FOLIAGE_PULL_FACTOR) % PaletteService.FULL_TURN;
|
|
264
|
+
return [
|
|
265
|
+
OklabUtil.lchToHex([PaletteService.FOLIAGE_STEPS[0], PaletteService.FOLIAGE_CHROMA, pulledHue]),
|
|
266
|
+
OklabUtil.lchToHex([PaletteService.FOLIAGE_STEPS[1], PaletteService.FOLIAGE_CHROMA, pulledHue]),
|
|
267
|
+
OklabUtil.lchToHex([PaletteService.FOLIAGE_STEPS[2], PaletteService.FOLIAGE_CHROMA, pulledHue])
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
static resolveText(ink, skyTop, wall, groundDark) {
|
|
271
|
+
const skyContrast = ColorUtil.contrast(ink, skyTop);
|
|
272
|
+
const wallContrast = ColorUtil.contrast(ink, wall);
|
|
273
|
+
const isInkLegible = skyContrast >= PaletteService.WCAG_AA_RATIO && wallContrast >= PaletteService.WCAG_AA_RATIO;
|
|
274
|
+
const text = isInkLegible ? ink : PaletteService.TEXT_LIGHT;
|
|
275
|
+
const darkContrast = ColorUtil.contrast(PaletteService.TEXT_LIGHT, groundDark);
|
|
276
|
+
const textOnDark = darkContrast >= PaletteService.WCAG_AA_RATIO ? PaletteService.TEXT_LIGHT : PaletteService.TEXT_DARK;
|
|
277
|
+
return { text, textOnDark };
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
export {
|
|
281
|
+
PaletteService
|
|
282
|
+
};
|
|
@@ -20,6 +20,8 @@ export declare class PieceService {
|
|
|
20
20
|
private static readonly SETTING_TO_CAST_SHAPE;
|
|
21
21
|
private static readonly OUTDOOR_CAST_SHAPE;
|
|
22
22
|
private static readonly DIGITS;
|
|
23
|
+
private static readonly OUTLINE_SIDE_WEIGHT;
|
|
24
|
+
private static readonly REFERENCE_WIDTH;
|
|
23
25
|
private static readonly MASK_PADDING;
|
|
24
26
|
private static readonly HATCH_INSET;
|
|
25
27
|
private static readonly HATCH_LOWER_START;
|
|
@@ -38,6 +40,8 @@ export declare class PieceService {
|
|
|
38
40
|
private static shadeOf;
|
|
39
41
|
private static castShape;
|
|
40
42
|
private static hatchShade;
|
|
43
|
+
private static readonly SHAFT_HIGHLIGHT_OPACITY;
|
|
41
44
|
private static softShade;
|
|
45
|
+
private static isInsideShaft;
|
|
42
46
|
}
|
|
43
47
|
export {};
|
|
@@ -16,6 +16,8 @@ class PieceService {
|
|
|
16
16
|
};
|
|
17
17
|
static OUTDOOR_CAST_SHAPE = { flatten: 0.24, slant: 0.75 };
|
|
18
18
|
static DIGITS = 3;
|
|
19
|
+
static OUTLINE_SIDE_WEIGHT = 0.8;
|
|
20
|
+
static REFERENCE_WIDTH = 1e3;
|
|
19
21
|
static MASK_PADDING = 0.2;
|
|
20
22
|
static HATCH_INSET = 0.08;
|
|
21
23
|
static HATCH_LOWER_START = 0.6;
|
|
@@ -39,7 +41,7 @@ class PieceService {
|
|
|
39
41
|
const settingAmbient = IdUtil.lookup(PieceService.SETTING_TO_AMBIENT, setting) ?? 1;
|
|
40
42
|
const ambient = light.isNight ? PieceService.NIGHT_CAST : settingAmbient;
|
|
41
43
|
const opacity = (ambient * PieceService.CAST_OPACITY * light.strength).toFixed(PieceService.DIGITS);
|
|
42
|
-
return `<g clip-path="url(#groundClip)" opacity="${opacity}"><g filter="url(#castF)">${casts.join("")}</g></g>`;
|
|
44
|
+
return `<g clip-path="url(#groundClip)" opacity="${opacity}" style="mix-blend-mode: multiply;"><g filter="url(#castF)">${casts.join("")}</g></g>`;
|
|
43
45
|
}
|
|
44
46
|
static isDecorated(placement, object) {
|
|
45
47
|
return !placement.isBackdrop && !PieceService.UNLIT_KINDS.includes(placement.kind) && object.kit !== false;
|
|
@@ -61,8 +63,15 @@ class PieceService {
|
|
|
61
63
|
let defs = "";
|
|
62
64
|
if (PieceService.isDecorated(placement, object)) {
|
|
63
65
|
if (kit.outline) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
const { inner: inner2, w, wobble = 0, weight = 0, detailRatio } = kit.outline;
|
|
67
|
+
artwork = inner2 ? KitService.innerStroke(art, inner2 / placement.scale, theme.ink, detailRatio) : art;
|
|
68
|
+
const radius = w / placement.scale;
|
|
69
|
+
const direction = pieceContext.light?.direction ?? 0;
|
|
70
|
+
defs += KitService.outlineFilter(`ol_${placement.id}`, radius, theme.ink, {
|
|
71
|
+
shadeX: direction * radius * weight * PieceService.OUTLINE_SIDE_WEIGHT,
|
|
72
|
+
shadeY: radius * weight,
|
|
73
|
+
wobble: wobble * context.width / PieceService.REFERENCE_WIDTH / placement.scale
|
|
74
|
+
});
|
|
66
75
|
filterId = `ol_${placement.id}`;
|
|
67
76
|
}
|
|
68
77
|
if (kit.hasDrop) {
|
|
@@ -71,7 +80,9 @@ class PieceService {
|
|
|
71
80
|
}
|
|
72
81
|
}
|
|
73
82
|
const inner = `<g id="${placement.id}" transform="${transform}"${hazeAttribute}><g id="b_${placement.id}">${artwork}</g></g>`;
|
|
74
|
-
|
|
83
|
+
const body = (filterId ? `${defs}<g filter="url(#${filterId})">${inner}</g>` : inner) + shade;
|
|
84
|
+
const isolated = `<g style="isolation: isolate;">${body}</g>`;
|
|
85
|
+
return cord + contact + isolated;
|
|
75
86
|
}
|
|
76
87
|
static cordOf(placement, ink) {
|
|
77
88
|
if (placement.kind !== "ceiling") {
|
|
@@ -127,7 +138,7 @@ class PieceService {
|
|
|
127
138
|
const cast = PieceService.castShape(placement, light, context);
|
|
128
139
|
casts.push(cast);
|
|
129
140
|
}
|
|
130
|
-
const layer = light.isHatch ? PieceService.hatchShade(placement, light, box, opacity) : PieceService.softShade(placement, box, { opacity, isGrounded });
|
|
141
|
+
const layer = light.isHatch ? PieceService.hatchShade(placement, light, box, opacity) : PieceService.softShade(placement, box, { opacity, isGrounded, light });
|
|
131
142
|
return `${mask}${layer}`;
|
|
132
143
|
}
|
|
133
144
|
static castShape(placement, light, context) {
|
|
@@ -144,9 +155,19 @@ class PieceService {
|
|
|
144
155
|
const bottom = box.y + box.height;
|
|
145
156
|
return `<g mask="url(#mk_${placement.id})" opacity="${opacity}"><rect x="${left.toFixed(1)}" y="${top.toFixed(1)}" width="${Math.max(0, right - left).toFixed(1)}" height="${Math.max(0, bottom - top).toFixed(1)}" fill="url(#hatchP)"/></g>`;
|
|
146
157
|
}
|
|
158
|
+
static SHAFT_HIGHLIGHT_OPACITY = 0.3;
|
|
147
159
|
static softShade(placement, box, shade) {
|
|
148
|
-
const occlusion = shade.isGrounded ? `<rect x="${placement.boxLeft.toFixed(1)}" y="${placement.boxTop.toFixed(1)}" width="${placement.width.toFixed(1)}" height="${placement.height.toFixed(1)}" fill="url(#lgAO)"/>` : "";
|
|
149
|
-
|
|
160
|
+
const occlusion = shade.isGrounded ? `<rect x="${placement.boxLeft.toFixed(1)}" y="${placement.boxTop.toFixed(1)}" width="${placement.width.toFixed(1)}" height="${placement.height.toFixed(1)}" fill="url(#lgAO)" style="mix-blend-mode: multiply;"/>` : "";
|
|
161
|
+
const extraLight = PieceService.isInsideShaft(placement, shade.light.shaft) ? `<rect x="${box.x.toFixed(1)}" y="${box.y.toFixed(1)}" width="${box.width.toFixed(1)}" height="${box.height.toFixed(1)}" fill="url(#lgLight)" opacity="${PieceService.SHAFT_HIGHLIGHT_OPACITY}" style="mix-blend-mode: screen;"/>` : "";
|
|
162
|
+
return `<g mask="url(#mk_${placement.id})" opacity="${shade.opacity}"><rect x="${box.x.toFixed(1)}" y="${box.y.toFixed(1)}" width="${box.width.toFixed(1)}" height="${box.height.toFixed(1)}" fill="url(#lgLight)" style="mix-blend-mode: screen;"/>` + extraLight + `<rect x="${box.x.toFixed(1)}" y="${box.y.toFixed(1)}" width="${box.width.toFixed(1)}" height="${box.height.toFixed(1)}" fill="url(#lgShade)" style="mix-blend-mode: multiply;"/>${occlusion}</g>`;
|
|
163
|
+
}
|
|
164
|
+
static isInsideShaft(placement, shaft) {
|
|
165
|
+
if (!shaft) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
const shaftMinX = Math.min(shaft.windowX - shaft.windowWidth / 2, shaft.floorLeft);
|
|
169
|
+
const shaftMaxX = Math.max(shaft.windowX + shaft.windowWidth / 2, shaft.floorRight);
|
|
170
|
+
return placement.x >= shaftMinX && placement.x <= shaftMaxX && placement.y >= shaft.windowY;
|
|
150
171
|
}
|
|
151
172
|
}
|
|
152
173
|
export {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DEPTH_NAMES } from "../Protocols/SceneProtocol.js";
|
|
2
2
|
import { AssetService } from "./AssetService.js";
|
|
3
3
|
import { DependencyOrderService } from "./DependencyOrderService.js";
|
|
4
|
+
import { DetailService } from "./DetailService.js";
|
|
4
5
|
import { IdUtil } from "../Utils/IdUtil.js";
|
|
5
6
|
import { RequireUtil } from "../Utils/RequireUtil.js";
|
|
6
7
|
import { PersonUtil } from "../Utils/PersonUtil.js";
|
|
@@ -129,6 +130,11 @@ class PlacementService {
|
|
|
129
130
|
return null;
|
|
130
131
|
}
|
|
131
132
|
const asset = RequireUtil.defined(library[resolved.id], `library asset ${resolved.id}`);
|
|
133
|
+
if (object.variant !== void 0 && asset.variants && !asset.variants.includes(String(object.variant))) {
|
|
134
|
+
warnings.push(
|
|
135
|
+
`'${id}' has no variant '${object.variant}' for '${resolved.id}'; use one of: ${asset.variants.join(", ")}`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
132
138
|
const size = asset.size ? asset.size(object) : { w: asset.width, h: asset.height };
|
|
133
139
|
const sizeFactor = PlacementService.sizeFactor(id, object, warnings);
|
|
134
140
|
const request = {
|
|
@@ -145,7 +151,7 @@ class PlacementService {
|
|
|
145
151
|
if (!position) {
|
|
146
152
|
return null;
|
|
147
153
|
}
|
|
148
|
-
const drawn = asset.draw({ ...object }, theme);
|
|
154
|
+
const drawn = asset.draw({ ...object, detail: DetailService.resolve(id, object, context) }, theme);
|
|
149
155
|
const drawnSize = typeof drawn === "string" ? size : drawn.box;
|
|
150
156
|
const width = drawnSize.w * position.scale;
|
|
151
157
|
const height = drawnSize.h * position.scale;
|
|
@@ -11,9 +11,13 @@ export declare class PlaneBackgroundService {
|
|
|
11
11
|
private static readonly MIN_PLANK_WIDTH;
|
|
12
12
|
private static readonly OFF_FRAME_MARGIN;
|
|
13
13
|
private static readonly JOINT_SPACING;
|
|
14
|
+
private static readonly DEFAULT_RIDGES;
|
|
15
|
+
private static readonly DEFAULT_SEED;
|
|
16
|
+
private static readonly PATH_TUFT_MARGIN;
|
|
14
17
|
static draw(world: PlaneWorld): Background;
|
|
15
18
|
private static defs;
|
|
16
19
|
private static outdoors;
|
|
20
|
+
private static isNearPath;
|
|
17
21
|
private static room;
|
|
18
22
|
private static floorPolygon;
|
|
19
23
|
private static backPolygon;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { GroundDetailService } from "./GroundDetailService.js";
|
|
1
2
|
import { PlaneBoxService } from "./PlaneBoxService.js";
|
|
3
|
+
import { RidgeService } from "./RidgeService.js";
|
|
4
|
+
import { SkyDetailService } from "./SkyDetailService.js";
|
|
2
5
|
import { ColorUtil } from "../Utils/ColorUtil.js";
|
|
3
6
|
import { FormatUtil } from "../Utils/FormatUtil.js";
|
|
4
7
|
import { SvgUtil } from "../Utils/SvgUtil.js";
|
|
@@ -11,6 +14,9 @@ class PlaneBackgroundService {
|
|
|
11
14
|
static MIN_PLANK_WIDTH = 1e-4;
|
|
12
15
|
static OFF_FRAME_MARGIN = 40;
|
|
13
16
|
static JOINT_SPACING = 0.55;
|
|
17
|
+
static DEFAULT_RIDGES = 2;
|
|
18
|
+
static DEFAULT_SEED = 1;
|
|
19
|
+
static PATH_TUFT_MARGIN = 30;
|
|
14
20
|
static draw(world) {
|
|
15
21
|
const { camera, scene } = world;
|
|
16
22
|
const horizonZ = scene.canvas?.horizon_z ?? PlaneBackgroundService.DEFAULT_HORIZON_Z;
|
|
@@ -22,7 +28,7 @@ class PlaneBackgroundService {
|
|
|
22
28
|
const shadowChannels = theme.shadow.match(PlaneBackgroundService.NUMBER) ?? PlaneBackgroundService.DEFAULT_SHADOW;
|
|
23
29
|
const [red = 0, green = 0, blue = 0, alpha = 0.15] = shadowChannels.map(Number);
|
|
24
30
|
const shadow = `rgb(${red},${green},${blue})`;
|
|
25
|
-
let defs = `<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><
|
|
31
|
+
let defs = `<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">${SkyDetailService.skyGradientStops(theme)}</linearGradient><filter id="dither"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="1" stitchTiles="stitch" result="nz"/><feColorMatrix in="nz" type="matrix" values="0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.012 0" result="d"/><feBlend in="SourceGraphic" in2="d" mode="soft-light"/></filter><linearGradient id="ground" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${ColorUtil.sh(theme.ground, 0.18)}"/><stop offset="1" stop-color="${theme.ground}"/></linearGradient>`;
|
|
26
32
|
defs += `<radialGradient id="cshadow"><stop offset="0" stop-color="${shadow}" stop-opacity="${alpha * 1.5}"/><stop offset="0.55" stop-color="${shadow}" stop-opacity="${alpha * 1.1}"/><stop offset="1" stop-color="${shadow}" stop-opacity="0"/></radialGradient>`;
|
|
27
33
|
const [airRed = 0, airGreen = 0, airBlue = 0] = [1, 3, 5].map((start) => {
|
|
28
34
|
const channel = theme.skyBottom.slice(start, start + 2);
|
|
@@ -38,11 +44,44 @@ class PlaneBackgroundService {
|
|
|
38
44
|
return defs;
|
|
39
45
|
}
|
|
40
46
|
static outdoors(world, horizonY) {
|
|
41
|
-
const { theme, camera } = world;
|
|
47
|
+
const { theme, camera, scene } = world;
|
|
42
48
|
const { width, height } = camera;
|
|
43
49
|
const num = FormatUtil.oneDecimal;
|
|
44
50
|
const hill = ColorUtil.sh(theme.groundDark || theme.ground, 0.25);
|
|
45
|
-
|
|
51
|
+
const ridges = RidgeService.draw({
|
|
52
|
+
count: scene.canvas?.ridges ?? PlaneBackgroundService.DEFAULT_RIDGES,
|
|
53
|
+
seed: scene.canvas?.seed ?? PlaneBackgroundService.DEFAULT_SEED,
|
|
54
|
+
width,
|
|
55
|
+
horizonY,
|
|
56
|
+
groundColor: hill,
|
|
57
|
+
airColor: theme.skyBottom,
|
|
58
|
+
bottomY: height
|
|
59
|
+
});
|
|
60
|
+
const groundDetail = GroundDetailService.draw({
|
|
61
|
+
detail: scene.canvas?.ground_detail ?? "low",
|
|
62
|
+
seed: scene.canvas?.seed ?? PlaneBackgroundService.DEFAULT_SEED,
|
|
63
|
+
width,
|
|
64
|
+
height,
|
|
65
|
+
horizonY,
|
|
66
|
+
theme,
|
|
67
|
+
isPathBlocked: (posX, posY) => PlaneBackgroundService.isNearPath(world, posX, posY)
|
|
68
|
+
});
|
|
69
|
+
return `<rect width="${width}" height="${height}" fill="url(#sky)" filter="url(#dither)"/>` + ridges + `<path d="M0 ${num(horizonY + 2)} Q${width * 0.25} ${num(horizonY - height * 0.035)} ${width * 0.5} ${num(horizonY)} T${width} ${num(horizonY - height * 0.02)} L${width} ${height} L0 ${height} Z" fill="url(#ground)"/>` + groundDetail;
|
|
70
|
+
}
|
|
71
|
+
static isNearPath(world, posX, posY) {
|
|
72
|
+
const points = world.scene.path?.points;
|
|
73
|
+
if (!points || points.length === 0) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return points.some((point) => {
|
|
77
|
+
const at = point.at;
|
|
78
|
+
if (!at) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const [screenX, screenY] = world.camera.project(at[0], at[1]);
|
|
82
|
+
const distance = Math.hypot(posX - screenX, posY - screenY);
|
|
83
|
+
return distance < PlaneBackgroundService.PATH_TUFT_MARGIN;
|
|
84
|
+
});
|
|
46
85
|
}
|
|
47
86
|
static room(world) {
|
|
48
87
|
const { theme, camera, scene } = world;
|
|
@@ -9,8 +9,12 @@ export declare class PlaneProjectionService {
|
|
|
9
9
|
private static readonly BOARD_SPREAD_MIN;
|
|
10
10
|
private static readonly BOARD_SPREAD_RANGE;
|
|
11
11
|
private static readonly FRAME_FILL;
|
|
12
|
+
private static readonly ISO_UNIT;
|
|
13
|
+
private static shrinkOf;
|
|
14
|
+
private static lensOf;
|
|
12
15
|
static create(canvas: Canvas, width: number, height: number): PlaneCamera;
|
|
13
16
|
private static roomOf;
|
|
14
17
|
private static roomLens;
|
|
18
|
+
private static isometricLens;
|
|
15
19
|
private static boardLens;
|
|
16
20
|
}
|