@guilhermebkel/scenec 0.1.2 → 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 +34 -31
- package/dist/Adapters/FileReaderAdapter.d.ts +4 -0
- package/dist/Adapters/FileReaderAdapter.js +21 -0
- package/dist/Adapters/FontAdapter.d.ts +5 -0
- package/dist/Adapters/FontAdapter.js +13 -0
- package/dist/Adapters/ResvgAdapter.d.ts +11 -0
- package/dist/Adapters/ResvgAdapter.js +18 -0
- package/dist/Commands/BaseCommand.d.ts +11 -0
- package/dist/Commands/BaseCommand.js +13 -0
- package/dist/Commands/BestCommand.d.ts +11 -0
- package/dist/Commands/BestCommand.js +73 -0
- package/dist/Commands/CatalogCommand.d.ts +6 -0
- package/dist/Commands/CatalogCommand.js +24 -0
- package/dist/Commands/CheckCommand.d.ts +5 -0
- package/dist/Commands/CheckCommand.js +8 -0
- package/dist/Commands/RenderCommand.d.ts +7 -0
- package/dist/Commands/RenderCommand.js +15 -0
- package/dist/Commands/SceneCommand.d.ts +11 -0
- package/dist/Commands/SceneCommand.js +70 -0
- package/dist/Commands/SchemaCommand.d.ts +5 -0
- package/dist/Commands/SchemaCommand.js +12 -0
- package/dist/Data/cities.json +312 -0
- package/dist/Data/europe.json +1 -0
- package/dist/Errors/SceneError.d.ts +4 -0
- package/dist/Errors/SceneError.js +11 -0
- package/dist/Errors/UnsafeSvgError.d.ts +3 -0
- package/dist/Errors/UnsafeSvgError.js +9 -0
- package/dist/Modules/BestModule.d.ts +41 -0
- package/dist/Modules/BestModule.js +159 -0
- package/dist/Modules/CheckModule.d.ts +8 -0
- package/dist/Modules/CheckModule.js +16 -0
- package/dist/Modules/CompilationModule.d.ts +23 -0
- package/dist/Modules/CompilationModule.js +210 -0
- package/dist/Modules/CritiqueModule.d.ts +9 -0
- package/dist/Modules/CritiqueModule.js +98 -0
- package/dist/Modules/MapModule.d.ts +24 -0
- package/dist/Modules/MapModule.js +99 -0
- package/dist/Modules/ParsingModule.d.ts +17 -0
- package/dist/Modules/ParsingModule.js +88 -0
- package/dist/Modules/PlaneModule.d.ts +19 -0
- package/dist/Modules/PlaneModule.js +98 -0
- package/dist/Protocols/AssetProtocol.d.ts +67 -0
- package/dist/Protocols/AssetProtocol.js +109 -0
- package/dist/Protocols/CommandProtocol.d.ts +8 -0
- package/dist/Protocols/CommandProtocol.js +0 -0
- package/dist/Protocols/CompilationProtocol.d.ts +136 -0
- package/dist/Protocols/CompilationProtocol.js +0 -0
- package/dist/Protocols/CritiqueProtocol.d.ts +58 -0
- package/dist/Protocols/CritiqueProtocol.js +14 -0
- package/dist/Protocols/CustomAssetProtocol.d.ts +24 -0
- package/dist/Protocols/CustomAssetProtocol.js +0 -0
- package/dist/Protocols/GroupProtocol.d.ts +17 -0
- package/dist/Protocols/GroupProtocol.js +12 -0
- package/dist/Protocols/KitProtocol.d.ts +32 -0
- package/dist/Protocols/KitProtocol.js +23 -0
- package/dist/Protocols/MapProtocol.d.ts +77 -0
- package/dist/Protocols/MapProtocol.js +4 -0
- package/dist/Protocols/OptionsProtocol.js +0 -0
- package/dist/Protocols/PersonProtocol.d.ts +68 -0
- package/dist/Protocols/PersonProtocol.js +42 -0
- package/dist/Protocols/PlaneProtocol.d.ts +140 -0
- package/dist/Protocols/PlaneProtocol.js +4 -0
- package/dist/{pipeline/index.d.ts → Protocols/ResultProtocol.d.ts} +0 -2
- package/dist/Protocols/ResultProtocol.js +0 -0
- package/dist/Protocols/SceneProtocol.d.ts +824 -0
- package/dist/Protocols/SceneProtocol.js +357 -0
- package/dist/{protocols/theme.d.ts → Protocols/ThemeProtocol.d.ts} +4 -0
- package/dist/Protocols/ThemeProtocol.js +28 -0
- package/dist/Resources/Assets/BackpackAsset.d.ts +10 -0
- package/dist/Resources/Assets/BackpackAsset.js +31 -0
- package/dist/Resources/Assets/BallAsset.d.ts +10 -0
- package/dist/Resources/Assets/BallAsset.js +15 -0
- package/dist/Resources/Assets/BalloonsAsset.d.ts +10 -0
- package/dist/Resources/Assets/BalloonsAsset.js +26 -0
- package/dist/Resources/Assets/BaseAsset.d.ts +17 -0
- package/dist/Resources/Assets/BaseAsset.js +11 -0
- package/dist/Resources/Assets/BeachTowelAsset.d.ts +10 -0
- package/dist/Resources/Assets/BeachTowelAsset.js +14 -0
- package/dist/Resources/Assets/BedAsset.d.ts +12 -0
- package/dist/Resources/Assets/BedAsset.js +25 -0
- package/dist/Resources/Assets/BenchAsset.d.ts +11 -0
- package/dist/Resources/Assets/BenchAsset.js +24 -0
- package/dist/Resources/Assets/BicycleAsset.d.ts +10 -0
- package/dist/Resources/Assets/BicycleAsset.js +18 -0
- package/dist/Resources/Assets/BigPlantAsset.d.ts +10 -0
- package/dist/Resources/Assets/BigPlantAsset.js +26 -0
- package/dist/Resources/Assets/BirdAsset.d.ts +10 -0
- package/dist/Resources/Assets/BirdAsset.js +14 -0
- package/dist/Resources/Assets/BlackboardAsset.d.ts +11 -0
- package/dist/Resources/Assets/BlackboardAsset.js +20 -0
- package/dist/Resources/Assets/BoardAsset.d.ts +12 -0
- package/dist/Resources/Assets/BoardAsset.js +44 -0
- package/dist/Resources/Assets/BoatAsset.d.ts +10 -0
- package/dist/Resources/Assets/BoatAsset.js +15 -0
- package/dist/Resources/Assets/BooksAsset.d.ts +10 -0
- package/dist/Resources/Assets/BooksAsset.js +35 -0
- package/dist/Resources/Assets/BookshelfAsset.d.ts +10 -0
- package/dist/Resources/Assets/BookshelfAsset.js +33 -0
- package/dist/Resources/Assets/BuildingAsset.d.ts +14 -0
- package/dist/Resources/Assets/BuildingAsset.js +34 -0
- package/dist/Resources/Assets/BurgerAsset.d.ts +9 -0
- package/dist/Resources/Assets/BurgerAsset.js +23 -0
- package/dist/Resources/Assets/BushAsset.d.ts +10 -0
- package/dist/Resources/Assets/BushAsset.js +17 -0
- package/dist/Resources/Assets/CabinetAsset.d.ts +14 -0
- package/dist/Resources/Assets/CabinetAsset.js +49 -0
- package/dist/Resources/Assets/CablesAsset.d.ts +10 -0
- package/dist/Resources/Assets/CablesAsset.js +16 -0
- package/dist/Resources/Assets/CakeAsset.d.ts +10 -0
- package/dist/Resources/Assets/CakeAsset.js +29 -0
- package/dist/Resources/Assets/CapAsset.d.ts +10 -0
- package/dist/Resources/Assets/CapAsset.js +18 -0
- package/dist/Resources/Assets/CarAsset.d.ts +10 -0
- package/dist/Resources/Assets/CarAsset.js +29 -0
- package/dist/Resources/Assets/CatAsset.d.ts +10 -0
- package/dist/Resources/Assets/CatAsset.js +17 -0
- package/dist/Resources/Assets/ChairAsset.d.ts +16 -0
- package/dist/Resources/Assets/ChairAsset.js +55 -0
- package/dist/Resources/Assets/ChatBubbleAsset.d.ts +11 -0
- package/dist/Resources/Assets/ChatBubbleAsset.js +18 -0
- package/dist/Resources/Assets/ClockAsset.d.ts +11 -0
- package/dist/Resources/Assets/ClockAsset.js +22 -0
- package/dist/Resources/Assets/CloudAsset.d.ts +10 -0
- package/dist/Resources/Assets/CloudAsset.js +17 -0
- package/dist/Resources/Assets/CoffeeMachineAsset.d.ts +10 -0
- package/dist/Resources/Assets/CoffeeMachineAsset.js +23 -0
- package/dist/Resources/Assets/ConfettiAsset.d.ts +10 -0
- package/dist/Resources/Assets/ConfettiAsset.js +18 -0
- package/dist/Resources/Assets/CounterAsset.d.ts +11 -0
- package/dist/Resources/Assets/CounterAsset.js +29 -0
- package/dist/Resources/Assets/CupAsset.d.ts +10 -0
- package/dist/Resources/Assets/CupAsset.js +17 -0
- package/dist/Resources/Assets/CursorAsset.d.ts +11 -0
- package/dist/Resources/Assets/CursorAsset.js +17 -0
- package/dist/Resources/Assets/CustomAsset.d.ts +25 -0
- package/dist/Resources/Assets/CustomAsset.js +58 -0
- package/dist/Resources/Assets/DeskAsset.d.ts +11 -0
- package/dist/Resources/Assets/DeskAsset.js +40 -0
- package/dist/Resources/Assets/DeskSlabAsset.d.ts +18 -0
- package/dist/Resources/Assets/DeskSlabAsset.js +43 -0
- package/dist/Resources/Assets/DiplomaAsset.d.ts +10 -0
- package/dist/Resources/Assets/DiplomaAsset.js +23 -0
- package/dist/Resources/Assets/DogAsset.d.ts +10 -0
- package/dist/Resources/Assets/DogAsset.js +24 -0
- package/dist/Resources/Assets/DrawerUnitAsset.d.ts +14 -0
- package/dist/Resources/Assets/DrawerUnitAsset.js +35 -0
- package/dist/Resources/Assets/FenceAsset.d.ts +10 -0
- package/dist/Resources/Assets/FenceAsset.js +26 -0
- package/dist/Resources/Assets/FigurineAsset.d.ts +10 -0
- package/dist/Resources/Assets/FigurineAsset.js +24 -0
- package/dist/Resources/Assets/FinishFlagAsset.d.ts +10 -0
- package/dist/Resources/Assets/FinishFlagAsset.js +21 -0
- package/dist/Resources/Assets/FirstAidKitAsset.d.ts +10 -0
- package/dist/Resources/Assets/FirstAidKitAsset.js +19 -0
- package/dist/Resources/Assets/FloorLampAsset.d.ts +10 -0
- package/dist/Resources/Assets/FloorLampAsset.js +22 -0
- package/dist/Resources/Assets/FlowersAsset.d.ts +10 -0
- package/dist/Resources/Assets/FlowersAsset.js +37 -0
- package/dist/Resources/Assets/FrameAsset.d.ts +11 -0
- package/dist/Resources/Assets/FrameAsset.js +24 -0
- package/dist/Resources/Assets/FruitBowlAsset.d.ts +10 -0
- package/dist/Resources/Assets/FruitBowlAsset.js +16 -0
- package/dist/Resources/Assets/GlassShelfAsset.d.ts +17 -0
- package/dist/Resources/Assets/GlassShelfAsset.js +25 -0
- package/dist/Resources/Assets/GlobeAsset.d.ts +10 -0
- package/dist/Resources/Assets/GlobeAsset.js +18 -0
- package/dist/Resources/Assets/HeadphonesAsset.d.ts +10 -0
- package/dist/Resources/Assets/HeadphonesAsset.js +23 -0
- package/dist/Resources/Assets/HouseAsset.d.ts +10 -0
- package/dist/Resources/Assets/HouseAsset.js +58 -0
- package/dist/Resources/Assets/LabAsset.d.ts +10 -0
- package/dist/Resources/Assets/LabAsset.js +52 -0
- package/dist/Resources/Assets/LampAsset.d.ts +10 -0
- package/dist/Resources/Assets/LampAsset.js +16 -0
- package/dist/Resources/Assets/LaptopAsset.d.ts +10 -0
- package/dist/Resources/Assets/LaptopAsset.js +27 -0
- package/dist/Resources/Assets/LaptopOpenAsset.d.ts +10 -0
- package/dist/Resources/Assets/LaptopOpenAsset.js +29 -0
- package/dist/Resources/Assets/LightSwitchAsset.d.ts +11 -0
- package/dist/Resources/Assets/LightSwitchAsset.js +24 -0
- package/dist/Resources/Assets/MonitorAsset.d.ts +10 -0
- package/dist/Resources/Assets/MonitorAsset.js +40 -0
- package/dist/Resources/Assets/MoonAsset.d.ts +10 -0
- package/dist/Resources/Assets/MoonAsset.js +16 -0
- package/dist/Resources/Assets/MountainAsset.d.ts +10 -0
- package/dist/Resources/Assets/MountainAsset.js +15 -0
- package/dist/Resources/Assets/OfficeChairAsset.d.ts +10 -0
- package/dist/Resources/Assets/OfficeChairAsset.js +45 -0
- package/dist/Resources/Assets/PalmAsset.d.ts +10 -0
- package/dist/Resources/Assets/PalmAsset.js +32 -0
- package/dist/Resources/Assets/PaperCupAsset.d.ts +10 -0
- package/dist/Resources/Assets/PaperCupAsset.js +17 -0
- package/dist/Resources/Assets/PendantLampAsset.d.ts +10 -0
- package/dist/Resources/Assets/PendantLampAsset.js +16 -0
- package/dist/Resources/Assets/PennantAsset.d.ts +10 -0
- package/dist/Resources/Assets/PennantAsset.js +15 -0
- package/dist/Resources/Assets/PersonAsset.d.ts +10 -0
- package/dist/Resources/Assets/PersonAsset.js +15 -0
- package/dist/Resources/Assets/PhotoFrameAsset.d.ts +15 -0
- package/dist/Resources/Assets/PhotoFrameAsset.js +68 -0
- package/dist/Resources/Assets/PineAsset.d.ts +10 -0
- package/dist/Resources/Assets/PineAsset.js +21 -0
- package/dist/Resources/Assets/PizzaAsset.d.ts +10 -0
- package/dist/Resources/Assets/PizzaAsset.js +17 -0
- package/dist/Resources/Assets/PlantAsset.d.ts +10 -0
- package/dist/Resources/Assets/PlantAsset.js +17 -0
- package/dist/Resources/Assets/PlasticBagAsset.d.ts +10 -0
- package/dist/Resources/Assets/PlasticBagAsset.js +15 -0
- package/dist/Resources/Assets/PlateAsset.d.ts +10 -0
- package/dist/Resources/Assets/PlateAsset.js +17 -0
- 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/RollingCartAsset.d.ts +11 -0
- package/dist/Resources/Assets/RollingCartAsset.js +34 -0
- package/dist/Resources/Assets/RugAsset.d.ts +10 -0
- package/dist/Resources/Assets/RugAsset.js +19 -0
- package/dist/Resources/Assets/SandcastleAsset.d.ts +10 -0
- package/dist/Resources/Assets/SandcastleAsset.js +30 -0
- package/dist/Resources/Assets/SchoolAsset.d.ts +10 -0
- package/dist/Resources/Assets/SchoolAsset.js +32 -0
- package/dist/Resources/Assets/ShelfWallAsset.d.ts +11 -0
- package/dist/Resources/Assets/ShelfWallAsset.js +23 -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 +16 -0
- package/dist/Resources/Assets/SofaAsset.js +66 -0
- package/dist/Resources/Assets/StageAsset.d.ts +10 -0
- package/dist/Resources/Assets/StageAsset.js +44 -0
- package/dist/Resources/Assets/StarAsset.d.ts +10 -0
- package/dist/Resources/Assets/StarAsset.js +14 -0
- package/dist/Resources/Assets/StarsAsset.d.ts +17 -0
- package/dist/Resources/Assets/StarsAsset.js +55 -0
- 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/StreetlightAsset.d.ts +10 -0
- package/dist/Resources/Assets/StreetlightAsset.js +20 -0
- package/dist/Resources/Assets/SuitcaseAsset.d.ts +10 -0
- package/dist/Resources/Assets/SuitcaseAsset.js +42 -0
- package/dist/Resources/Assets/SunAsset.d.ts +10 -0
- package/dist/Resources/Assets/SunAsset.js +22 -0
- package/dist/Resources/Assets/TableAsset.d.ts +15 -0
- package/dist/Resources/Assets/TableAsset.js +21 -0
- package/dist/Resources/Assets/ToggleAsset.d.ts +11 -0
- package/dist/Resources/Assets/ToggleAsset.js +21 -0
- package/dist/Resources/Assets/TrashCanAsset.d.ts +10 -0
- package/dist/Resources/Assets/TrashCanAsset.js +31 -0
- package/dist/Resources/Assets/TreeAsset.d.ts +15 -0
- package/dist/Resources/Assets/TreeAsset.js +48 -0
- package/dist/Resources/Assets/TrophyAsset.d.ts +10 -0
- package/dist/Resources/Assets/TrophyAsset.js +16 -0
- package/dist/Resources/Assets/TumblerAsset.d.ts +10 -0
- package/dist/Resources/Assets/TumblerAsset.js +17 -0
- package/dist/Resources/Assets/TvAsset.d.ts +10 -0
- package/dist/Resources/Assets/TvAsset.js +29 -0
- package/dist/Resources/Assets/TvStandAsset.d.ts +11 -0
- package/dist/Resources/Assets/TvStandAsset.js +34 -0
- package/dist/Resources/Assets/UmbrellaAsset.d.ts +10 -0
- package/dist/Resources/Assets/UmbrellaAsset.js +17 -0
- package/dist/Resources/Assets/UniversityAsset.d.ts +10 -0
- package/dist/Resources/Assets/UniversityAsset.js +22 -0
- package/dist/Resources/Assets/VaseFlowersAsset.d.ts +10 -0
- package/dist/Resources/Assets/VaseFlowersAsset.js +16 -0
- 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/Assets/WindowAsset.d.ts +11 -0
- package/dist/Resources/Assets/WindowAsset.js +32 -0
- package/dist/Resources/Groups/BaseGroup.d.ts +7 -0
- package/dist/Resources/Groups/BaseGroup.js +5 -0
- package/dist/Resources/Groups/CelebrationGroup.d.ts +8 -0
- package/dist/Resources/Groups/CelebrationGroup.js +19 -0
- package/dist/Resources/Groups/ConversationGroup.d.ts +9 -0
- package/dist/Resources/Groups/ConversationGroup.js +17 -0
- package/dist/Resources/Groups/DiningGroup.d.ts +8 -0
- package/dist/Resources/Groups/DiningGroup.js +21 -0
- package/dist/Resources/Groups/MeetingGroup.d.ts +8 -0
- package/dist/Resources/Groups/MeetingGroup.js +22 -0
- package/dist/Resources/Groups/ParkBenchGroup.d.ts +8 -0
- package/dist/Resources/Groups/ParkBenchGroup.js +17 -0
- package/dist/Resources/Groups/ReadingCornerGroup.d.ts +8 -0
- package/dist/Resources/Groups/ReadingCornerGroup.js +17 -0
- package/dist/Resources/Groups/WorkspaceGroup.d.ts +10 -0
- package/dist/Resources/Groups/WorkspaceGroup.js +25 -0
- package/dist/Resources/Kits/BaseKit.d.ts +13 -0
- package/dist/Resources/Kits/BaseKit.js +12 -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/FlatKit.d.ts +5 -0
- package/dist/Resources/Kits/FlatKit.js +8 -0
- package/dist/Resources/Kits/HatchKit.d.ts +15 -0
- package/dist/Resources/Kits/HatchKit.js +12 -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 +15 -0
- package/dist/Resources/Kits/OutlineKit.js +10 -0
- package/dist/Resources/Kits/PaperKit.d.ts +13 -0
- package/dist/Resources/Kits/PaperKit.js +12 -0
- package/dist/Resources/Kits/PosterKit.d.ts +14 -0
- package/dist/Resources/Kits/PosterKit.js +16 -0
- package/dist/Resources/Kits/RisoKit.d.ts +16 -0
- package/dist/Resources/Kits/RisoKit.js +11 -0
- package/dist/Resources/Kits/SketchKit.d.ts +10 -0
- package/dist/Resources/Kits/SketchKit.js +12 -0
- package/dist/Resources/Themes/BaseTheme.d.ts +5 -0
- package/dist/Resources/Themes/BaseTheme.js +5 -0
- package/dist/Resources/Themes/BeachTheme.d.ts +6 -0
- package/dist/Resources/Themes/BeachTheme.js +31 -0
- package/dist/Resources/Themes/FlatAutumnTheme.d.ts +6 -0
- package/dist/Resources/Themes/FlatAutumnTheme.js +29 -0
- package/dist/Resources/Themes/FlatCoolTheme.d.ts +6 -0
- package/dist/Resources/Themes/FlatCoolTheme.js +29 -0
- package/dist/Resources/Themes/NightTheme.d.ts +6 -0
- package/dist/Resources/Themes/NightTheme.js +29 -0
- package/dist/Resources/Themes/WarmCafeTheme.d.ts +6 -0
- package/dist/Resources/Themes/WarmCafeTheme.js +29 -0
- package/dist/Services/AssetService.d.ts +12 -0
- package/dist/Services/AssetService.js +232 -0
- package/dist/Services/BackgroundService.d.ts +41 -0
- package/dist/Services/BackgroundService.js +177 -0
- package/dist/Services/BalanceCritiqueService.d.ts +13 -0
- package/dist/Services/BalanceCritiqueService.js +64 -0
- package/dist/Services/CameraService.d.ts +21 -0
- package/dist/Services/CameraService.js +121 -0
- package/dist/Services/CatalogService.d.ts +30 -0
- package/dist/Services/CatalogService.js +56 -0
- package/dist/Services/ColorCritiqueService.d.ts +42 -0
- package/dist/Services/ColorCritiqueService.js +232 -0
- package/dist/Services/ContextService.d.ts +21 -0
- package/dist/Services/ContextService.js +98 -0
- package/dist/Services/CoverageCritiqueService.d.ts +16 -0
- package/dist/Services/CoverageCritiqueService.js +84 -0
- package/dist/Services/CustomAssetService.d.ts +31 -0
- package/dist/Services/CustomAssetService.js +184 -0
- package/dist/Services/DependencyOrderService.d.ts +12 -0
- package/dist/Services/DependencyOrderService.js +73 -0
- package/dist/Services/DescriptionService.d.ts +10 -0
- package/dist/Services/DescriptionService.js +33 -0
- 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/FramingCheckService.d.ts +15 -0
- package/dist/Services/FramingCheckService.js +93 -0
- package/dist/Services/FramingService.d.ts +31 -0
- package/dist/Services/FramingService.js +108 -0
- package/dist/Services/GazeService.d.ts +6 -0
- package/dist/Services/GazeService.js +45 -0
- package/dist/Services/GroundDetailService.d.ts +50 -0
- package/dist/Services/GroundDetailService.js +115 -0
- package/dist/Services/GroupService.d.ts +17 -0
- package/dist/Services/GroupService.js +152 -0
- package/dist/Services/KitService.d.ts +32 -0
- package/dist/Services/KitService.js +131 -0
- package/dist/Services/LightingService.d.ts +39 -0
- package/dist/Services/LightingService.js +237 -0
- package/dist/Services/MapBaseService.d.ts +24 -0
- package/dist/Services/MapBaseService.js +104 -0
- package/dist/Services/MapLabelService.d.ts +26 -0
- package/dist/Services/MapLabelService.js +185 -0
- package/dist/Services/MapLegService.d.ts +23 -0
- package/dist/Services/MapLegService.js +87 -0
- package/dist/Services/MapPanelService.d.ts +16 -0
- package/dist/Services/MapPanelService.js +89 -0
- package/dist/Services/MapPinService.d.ts +11 -0
- package/dist/Services/MapPinService.js +56 -0
- package/dist/Services/MapProjectionService.d.ts +14 -0
- package/dist/Services/MapProjectionService.js +70 -0
- package/dist/Services/MapRouteService.d.ts +17 -0
- package/dist/Services/MapRouteService.js +79 -0
- package/dist/Services/PaletteService.d.ts +108 -0
- package/dist/Services/PaletteService.js +282 -0
- package/dist/Services/PieceService.d.ts +47 -0
- package/dist/Services/PieceService.js +175 -0
- package/dist/Services/PlacementService.d.ts +60 -0
- package/dist/Services/PlacementService.js +421 -0
- package/dist/Services/PlaneBackgroundService.d.ts +28 -0
- package/dist/Services/PlaneBackgroundService.js +209 -0
- package/dist/Services/PlaneBoxService.d.ts +27 -0
- package/dist/Services/PlaneBoxService.js +209 -0
- package/dist/Services/PlaneDepthService.d.ts +18 -0
- package/dist/Services/PlaneDepthService.js +146 -0
- package/dist/Services/PlaneLabelService.d.ts +13 -0
- package/dist/Services/PlaneLabelService.js +115 -0
- package/dist/Services/PlaneObjectService.d.ts +17 -0
- package/dist/Services/PlaneObjectService.js +147 -0
- package/dist/Services/PlanePathService.d.ts +15 -0
- package/dist/Services/PlanePathService.js +98 -0
- package/dist/Services/PlaneProjectionService.d.ts +20 -0
- package/dist/Services/PlaneProjectionService.js +119 -0
- package/dist/Services/PlaneRoadService.d.ts +13 -0
- package/dist/Services/PlaneRoadService.js +105 -0
- package/dist/Services/PlaneScatterService.d.ts +11 -0
- package/dist/Services/PlaneScatterService.js +48 -0
- package/dist/Services/PlaneSpaceService.d.ts +27 -0
- package/dist/Services/PlaneSpaceService.js +96 -0
- package/dist/Services/PlaneSpriteService.d.ts +29 -0
- package/dist/Services/PlaneSpriteService.js +95 -0
- package/dist/Services/PlaneTitleService.d.ts +17 -0
- package/dist/Services/PlaneTitleService.js +126 -0
- package/dist/Services/PlaneZoneService.d.ts +20 -0
- package/dist/Services/PlaneZoneService.js +121 -0
- package/dist/Services/RasterService.d.ts +10 -0
- package/dist/Services/RasterService.js +85 -0
- 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/SchemaService.d.ts +3 -0
- package/dist/Services/SchemaService.js +10 -0
- package/dist/Services/SilhouetteCritiqueService.d.ts +32 -0
- package/dist/Services/SilhouetteCritiqueService.js +155 -0
- package/dist/Services/SkyDetailService.d.ts +39 -0
- package/dist/Services/SkyDetailService.js +95 -0
- package/dist/Services/TangentCritiqueService.d.ts +23 -0
- package/dist/Services/TangentCritiqueService.js +136 -0
- package/dist/Services/TextService.d.ts +87 -0
- package/dist/Services/TextService.js +434 -0
- package/dist/Services/ThemeService.d.ts +5 -0
- package/dist/Services/ThemeService.js +18 -0
- package/dist/Services/ThumbnailCritiqueService.d.ts +30 -0
- package/dist/Services/ThumbnailCritiqueService.js +130 -0
- package/dist/Utils/BoxUtil.d.ts +4 -0
- package/dist/Utils/BoxUtil.js +8 -0
- package/dist/Utils/ColorUtil.d.ts +34 -0
- package/dist/Utils/ColorUtil.js +114 -0
- package/dist/Utils/CurveUtil.d.ts +6 -0
- package/dist/Utils/CurveUtil.js +35 -0
- package/dist/Utils/DetailUtil.d.ts +7 -0
- package/dist/Utils/DetailUtil.js +15 -0
- package/dist/Utils/FallbackUtil.d.ts +3 -0
- package/dist/Utils/FallbackUtil.js +8 -0
- package/dist/Utils/FontMetricsUtil.d.ts +7 -0
- package/dist/Utils/FontMetricsUtil.js +694 -0
- package/dist/Utils/FormatUtil.d.ts +4 -0
- package/dist/Utils/FormatUtil.js +9 -0
- package/dist/Utils/IdUtil.d.ts +4 -0
- package/dist/Utils/IdUtil.js +11 -0
- package/dist/Utils/NormalizeUtil.d.ts +4 -0
- package/dist/Utils/NormalizeUtil.js +9 -0
- package/dist/Utils/OklabUtil.d.ts +41 -0
- package/dist/Utils/OklabUtil.js +151 -0
- package/dist/Utils/PersonArmUtil.d.ts +31 -0
- package/dist/Utils/PersonArmUtil.js +132 -0
- package/dist/Utils/PersonHeadUtil.d.ts +31 -0
- package/dist/Utils/PersonHeadUtil.js +156 -0
- package/dist/Utils/PersonOutfitUtil.d.ts +64 -0
- package/dist/Utils/PersonOutfitUtil.js +254 -0
- package/dist/Utils/PersonUtil.d.ts +41 -0
- package/dist/Utils/PersonUtil.js +216 -0
- package/dist/Utils/PixelUtil.d.ts +3 -0
- package/dist/Utils/PixelUtil.js +8 -0
- package/dist/Utils/RecolorUtil.d.ts +40 -0
- package/dist/Utils/RecolorUtil.js +155 -0
- package/dist/Utils/RegistryUtil.d.ts +8 -0
- package/dist/Utils/RegistryUtil.js +19 -0
- package/dist/Utils/RequireUtil.d.ts +3 -0
- package/dist/Utils/RequireUtil.js +11 -0
- package/dist/Utils/SanitizeUtil.d.ts +25 -0
- package/dist/Utils/SanitizeUtil.js +211 -0
- package/dist/Utils/SeedUtil.d.ts +6 -0
- package/dist/Utils/SeedUtil.js +15 -0
- package/dist/Utils/ShapeUtil.d.ts +40 -0
- package/dist/Utils/ShapeUtil.js +73 -0
- package/dist/Utils/SuggestUtil.d.ts +7 -0
- package/dist/Utils/SuggestUtil.js +25 -0
- package/dist/Utils/SvgUtil.d.ts +9 -0
- package/dist/Utils/SvgUtil.js +21 -0
- package/dist/Utils/ThemeUtil.d.ts +4 -0
- package/dist/Utils/ThemeUtil.js +13 -0
- package/dist/Utils/TransportUtil.d.ts +24 -0
- package/dist/Utils/TransportUtil.js +108 -0
- package/dist/Utils/TypesettingUtil.d.ts +17 -0
- package/dist/Utils/TypesettingUtil.js +92 -0
- package/dist/cli.js +52 -96
- package/dist/index.d.ts +10 -6
- package/dist/index.js +14 -2
- package/dist/render.d.ts +10 -5
- package/dist/render.js +26 -3
- package/dist/schema.d.ts +9 -2
- package/dist/schema.js +29 -5
- package/fonts/DMSerifDisplay-Regular.ttf +0 -0
- package/fonts/OFL.txt +2 -0
- package/fonts/PatrickHand-Regular.ttf +0 -0
- package/package.json +3 -2
- package/skills/{scenec → draw-scene}/SKILL.md +17 -20
- package/skills/{scenec/recipes/carrossel.yaml → 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/{scenec/recipes/ilustracoes-produto.yaml → draw-scene/recipes/product-illustration.yaml} +2 -1
- package/skills/{scenec → draw-scene}/references/catalog.md +33 -15
- package/skills/{scenec → draw-scene}/references/dsl.md +32 -8
- package/dist/catalog.d.ts +0 -21
- package/dist/catalog.js +0 -35
- package/dist/data/europe.json +0 -1
- package/dist/drawing/assets.d.ts +0 -8
- package/dist/drawing/assets.js +0 -612
- package/dist/drawing/kits.d.ts +0 -7
- package/dist/drawing/kits.js +0 -92
- package/dist/drawing/person.d.ts +0 -18
- package/dist/drawing/person.js +0 -287
- package/dist/drawing/themes.d.ts +0 -4
- package/dist/drawing/themes.js +0 -45
- package/dist/modes/map.d.ts +0 -5
- package/dist/modes/map.js +0 -365
- package/dist/modes/plane.d.ts +0 -5
- package/dist/modes/plane.js +0 -716
- package/dist/pipeline/compile.d.ts +0 -2
- package/dist/pipeline/compile.js +0 -581
- package/dist/pipeline/custom.d.ts +0 -2
- package/dist/pipeline/custom.js +0 -120
- package/dist/pipeline/groups.d.ts +0 -2
- package/dist/pipeline/groups.js +0 -189
- package/dist/pipeline/index.js +0 -7
- package/dist/pipeline/parse.d.ts +0 -10
- package/dist/pipeline/parse.js +0 -80
- package/dist/protocols/options.js +0 -1
- package/dist/protocols/scene.d.ts +0 -299
- package/dist/protocols/scene.js +0 -118
- package/dist/protocols/theme.js +0 -1
- package/dist/render/check.d.ts +0 -6
- package/dist/render/check.js +0 -10
- package/dist/render/critic.d.ts +0 -1
- package/dist/render/critic.js +0 -235
- package/dist/render/files.d.ts +0 -2
- package/dist/render/files.js +0 -16
- package/dist/render/fonts.d.ts +0 -2
- package/dist/render/fonts.js +0 -4
- package/dist/render/png.d.ts +0 -9
- package/dist/render/png.js +0 -13
- package/dist/utils/color.d.ts +0 -5
- package/dist/utils/color.js +0 -35
- package/dist/utils/recolor.d.ts +0 -1
- package/dist/utils/recolor.js +0 -56
- package/dist/utils/sanitize.d.ts +0 -5
- package/dist/utils/sanitize.js +0 -169
- package/dist/utils/suggest.d.ts +0 -1
- package/dist/utils/suggest.js +0 -22
- package/dist/utils/svg.d.ts +0 -2
- package/dist/utils/svg.js +0 -11
- package/skills/scenec/references/fontes.md +0 -8
- /package/dist/{protocols/options.d.ts → Protocols/OptionsProtocol.d.ts} +0 -0
- /package/skills/{scenec/recipes/anuncios-variacoes.yaml → draw-scene/recipes/ad-variations.yaml} +0 -0
- /package/skills/{scenec/recipes/elearning.yaml → draw-scene/recipes/e-learning.yaml} +0 -0
- /package/skills/{scenec/recipes/reels-explicativo.yaml → draw-scene/recipes/explainer-reel.yaml} +0 -0
- /package/skills/{scenec/recipes/historia-ilustrada.yaml → draw-scene/recipes/illustrated-story.yaml} +0 -0
- /package/skills/{scenec/recipes/mapas-jornadas.yaml → draw-scene/recipes/journey-map.yaml} +0 -0
- /package/skills/{scenec/recipes/wrapped-personalizado.yaml → draw-scene/recipes/personalized-wrapped.yaml} +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { PixelUtil } from "../Utils/PixelUtil.js";
|
|
2
|
+
class TangentCritiqueService {
|
|
3
|
+
// Why: objects with fewer pixels than an icon are details or props and cannot form a prominent tangent.
|
|
4
|
+
static MIN_AREA = 30;
|
|
5
|
+
// Why: shapes whose bounding boxes are further apart than 4 px cannot touch after dilation.
|
|
6
|
+
static NEAR_DISTANCE_PX = 4;
|
|
7
|
+
// Why: a 2 px dilation radius detects edges that sit within a 2 px gap of each other.
|
|
8
|
+
static DILATION_PX = 2;
|
|
9
|
+
// Why: alpha above 128 defines the perceived solid boundary of an antialiased SVG element.
|
|
10
|
+
static OPAQUE_ALPHA = 128;
|
|
11
|
+
// Why: at least 4 meeting pixels are required to avoid single-pixel antialiasing noise.
|
|
12
|
+
static MIN_NEAR_PIXELS = 4;
|
|
13
|
+
// Why: accidental edge touches overlap by only 1 to 2 pixels.
|
|
14
|
+
static MAX_ALMOST_TOUCH_PIXELS = 2;
|
|
15
|
+
// Why: sky elements touching ground crowns with under 8% overlap create visual ambiguity.
|
|
16
|
+
static MAX_SKY_OVERLAP_SHARE = 0.08;
|
|
17
|
+
// Why: a 2 px gap to the horizon creates an awkward tangent resting right on the horizon line.
|
|
18
|
+
static HORIZON_GAP_PX = 2;
|
|
19
|
+
// Why: an object stopping 1 to 2 px short of the frame edge creates an accidental edge tangent.
|
|
20
|
+
static MAX_EDGE_GAP_PX = 2;
|
|
21
|
+
// Why: a gap under 8 px looks like an accidental touch rather than deliberate composition spacing.
|
|
22
|
+
static MIN_GAP_PX = 8;
|
|
23
|
+
static critique(raster) {
|
|
24
|
+
const candidates = raster.objects.filter(
|
|
25
|
+
(object) => object.area >= TangentCritiqueService.MIN_AREA && object.kind !== "floor"
|
|
26
|
+
);
|
|
27
|
+
return [
|
|
28
|
+
...TangentCritiqueService.tangencies(raster, candidates),
|
|
29
|
+
...candidates.flatMap((object) => TangentCritiqueService.horizonTouches(raster, object)),
|
|
30
|
+
...candidates.flatMap((object) => TangentCritiqueService.edgeTouches(raster, object))
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
static tangencies(raster, candidates) {
|
|
34
|
+
const dilated = candidates.map((object) => TangentCritiqueService.dilate(raster, object));
|
|
35
|
+
const messages = [];
|
|
36
|
+
candidates.forEach((first, firstIndex) => {
|
|
37
|
+
const firstDilated = dilated[firstIndex] ?? new Uint8Array(0);
|
|
38
|
+
for (const second of candidates.slice(firstIndex + 1)) {
|
|
39
|
+
if (TangentCritiqueService.isTangent(raster, { first, second, firstDilated })) {
|
|
40
|
+
messages.push(
|
|
41
|
+
`'${first.id}' just touches '${second.id}' (tangent); overlap them clearly or leave a gap of at least ${TangentCritiqueService.MIN_GAP_PX} px`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return messages;
|
|
47
|
+
}
|
|
48
|
+
static isTangent(raster, pair) {
|
|
49
|
+
const { first, second } = pair;
|
|
50
|
+
if (TangentCritiqueService.isIgnoredPair(first, second) || !TangentCritiqueService.boxesAreClose(first, second)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const { near, overlap } = TangentCritiqueService.countContacts(raster, pair);
|
|
54
|
+
const minArea = Math.min(first.area, second.area);
|
|
55
|
+
const isNearTouch = near >= TangentCritiqueService.MIN_NEAR_PIXELS && overlap <= TangentCritiqueService.MAX_ALMOST_TOUCH_PIXELS;
|
|
56
|
+
const hasSky = first.kind === "sky" || second.kind === "sky";
|
|
57
|
+
const isSkyTouch = hasSky && near > 0 && overlap <= TangentCritiqueService.MAX_SKY_OVERLAP_SHARE * minArea;
|
|
58
|
+
return isNearTouch || isSkyTouch;
|
|
59
|
+
}
|
|
60
|
+
static isIgnoredPair(first, second) {
|
|
61
|
+
if (first.related.includes(second.id) || second.related.includes(first.id)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
const firstPrefix = first.id.includes("_") ? first.id.slice(0, first.id.indexOf("_")) : null;
|
|
65
|
+
const secondPrefix = second.id.includes("_") ? second.id.slice(0, second.id.indexOf("_")) : null;
|
|
66
|
+
return firstPrefix !== null && firstPrefix === secondPrefix;
|
|
67
|
+
}
|
|
68
|
+
static boxesAreClose(first, second) {
|
|
69
|
+
const distance = TangentCritiqueService.NEAR_DISTANCE_PX;
|
|
70
|
+
const isApartHorizontally = first.box.right + distance < second.box.left || second.box.right + distance < first.box.left;
|
|
71
|
+
const isApartVertically = first.box.bottom + distance < second.box.top || second.box.bottom + distance < first.box.top;
|
|
72
|
+
return !isApartHorizontally && !isApartVertically;
|
|
73
|
+
}
|
|
74
|
+
static countContacts(raster, pair) {
|
|
75
|
+
const { first, second, firstDilated } = pair;
|
|
76
|
+
let near = 0;
|
|
77
|
+
let overlap = 0;
|
|
78
|
+
for (let index = 0; index < raster.pixelCount; index++) {
|
|
79
|
+
if (PixelUtil.read(second.alpha, index) <= TangentCritiqueService.OPAQUE_ALPHA) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (PixelUtil.read(first.alpha, index) > TangentCritiqueService.OPAQUE_ALPHA) {
|
|
83
|
+
overlap++;
|
|
84
|
+
} else if (PixelUtil.read(firstDilated, index) > 0) {
|
|
85
|
+
near++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return { near, overlap };
|
|
89
|
+
}
|
|
90
|
+
static dilate(raster, object) {
|
|
91
|
+
const dilated = new Uint8Array(raster.pixelCount);
|
|
92
|
+
for (let index = 0; index < raster.pixelCount; index++) {
|
|
93
|
+
if (PixelUtil.read(object.alpha, index) > TangentCritiqueService.OPAQUE_ALPHA) {
|
|
94
|
+
const center = { row: Math.trunc(index / raster.width), column: index % raster.width };
|
|
95
|
+
TangentCritiqueService.stamp(dilated, raster, center);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return dilated;
|
|
99
|
+
}
|
|
100
|
+
static stamp(dilated, raster, center) {
|
|
101
|
+
const reach = TangentCritiqueService.DILATION_PX;
|
|
102
|
+
const firstRow = Math.max(0, center.row - reach);
|
|
103
|
+
const lastRow = Math.min(raster.height - 1, center.row + reach);
|
|
104
|
+
const firstColumn = Math.max(0, center.column - reach);
|
|
105
|
+
const lastColumn = Math.min(raster.width - 1, center.column + reach);
|
|
106
|
+
for (let row = firstRow; row <= lastRow; row++) {
|
|
107
|
+
dilated.fill(1, row * raster.width + firstColumn, row * raster.width + lastColumn + 1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
static horizonTouches(raster, object) {
|
|
111
|
+
if (raster.horizonRatio == null || object.kind === "sky") {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
const horizonY = Math.round(raster.height * raster.horizonRatio);
|
|
115
|
+
const tolerancePx = TangentCritiqueService.HORIZON_GAP_PX;
|
|
116
|
+
const isTopAtHorizon = Math.abs(object.box.top - horizonY) <= tolerancePx;
|
|
117
|
+
const isBottomAtHorizon = Math.abs(object.box.bottom - horizonY) <= tolerancePx;
|
|
118
|
+
const isSpanningAcross = object.box.top < horizonY - 1 && object.box.bottom > horizonY + 1;
|
|
119
|
+
if ((isTopAtHorizon || isBottomAtHorizon) && !isSpanningAcross) {
|
|
120
|
+
return [`'${object.id}' touches the horizon; move it above or below`];
|
|
121
|
+
}
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
static edgeTouches(raster, object) {
|
|
125
|
+
const maxEdgeGap = TangentCritiqueService.MAX_EDGE_GAP_PX;
|
|
126
|
+
const gaps = [
|
|
127
|
+
["left", object.box.left],
|
|
128
|
+
["right", raster.width - 1 - object.box.right],
|
|
129
|
+
["top", object.box.top]
|
|
130
|
+
];
|
|
131
|
+
return gaps.filter(([, gap]) => gap > 0 && gap <= maxEdgeGap).map(([side]) => `'${object.id}' touches the edge (${side}); move it away from the edge or let it crop on purpose`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
TangentCritiqueService
|
|
136
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { CompilationContext, Placement, TextRect } from "../Protocols/CompilationProtocol.js";
|
|
2
|
+
import type { SceneText } from "../Protocols/SceneProtocol.js";
|
|
3
|
+
export interface TextResult {
|
|
4
|
+
svg: string;
|
|
5
|
+
rects: TextRect[];
|
|
6
|
+
}
|
|
7
|
+
export declare class TextService {
|
|
8
|
+
private static readonly TITLE_SIZE;
|
|
9
|
+
private static readonly SUBTITLE_SIZE;
|
|
10
|
+
private static readonly LABEL_SIZE;
|
|
11
|
+
private static readonly BODY_SIZE;
|
|
12
|
+
private static readonly ROLE_TO_SIZE;
|
|
13
|
+
private static readonly BOLD_WEIGHT;
|
|
14
|
+
private static readonly REGULAR_WEIGHT;
|
|
15
|
+
private static readonly ROLE_TO_WEIGHT;
|
|
16
|
+
private static readonly ROLE_TO_IS_BOLD;
|
|
17
|
+
private static readonly HORIZONTAL_TO_ALIGNMENT;
|
|
18
|
+
private static readonly ANCHOR_TO_LEFT_OF;
|
|
19
|
+
private static readonly DEFAULT_SIZE;
|
|
20
|
+
private static readonly DEFAULT_WEIGHT;
|
|
21
|
+
private static readonly MARGIN;
|
|
22
|
+
private static readonly BOTTOM_MARGIN;
|
|
23
|
+
private static readonly BASELINE_ASCENT;
|
|
24
|
+
private static readonly SUBTITLE_GAP;
|
|
25
|
+
private static readonly LINE_HEIGHT;
|
|
26
|
+
private static readonly FONT_NAME_TO_FAMILY;
|
|
27
|
+
private static readonly FONT_TO_CHAR_WIDTH;
|
|
28
|
+
private static readonly MIN_CONTRAST;
|
|
29
|
+
private static readonly SELF_COVER;
|
|
30
|
+
private static readonly OBJECT_COVER;
|
|
31
|
+
private static readonly DESCENT;
|
|
32
|
+
private static readonly RECT_DESCENT;
|
|
33
|
+
private static readonly DEFAULT_PAD;
|
|
34
|
+
private static readonly DEFAULT_RADIUS;
|
|
35
|
+
private static readonly BOX_ASCENT;
|
|
36
|
+
private static readonly BOX_TOP_PAD;
|
|
37
|
+
private static readonly BOX_BOTTOM_EXTRA;
|
|
38
|
+
private static readonly BOX_BOTTOM_PAD;
|
|
39
|
+
private static readonly TRACKING_THRESHOLD_PX;
|
|
40
|
+
private static readonly DEFAULT_TIGHT_TRACKING;
|
|
41
|
+
private static readonly TRACKING_DECIMALS;
|
|
42
|
+
private static readonly DEFAULT_STICKER_ROTATION;
|
|
43
|
+
private static readonly STICKER_STROKE_FRACTION;
|
|
44
|
+
private static readonly STICKER_MIN_STROKE;
|
|
45
|
+
private static readonly STICKER_SHADOW_DY;
|
|
46
|
+
private static readonly STICKER_SHADOW_BLUR;
|
|
47
|
+
private static readonly STICKER_SHADOW_OPACITY;
|
|
48
|
+
private static readonly PILL_HORIZONTAL_PAD;
|
|
49
|
+
private static readonly PILL_VERTICAL_PAD;
|
|
50
|
+
private static readonly PILL_SHADOW_DY;
|
|
51
|
+
private static readonly PILL_SHADOW_BLUR;
|
|
52
|
+
private static readonly PILL_SHADOW_OPACITY;
|
|
53
|
+
private static readonly HIGHLIGHT_TOP;
|
|
54
|
+
private static readonly HIGHLIGHT_BOTTOM;
|
|
55
|
+
private static readonly HIGHLIGHT_PAD;
|
|
56
|
+
private static readonly HIGHLIGHT_SKEW;
|
|
57
|
+
private static readonly HIGHLIGHT_OPACITY;
|
|
58
|
+
private static readonly UNDERLINE_Y_OFFSET;
|
|
59
|
+
private static readonly HALF_CIRCLE_DEG;
|
|
60
|
+
private static readonly DEG_TO_RAD;
|
|
61
|
+
private static readonly HALF;
|
|
62
|
+
private static readonly STYLE_IGNORES_CONTRAST;
|
|
63
|
+
private static readonly BOX_STYLE_TO_RECT;
|
|
64
|
+
static render(texts: SceneText[], context: CompilationContext, list: Placement[], backdrop: string): TextResult;
|
|
65
|
+
private static themeColor;
|
|
66
|
+
private static isRole;
|
|
67
|
+
private static layoutOf;
|
|
68
|
+
private static resolveTracking;
|
|
69
|
+
private static baseline;
|
|
70
|
+
private static rectOf;
|
|
71
|
+
private static rectForPlain;
|
|
72
|
+
private static rectForDefault;
|
|
73
|
+
private static rectForPill;
|
|
74
|
+
private static rectForSticker;
|
|
75
|
+
private static rectForHighlight;
|
|
76
|
+
private static rectForUnderline;
|
|
77
|
+
private static boxOf;
|
|
78
|
+
private static renderRectBox;
|
|
79
|
+
private static renderPillBox;
|
|
80
|
+
private static renderStickerBox;
|
|
81
|
+
private static renderHighlightBox;
|
|
82
|
+
private static renderUnderline;
|
|
83
|
+
private static underlinedPieces;
|
|
84
|
+
private static escapeText;
|
|
85
|
+
private static warnCovered;
|
|
86
|
+
private static element;
|
|
87
|
+
}
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { KitService } from "./KitService.js";
|
|
2
|
+
import { ColorUtil } from "../Utils/ColorUtil.js";
|
|
3
|
+
import { FontMetricsUtil } from "../Utils/FontMetricsUtil.js";
|
|
4
|
+
import { IdUtil } from "../Utils/IdUtil.js";
|
|
5
|
+
import { TypesettingUtil } from "../Utils/TypesettingUtil.js";
|
|
6
|
+
const HORIZONTAL_NAMES = ["left", "center", "right"];
|
|
7
|
+
class TextService {
|
|
8
|
+
static TITLE_SIZE = 0.075;
|
|
9
|
+
static SUBTITLE_SIZE = 0.036;
|
|
10
|
+
static LABEL_SIZE = 0.028;
|
|
11
|
+
static BODY_SIZE = 0.032;
|
|
12
|
+
static ROLE_TO_SIZE = {
|
|
13
|
+
title: TextService.TITLE_SIZE,
|
|
14
|
+
subtitle: TextService.SUBTITLE_SIZE,
|
|
15
|
+
label: TextService.LABEL_SIZE,
|
|
16
|
+
body: TextService.BODY_SIZE
|
|
17
|
+
};
|
|
18
|
+
static BOLD_WEIGHT = 700;
|
|
19
|
+
static REGULAR_WEIGHT = 400;
|
|
20
|
+
static ROLE_TO_WEIGHT = {
|
|
21
|
+
title: TextService.BOLD_WEIGHT,
|
|
22
|
+
body: TextService.REGULAR_WEIGHT
|
|
23
|
+
};
|
|
24
|
+
static ROLE_TO_IS_BOLD = { title: true };
|
|
25
|
+
static HORIZONTAL_TO_ALIGNMENT = {
|
|
26
|
+
left: { anchor: "start", startX: (_width, margin) => margin, leftOf: (anchorX) => anchorX },
|
|
27
|
+
center: {
|
|
28
|
+
anchor: "middle",
|
|
29
|
+
startX: (width) => width / 2,
|
|
30
|
+
leftOf: (anchorX, textWidth) => anchorX - textWidth / 2
|
|
31
|
+
},
|
|
32
|
+
right: {
|
|
33
|
+
anchor: "end",
|
|
34
|
+
startX: (width, margin) => width - margin,
|
|
35
|
+
leftOf: (anchorX, textWidth) => anchorX - textWidth
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
static ANCHOR_TO_LEFT_OF = {
|
|
39
|
+
start: (anchorX) => anchorX,
|
|
40
|
+
middle: (anchorX, textWidth) => anchorX - textWidth * TextService.HALF,
|
|
41
|
+
end: (anchorX, textWidth) => anchorX - textWidth
|
|
42
|
+
};
|
|
43
|
+
static DEFAULT_SIZE = 0.04;
|
|
44
|
+
static DEFAULT_WEIGHT = 500;
|
|
45
|
+
static MARGIN = 0.06;
|
|
46
|
+
static BOTTOM_MARGIN = 0.7;
|
|
47
|
+
static BASELINE_ASCENT = 0.9;
|
|
48
|
+
static SUBTITLE_GAP = 0.8;
|
|
49
|
+
static LINE_HEIGHT = 1.2;
|
|
50
|
+
static FONT_NAME_TO_FAMILY = {
|
|
51
|
+
sans: "Poppins",
|
|
52
|
+
serif: "DM Serif Display",
|
|
53
|
+
hand: "Patrick Hand"
|
|
54
|
+
};
|
|
55
|
+
static FONT_TO_CHAR_WIDTH = {
|
|
56
|
+
sans: { regular: 0.565, bold: 0.6 },
|
|
57
|
+
serif: { regular: 0.49, bold: 0.53 },
|
|
58
|
+
hand: { regular: 0.42, bold: 0.45 }
|
|
59
|
+
};
|
|
60
|
+
static MIN_CONTRAST = 4.5;
|
|
61
|
+
static SELF_COVER = 0.06;
|
|
62
|
+
static OBJECT_COVER = 0.12;
|
|
63
|
+
static DESCENT = 0.25;
|
|
64
|
+
static RECT_DESCENT = 0.75;
|
|
65
|
+
static DEFAULT_PAD = 0.45;
|
|
66
|
+
static DEFAULT_RADIUS = 0.35;
|
|
67
|
+
static BOX_ASCENT = 1.05;
|
|
68
|
+
static BOX_TOP_PAD = 0.3;
|
|
69
|
+
static BOX_BOTTOM_EXTRA = 0.45;
|
|
70
|
+
static BOX_BOTTOM_PAD = 0.6;
|
|
71
|
+
static TRACKING_THRESHOLD_PX = 36;
|
|
72
|
+
static DEFAULT_TIGHT_TRACKING = -0.015;
|
|
73
|
+
static TRACKING_DECIMALS = 3;
|
|
74
|
+
static DEFAULT_STICKER_ROTATION = -1.5;
|
|
75
|
+
static STICKER_STROKE_FRACTION = 0.12;
|
|
76
|
+
static STICKER_MIN_STROKE = 3;
|
|
77
|
+
static STICKER_SHADOW_DY = 0.1;
|
|
78
|
+
static STICKER_SHADOW_BLUR = 0.12;
|
|
79
|
+
static STICKER_SHADOW_OPACITY = 0.25;
|
|
80
|
+
static PILL_HORIZONTAL_PAD = 0.6;
|
|
81
|
+
static PILL_VERTICAL_PAD = 0.35;
|
|
82
|
+
static PILL_SHADOW_DY = 0.08;
|
|
83
|
+
static PILL_SHADOW_BLUR = 0.12;
|
|
84
|
+
static PILL_SHADOW_OPACITY = 0.22;
|
|
85
|
+
static HIGHLIGHT_TOP = 0.78;
|
|
86
|
+
static HIGHLIGHT_BOTTOM = 0.15;
|
|
87
|
+
static HIGHLIGHT_PAD = 0.2;
|
|
88
|
+
static HIGHLIGHT_SKEW = 0.08;
|
|
89
|
+
static HIGHLIGHT_OPACITY = 0.38;
|
|
90
|
+
static UNDERLINE_Y_OFFSET = 0.16;
|
|
91
|
+
static HALF_CIRCLE_DEG = 180;
|
|
92
|
+
static DEG_TO_RAD = Math.PI / TextService.HALF_CIRCLE_DEG;
|
|
93
|
+
static HALF = 0.5;
|
|
94
|
+
static STYLE_IGNORES_CONTRAST = /* @__PURE__ */ new Set(["highlight", "underline"]);
|
|
95
|
+
static BOX_STYLE_TO_RECT = {
|
|
96
|
+
rect: (layout) => TextService.rectForDefault(layout),
|
|
97
|
+
pill: (layout) => TextService.rectForPill(layout),
|
|
98
|
+
sticker: (layout) => TextService.rectForSticker(layout),
|
|
99
|
+
highlight: (layout) => TextService.rectForHighlight(layout),
|
|
100
|
+
underline: (layout) => TextService.rectForUnderline(layout)
|
|
101
|
+
};
|
|
102
|
+
static render(texts, context, list, backdrop) {
|
|
103
|
+
const rects = [];
|
|
104
|
+
let svg = "";
|
|
105
|
+
for (let index = 0; index < texts.length; index++) {
|
|
106
|
+
const text = texts[index];
|
|
107
|
+
if (!text) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const layout = TextService.layoutOf(text, texts, context, index);
|
|
111
|
+
rects.push(TextService.rectOf(layout));
|
|
112
|
+
svg += TextService.boxOf(layout, context, backdrop) + TextService.element(layout);
|
|
113
|
+
TextService.warnCovered(layout, list, context);
|
|
114
|
+
}
|
|
115
|
+
return { svg, rects };
|
|
116
|
+
}
|
|
117
|
+
static themeColor(context, name) {
|
|
118
|
+
const value = context.theme[name];
|
|
119
|
+
return typeof value === "string" ? value : name;
|
|
120
|
+
}
|
|
121
|
+
static isRole(text, role) {
|
|
122
|
+
return (text.role ?? "title") === role;
|
|
123
|
+
}
|
|
124
|
+
static layoutOf(text, texts, context, index) {
|
|
125
|
+
const { width, height, theme } = context;
|
|
126
|
+
const role = text.role ?? "title";
|
|
127
|
+
const roleSize = IdUtil.lookup(TextService.ROLE_TO_SIZE, role) ?? TextService.DEFAULT_SIZE;
|
|
128
|
+
const fontSize = text.size ? text.size * height : roleSize * height;
|
|
129
|
+
const [vertical = "top", horizontalText] = (text.at ?? "top-left").split("-");
|
|
130
|
+
const horizontal = IdUtil.isOneOf(HORIZONTAL_NAMES, horizontalText) ? horizontalText : "left";
|
|
131
|
+
const alignment = TextService.HORIZONTAL_TO_ALIGNMENT[horizontal];
|
|
132
|
+
const margin = width * TextService.MARGIN;
|
|
133
|
+
const defaultX = alignment.startX(width, margin);
|
|
134
|
+
const anchorX = text.x != null ? text.x * width : defaultX;
|
|
135
|
+
const kit = context.canvas.kit ? IdUtil.lookup(KitService.KIT_ID_TO_KIT, context.canvas.kit) : void 0;
|
|
136
|
+
const fontName = text.font ?? context.canvas.font ?? kit?.font ?? "sans";
|
|
137
|
+
const fontFamily = TextService.FONT_NAME_TO_FAMILY[fontName];
|
|
138
|
+
const tracking = TextService.resolveTracking(text.tracking, fontSize);
|
|
139
|
+
const lines = TypesettingUtil.splitLines(String(text.content), {
|
|
140
|
+
wrap: text.wrap,
|
|
141
|
+
hasBalance: text.balance ?? (role === "title" && text.wrap != null)
|
|
142
|
+
});
|
|
143
|
+
const lineHeight = fontSize * TextService.LINE_HEIGHT;
|
|
144
|
+
const weight = text.weight ?? IdUtil.lookup(TextService.ROLE_TO_WEIGHT, role) ?? TextService.DEFAULT_WEIGHT;
|
|
145
|
+
const isBold = weight >= TextService.BOLD_WEIGHT || IdUtil.lookup(TextService.ROLE_TO_IS_BOLD, role) === true;
|
|
146
|
+
const charWidths = TextService.FONT_TO_CHAR_WIDTH[fontName];
|
|
147
|
+
const charWidth = isBold ? charWidths.bold : charWidths.regular;
|
|
148
|
+
const estimatedWidth = Math.max(...lines.map((line) => line.length)) * fontSize * (charWidth + tracking);
|
|
149
|
+
const metrics = { isBottom: vertical === "bottom", margin, fontSize, lineHeight, lineCount: lines.length };
|
|
150
|
+
const boxFill = text.box ? TextService.themeColor(context, text.box) : void 0;
|
|
151
|
+
return {
|
|
152
|
+
role,
|
|
153
|
+
fontSize,
|
|
154
|
+
anchor: alignment.anchor,
|
|
155
|
+
x: anchorX,
|
|
156
|
+
lines,
|
|
157
|
+
lineHeight,
|
|
158
|
+
weight,
|
|
159
|
+
estimatedWidth,
|
|
160
|
+
left: alignment.leftOf(anchorX, estimatedWidth),
|
|
161
|
+
y: TextService.baseline(text, texts, metrics, context),
|
|
162
|
+
color: text.color ? TextService.themeColor(context, text.color) : theme.text,
|
|
163
|
+
blockHeight: fontSize + (lines.length - 1) * lineHeight,
|
|
164
|
+
fontFamily,
|
|
165
|
+
fontName,
|
|
166
|
+
isBold,
|
|
167
|
+
tracking,
|
|
168
|
+
charWidth,
|
|
169
|
+
boxStyle: text.box_style ?? (text.box ? "rect" : void 0),
|
|
170
|
+
rotation: text.rotation,
|
|
171
|
+
emphasis: text.emphasis,
|
|
172
|
+
hasBox: Boolean(text.box ?? text.box_style),
|
|
173
|
+
boxFill,
|
|
174
|
+
pad: text.pad,
|
|
175
|
+
radius: text.radius,
|
|
176
|
+
index
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
static resolveTracking(tracking, fontSize = 0) {
|
|
180
|
+
if (tracking != null) {
|
|
181
|
+
return tracking;
|
|
182
|
+
}
|
|
183
|
+
return fontSize >= TextService.TRACKING_THRESHOLD_PX ? TextService.DEFAULT_TIGHT_TRACKING : 0;
|
|
184
|
+
}
|
|
185
|
+
static baseline(text, texts, metrics, context) {
|
|
186
|
+
const { isBottom, margin, fontSize, lineHeight, lineCount } = metrics;
|
|
187
|
+
if (text.y != null) {
|
|
188
|
+
return text.y * context.height;
|
|
189
|
+
}
|
|
190
|
+
const bottomBase = context.height - margin * TextService.BOTTOM_MARGIN - (lineCount - 1) * lineHeight;
|
|
191
|
+
const base = isBottom ? bottomBase : margin + fontSize * TextService.BASELINE_ASCENT;
|
|
192
|
+
const hasTitleAbove = TextService.isRole(text, "subtitle") && texts.some((other) => TextService.isRole(other, "title") && other.at === text.at && other.y == null);
|
|
193
|
+
const shift = context.height * TextService.TITLE_SIZE * TextService.BASELINE_ASCENT + fontSize * TextService.SUBTITLE_GAP;
|
|
194
|
+
return hasTitleAbove ? base + shift : base;
|
|
195
|
+
}
|
|
196
|
+
static rectOf(layout) {
|
|
197
|
+
if (layout.boxStyle) {
|
|
198
|
+
return TextService.BOX_STYLE_TO_RECT[layout.boxStyle](layout);
|
|
199
|
+
}
|
|
200
|
+
return TextService.rectForPlain(layout);
|
|
201
|
+
}
|
|
202
|
+
static rectForPlain(layout) {
|
|
203
|
+
const { left, y, fontSize, estimatedWidth, blockHeight } = layout;
|
|
204
|
+
return {
|
|
205
|
+
x0: left,
|
|
206
|
+
y0: y - fontSize,
|
|
207
|
+
x1: left + estimatedWidth,
|
|
208
|
+
y1: y + blockHeight - fontSize * TextService.RECT_DESCENT,
|
|
209
|
+
hasBox: false
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
static rectForDefault(layout) {
|
|
213
|
+
const { left, y, fontSize, estimatedWidth, blockHeight, pad } = layout;
|
|
214
|
+
const padding = (pad ?? TextService.DEFAULT_PAD) * fontSize;
|
|
215
|
+
return {
|
|
216
|
+
x0: left - padding,
|
|
217
|
+
y0: y - fontSize * TextService.BOX_ASCENT - padding * TextService.BOX_TOP_PAD,
|
|
218
|
+
x1: left + estimatedWidth + padding,
|
|
219
|
+
y1: y + blockHeight + fontSize * TextService.BOX_BOTTOM_EXTRA + padding * TextService.BOX_BOTTOM_PAD,
|
|
220
|
+
hasBox: true
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
static rectForPill(layout) {
|
|
224
|
+
const { left, y, fontSize, estimatedWidth, blockHeight, pad } = layout;
|
|
225
|
+
const padding = (pad ?? TextService.PILL_HORIZONTAL_PAD) * fontSize;
|
|
226
|
+
return {
|
|
227
|
+
x0: left - padding,
|
|
228
|
+
y0: y - fontSize * TextService.BOX_ASCENT,
|
|
229
|
+
x1: left + estimatedWidth + padding,
|
|
230
|
+
y1: y + blockHeight + fontSize * TextService.BOX_BOTTOM_EXTRA,
|
|
231
|
+
hasBox: true
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
static rectForSticker(layout) {
|
|
235
|
+
const { left, y, fontSize, estimatedWidth, blockHeight, pad, rotation } = layout;
|
|
236
|
+
const padding = (pad ?? TextService.DEFAULT_PAD) * fontSize;
|
|
237
|
+
const angle = (rotation ?? TextService.DEFAULT_STICKER_ROTATION) * TextService.DEG_TO_RAD;
|
|
238
|
+
const rawWidth = estimatedWidth + padding * 2;
|
|
239
|
+
const rawHeight = blockHeight + fontSize * (TextService.BOX_ASCENT + TextService.BOX_BOTTOM_EXTRA);
|
|
240
|
+
const rotWidth = rawWidth * Math.cos(angle) + rawHeight * Math.abs(Math.sin(angle));
|
|
241
|
+
const rotHeight = rawWidth * Math.abs(Math.sin(angle)) + rawHeight * Math.cos(angle);
|
|
242
|
+
const centerX = left + estimatedWidth * TextService.HALF;
|
|
243
|
+
const centerY = y + (blockHeight - fontSize) * TextService.HALF;
|
|
244
|
+
return {
|
|
245
|
+
x0: centerX - rotWidth * TextService.HALF,
|
|
246
|
+
y0: centerY - rotHeight * TextService.HALF,
|
|
247
|
+
x1: centerX + rotWidth * TextService.HALF,
|
|
248
|
+
y1: centerY + rotHeight * TextService.HALF,
|
|
249
|
+
hasBox: true
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
static rectForHighlight(layout) {
|
|
253
|
+
const { left, y, fontSize, estimatedWidth, blockHeight } = layout;
|
|
254
|
+
const padding = fontSize * TextService.HIGHLIGHT_PAD;
|
|
255
|
+
return {
|
|
256
|
+
x0: left - padding,
|
|
257
|
+
y0: y - fontSize * TextService.HIGHLIGHT_TOP,
|
|
258
|
+
x1: left + estimatedWidth + padding,
|
|
259
|
+
y1: y + blockHeight + fontSize * TextService.HIGHLIGHT_BOTTOM,
|
|
260
|
+
hasBox: true
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
static rectForUnderline(layout) {
|
|
264
|
+
const { left, y, fontSize, estimatedWidth, blockHeight } = layout;
|
|
265
|
+
return {
|
|
266
|
+
x0: left,
|
|
267
|
+
y0: y - fontSize,
|
|
268
|
+
x1: left + estimatedWidth,
|
|
269
|
+
y1: y + blockHeight + fontSize * TextService.UNDERLINE_Y_OFFSET,
|
|
270
|
+
hasBox: true
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
static boxOf(layout, context, backdrop) {
|
|
274
|
+
const { color, lines, boxStyle, boxFill } = layout;
|
|
275
|
+
const effectiveFill = boxFill ?? backdrop;
|
|
276
|
+
const ratio = ColorUtil.contrast(color, effectiveFill);
|
|
277
|
+
const isContrastIgnored = boxStyle ? TextService.STYLE_IGNORES_CONTRAST.has(boxStyle) : false;
|
|
278
|
+
if (ratio < TextService.MIN_CONTRAST && !isContrastIgnored) {
|
|
279
|
+
context.warnings.push(
|
|
280
|
+
`text "${lines[0]}" has contrast ${ratio.toFixed(1)}:1 (min. 4.5); change 'color' or use 'box'`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
if (!boxStyle) {
|
|
284
|
+
return "";
|
|
285
|
+
}
|
|
286
|
+
const boxStyleToRenderer = {
|
|
287
|
+
rect: () => TextService.renderRectBox(layout, effectiveFill),
|
|
288
|
+
pill: () => TextService.renderPillBox(layout, context),
|
|
289
|
+
sticker: () => TextService.renderStickerBox(layout, context),
|
|
290
|
+
highlight: () => TextService.renderHighlightBox(layout, context),
|
|
291
|
+
underline: () => TextService.renderUnderline(layout, context)
|
|
292
|
+
};
|
|
293
|
+
return boxStyleToRenderer[boxStyle]();
|
|
294
|
+
}
|
|
295
|
+
static renderRectBox(layout, fill) {
|
|
296
|
+
const { fontSize, left, estimatedWidth, blockHeight, y, pad, radius } = layout;
|
|
297
|
+
const padding = (pad ?? TextService.DEFAULT_PAD) * fontSize;
|
|
298
|
+
const boxY = y - fontSize * TextService.BOX_ASCENT - padding * TextService.BOX_TOP_PAD;
|
|
299
|
+
const boxHeight = blockHeight + fontSize * TextService.BOX_BOTTOM_EXTRA + padding * TextService.BOX_BOTTOM_PAD;
|
|
300
|
+
const cornerRadius = (radius ?? TextService.DEFAULT_RADIUS) * fontSize;
|
|
301
|
+
return `<rect x="${(left - padding).toFixed(1)}" y="${boxY.toFixed(1)}" width="${(estimatedWidth + padding * 2).toFixed(1)}" height="${boxHeight.toFixed(1)}" rx="${cornerRadius.toFixed(1)}" fill="${fill}"/>`;
|
|
302
|
+
}
|
|
303
|
+
static renderPillBox(layout, context) {
|
|
304
|
+
const { fontSize, left, estimatedWidth, blockHeight, y, boxFill, pad, index } = layout;
|
|
305
|
+
const fill = boxFill ?? context.theme.accent;
|
|
306
|
+
const padding = (pad ?? TextService.PILL_HORIZONTAL_PAD) * fontSize;
|
|
307
|
+
const boxY = y - fontSize * TextService.BOX_ASCENT;
|
|
308
|
+
const boxHeight = blockHeight + fontSize * (TextService.BOX_ASCENT + TextService.PILL_VERTICAL_PAD);
|
|
309
|
+
const boxWidth = estimatedWidth + padding * 2;
|
|
310
|
+
const radius = boxHeight * TextService.HALF;
|
|
311
|
+
const shadowDy = (fontSize * TextService.PILL_SHADOW_DY).toFixed(1);
|
|
312
|
+
const shadowBlur = (fontSize * TextService.PILL_SHADOW_BLUR).toFixed(1);
|
|
313
|
+
const filterId = `pill_sh_${index}`;
|
|
314
|
+
return `<defs><filter id="${filterId}" x="-20%" y="-20%" width="140%" height="150%"><feDropShadow dx="0" dy="${shadowDy}" stdDeviation="${shadowBlur}" flood-color="#000000" flood-opacity="${TextService.PILL_SHADOW_OPACITY}"/></filter></defs><rect x="${(left - padding).toFixed(1)}" y="${boxY.toFixed(1)}" width="${boxWidth.toFixed(1)}" height="${boxHeight.toFixed(1)}" rx="${radius.toFixed(1)}" fill="${fill}" filter="url(#${filterId})"/>`;
|
|
315
|
+
}
|
|
316
|
+
static renderStickerBox(layout, context) {
|
|
317
|
+
const { fontSize, left, estimatedWidth, blockHeight, y, boxFill, pad, radius, rotation, index } = layout;
|
|
318
|
+
const fill = boxFill ?? context.theme.paper;
|
|
319
|
+
const padding = (pad ?? TextService.DEFAULT_PAD) * fontSize;
|
|
320
|
+
const boxY = y - fontSize * TextService.BOX_ASCENT;
|
|
321
|
+
const boxHeight = blockHeight + fontSize * (TextService.BOX_ASCENT + TextService.BOX_BOTTOM_EXTRA);
|
|
322
|
+
const boxWidth = estimatedWidth + padding * 2;
|
|
323
|
+
const cornerRadius = (radius ?? TextService.DEFAULT_RADIUS) * fontSize;
|
|
324
|
+
const strokeWidth = Math.max(TextService.STICKER_MIN_STROKE, fontSize * TextService.STICKER_STROKE_FRACTION);
|
|
325
|
+
const shadowDy = (fontSize * TextService.STICKER_SHADOW_DY).toFixed(1);
|
|
326
|
+
const shadowBlur = (fontSize * TextService.STICKER_SHADOW_BLUR).toFixed(1);
|
|
327
|
+
const filterId = `stk_sh_${index}`;
|
|
328
|
+
const angle = rotation ?? TextService.DEFAULT_STICKER_ROTATION;
|
|
329
|
+
const centerX = left + estimatedWidth * TextService.HALF;
|
|
330
|
+
const centerY = boxY + boxHeight * TextService.HALF;
|
|
331
|
+
return `<defs><filter id="${filterId}" x="-25%" y="-25%" width="150%" height="160%"><feDropShadow dx="1" dy="${shadowDy}" stdDeviation="${shadowBlur}" flood-color="#000000" flood-opacity="${TextService.STICKER_SHADOW_OPACITY}"/></filter></defs><g transform="rotate(${angle.toFixed(1)}, ${centerX.toFixed(1)}, ${centerY.toFixed(1)})"><rect x="${(left - padding).toFixed(1)}" y="${boxY.toFixed(1)}" width="${boxWidth.toFixed(1)}" height="${boxHeight.toFixed(1)}" rx="${cornerRadius.toFixed(1)}" fill="${fill}" stroke="#FFFFFF" stroke-width="${strokeWidth.toFixed(1)}" stroke-linejoin="round" filter="url(#${filterId})"/>`;
|
|
332
|
+
}
|
|
333
|
+
static renderHighlightBox(layout, context) {
|
|
334
|
+
const { fontSize, x, y, lines, lineHeight, anchor, fontName, isBold, tracking, boxFill } = layout;
|
|
335
|
+
const fill = boxFill ?? context.theme.accent;
|
|
336
|
+
const pad = fontSize * TextService.HIGHLIGHT_PAD;
|
|
337
|
+
const skew = fontSize * TextService.HIGHLIGHT_SKEW;
|
|
338
|
+
let svg = "";
|
|
339
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
340
|
+
const line = lines[lineIndex];
|
|
341
|
+
if (!line) {
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
const lineY = y + lineIndex * lineHeight;
|
|
345
|
+
const lineWidth = fontSize * (FontMetricsUtil.lineEm(line, fontName, isBold) + tracking * line.length);
|
|
346
|
+
const lineLeft = TextService.ANCHOR_TO_LEFT_OF[anchor](x, lineWidth);
|
|
347
|
+
const top = lineY - fontSize * TextService.HIGHLIGHT_TOP;
|
|
348
|
+
const bottom = lineY + fontSize * TextService.HIGHLIGHT_BOTTOM;
|
|
349
|
+
const points = [
|
|
350
|
+
`${(lineLeft - pad + skew).toFixed(1)},${top.toFixed(1)}`,
|
|
351
|
+
`${(lineLeft + lineWidth + pad + skew).toFixed(1)},${top.toFixed(1)}`,
|
|
352
|
+
`${(lineLeft + lineWidth + pad - skew).toFixed(1)},${bottom.toFixed(1)}`,
|
|
353
|
+
`${(lineLeft - pad - skew).toFixed(1)},${bottom.toFixed(1)}`
|
|
354
|
+
].join(" ");
|
|
355
|
+
svg += `<polygon points="${points}" fill="${fill}" fill-opacity="${TextService.HIGHLIGHT_OPACITY}"/>`;
|
|
356
|
+
}
|
|
357
|
+
return svg;
|
|
358
|
+
}
|
|
359
|
+
static renderUnderline(layout, context) {
|
|
360
|
+
const { fontSize, x, y, lines, lineHeight, anchor, weight, fontFamily, tracking, boxFill, emphasis } = layout;
|
|
361
|
+
const stroke = boxFill ?? context.theme.accent;
|
|
362
|
+
const spans = lines.map((line, lineIndex) => {
|
|
363
|
+
const dy = lineIndex === 0 ? "" : ` dy="${lineHeight.toFixed(1)}"`;
|
|
364
|
+
const pieces = TextService.underlinedPieces(line, emphasis, stroke);
|
|
365
|
+
return `<tspan x="${x.toFixed(1)}"${dy}>${pieces}</tspan>`;
|
|
366
|
+
});
|
|
367
|
+
const trackingAttr = tracking !== 0 ? ` letter-spacing="${tracking.toFixed(TextService.TRACKING_DECIMALS)}em"` : "";
|
|
368
|
+
return `<text x="${x.toFixed(1)}" y="${y.toFixed(1)}" font-family="${fontFamily}" font-size="${fontSize.toFixed(1)}" font-weight="${weight}" fill="${stroke}" fill-opacity="0" text-anchor="${anchor}"${trackingAttr}>${spans.join("")}</text>`;
|
|
369
|
+
}
|
|
370
|
+
static underlinedPieces(line, emphasis, stroke) {
|
|
371
|
+
const ranges = TypesettingUtil.emphasisRanges(line, emphasis);
|
|
372
|
+
const merged = [];
|
|
373
|
+
for (const range of ranges) {
|
|
374
|
+
const end = range.start + range.length;
|
|
375
|
+
const last = merged.at(-1);
|
|
376
|
+
if (last && range.start <= last.end) {
|
|
377
|
+
last.end = Math.max(last.end, end);
|
|
378
|
+
} else {
|
|
379
|
+
merged.push({ start: range.start, end });
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
let cursor = 0;
|
|
383
|
+
let html = "";
|
|
384
|
+
for (const { start, end } of merged) {
|
|
385
|
+
html += TextService.escapeText(line.slice(cursor, start));
|
|
386
|
+
html += `<tspan fill="${stroke}" fill-opacity="1" text-decoration="underline">${TextService.escapeText(line.slice(start, end))}</tspan>`;
|
|
387
|
+
cursor = end;
|
|
388
|
+
}
|
|
389
|
+
return html + TextService.escapeText(line.slice(cursor));
|
|
390
|
+
}
|
|
391
|
+
static escapeText(value) {
|
|
392
|
+
return value.replace(/&/g, "&").replace(/</g, "<");
|
|
393
|
+
}
|
|
394
|
+
static warnCovered(layout, list, context) {
|
|
395
|
+
const { left, estimatedWidth, y, blockHeight, fontSize, lines } = layout;
|
|
396
|
+
for (const placement of list) {
|
|
397
|
+
if (placement.isBackdrop) {
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
const overlapX = Math.max(
|
|
401
|
+
0,
|
|
402
|
+
Math.min(placement.boxRight, left + estimatedWidth) - Math.max(placement.boxLeft, left)
|
|
403
|
+
);
|
|
404
|
+
const textBottom = y + blockHeight - fontSize + fontSize * TextService.DESCENT;
|
|
405
|
+
const overlapY = Math.max(
|
|
406
|
+
0,
|
|
407
|
+
Math.min(placement.boxBottom, textBottom) - Math.max(placement.boxTop, y - fontSize)
|
|
408
|
+
);
|
|
409
|
+
const covered = overlapX * overlapY;
|
|
410
|
+
const selfLimit = TextService.SELF_COVER * estimatedWidth * blockHeight;
|
|
411
|
+
const objectLimit = TextService.OBJECT_COVER * placement.width * placement.height;
|
|
412
|
+
if (covered > selfLimit || covered > objectLimit) {
|
|
413
|
+
context.warnings.push(`text "${lines[0]}" covers '${placement.id}'`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
static element(layout) {
|
|
418
|
+
const { x, y, fontSize, weight, color, anchor, lines, lineHeight, fontFamily, tracking, boxStyle } = layout;
|
|
419
|
+
const escape = (value) => value.replace(/&/g, "&").replace(/</g, "<");
|
|
420
|
+
const spans = lines.map((line, lineIndex) => {
|
|
421
|
+
const dy = lineIndex === 0 ? "" : ` dy="${lineHeight.toFixed(1)}"`;
|
|
422
|
+
return `<tspan x="${x.toFixed(1)}"${dy}>${escape(line)}</tspan>`;
|
|
423
|
+
});
|
|
424
|
+
const trackingAttr = tracking !== 0 ? ` letter-spacing="${tracking.toFixed(TextService.TRACKING_DECIMALS)}em"` : "";
|
|
425
|
+
const textTag = `<text x="${x.toFixed(1)}" y="${y.toFixed(1)}" font-family="${fontFamily}" font-size="${fontSize.toFixed(1)}" font-weight="${weight}" fill="${color}" text-anchor="${anchor}"${trackingAttr}>${spans.join("")}</text>`;
|
|
426
|
+
if (boxStyle === "sticker") {
|
|
427
|
+
return `${textTag}</g>`;
|
|
428
|
+
}
|
|
429
|
+
return textTag;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
export {
|
|
433
|
+
TextService
|
|
434
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FlatAutumnTheme } from "../Resources/Themes/FlatAutumnTheme.js";
|
|
2
|
+
import { FlatCoolTheme } from "../Resources/Themes/FlatCoolTheme.js";
|
|
3
|
+
import { NightTheme } from "../Resources/Themes/NightTheme.js";
|
|
4
|
+
import { WarmCafeTheme } from "../Resources/Themes/WarmCafeTheme.js";
|
|
5
|
+
import { BeachTheme } from "../Resources/Themes/BeachTheme.js";
|
|
6
|
+
import { RegistryUtil } from "../Utils/RegistryUtil.js";
|
|
7
|
+
class ThemeService {
|
|
8
|
+
static THEME_ID_TO_THEME = RegistryUtil.indexValues(
|
|
9
|
+
[new FlatAutumnTheme(), new FlatCoolTheme(), new NightTheme(), new WarmCafeTheme(), new BeachTheme()],
|
|
10
|
+
(theme) => theme.palette
|
|
11
|
+
);
|
|
12
|
+
static resolve(id) {
|
|
13
|
+
return ThemeService.THEME_ID_TO_THEME[id];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
ThemeService
|
|
18
|
+
};
|