castle-web-cli 0.4.84 → 0.4.85

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.
Files changed (73) hide show
  1. package/dist/ide.js +35 -13
  2. package/dist/shell/assets/{index-BOgm5T3W.js → index-BJLaUTJE.js} +21 -21
  3. package/dist/shell/index.html +1 -1
  4. package/kits/physics-2d/.prettierrc +8 -0
  5. package/kits/physics-2d/CLAUDE.md +329 -0
  6. package/kits/physics-2d/behaviors/Camera.jsx +43 -0
  7. package/kits/physics-2d/behaviors/Collider.jsx +199 -0
  8. package/kits/physics-2d/behaviors/Goal.jsx +29 -0
  9. package/kits/physics-2d/behaviors/Layout.jsx +53 -0
  10. package/kits/physics-2d/behaviors/Sprite.jsx +352 -0
  11. package/kits/physics-2d/behaviors/tint.js +47 -0
  12. package/kits/physics-2d/blueprints/ball.scene +14 -0
  13. package/kits/physics-2d/blueprints/block.scene +12 -0
  14. package/kits/physics-2d/blueprints/cauldron.scene +18 -0
  15. package/kits/physics-2d/blueprints/crate.scene +14 -0
  16. package/kits/physics-2d/blueprints/goal.scene +12 -0
  17. package/kits/physics-2d/castle.json +13 -0
  18. package/kits/physics-2d/docs/pxart-format.md +377 -0
  19. package/kits/physics-2d/drawings/block.pxart +25 -0
  20. package/kits/physics-2d/drawings/cauldron.pxart +113 -0
  21. package/kits/physics-2d/editors/BlueprintLibrary.jsx +247 -0
  22. package/kits/physics-2d/editors/ErrorBoundary.jsx +59 -0
  23. package/kits/physics-2d/editors/PlayOnly.jsx +31 -0
  24. package/kits/physics-2d/editors/PxArtEditor.jsx +954 -0
  25. package/kits/physics-2d/editors/SceneEditor.jsx +1681 -0
  26. package/kits/physics-2d/editors/SelectionOverlay.jsx +909 -0
  27. package/kits/physics-2d/editors/SingleEditor.jsx +122 -0
  28. package/kits/physics-2d/editors/behaviorRegistry.js +30 -0
  29. package/kits/physics-2d/editors/editorHistory.js +157 -0
  30. package/kits/physics-2d/editors/inspectorSheet.js +13 -0
  31. package/kits/physics-2d/editors/pixelCanvas.js +11 -0
  32. package/kits/physics-2d/editors/pixelEditorChrome.jsx +74 -0
  33. package/kits/physics-2d/editors/pixelGeometry.js +140 -0
  34. package/kits/physics-2d/editors/pixelInspector.jsx +633 -0
  35. package/kits/physics-2d/editors/pxArtEditorModel.js +732 -0
  36. package/kits/physics-2d/editors/pxArtPlayback.js +92 -0
  37. package/kits/physics-2d/editors/pxArtTimeline.jsx +752 -0
  38. package/kits/physics-2d/editors/pxArtTimeline.module.css +506 -0
  39. package/kits/physics-2d/editors/pxArtTools.js +232 -0
  40. package/kits/physics-2d/editors/useArtboardFit.js +102 -0
  41. package/kits/physics-2d/engine/ScenePlayer.jsx +196 -0
  42. package/kits/physics-2d/engine/SceneUI.jsx +59 -0
  43. package/kits/physics-2d/engine/assets.js +15 -0
  44. package/kits/physics-2d/engine/autoInspector.jsx +70 -0
  45. package/kits/physics-2d/engine/blueprint.js +521 -0
  46. package/kits/physics-2d/engine/collider.js +196 -0
  47. package/kits/physics-2d/engine/files.js +117 -0
  48. package/kits/physics-2d/engine/liveReload.js +88 -0
  49. package/kits/physics-2d/engine/pxart.js +1032 -0
  50. package/kits/physics-2d/engine/pxartSmooth.js +222 -0
  51. package/kits/physics-2d/engine/scene.js +686 -0
  52. package/kits/physics-2d/engine/spriteGeometry.js +32 -0
  53. package/kits/physics-2d/engine/ui.jsx +688 -0
  54. package/kits/physics-2d/engine/ui.module.css +2287 -0
  55. package/kits/physics-2d/eslint.config.js +71 -0
  56. package/kits/physics-2d/index.html +24 -0
  57. package/kits/physics-2d/main.jsx +24 -0
  58. package/kits/physics-2d/package-lock.json +2706 -0
  59. package/kits/physics-2d/package.json +42 -0
  60. package/kits/physics-2d/physics/PhysicsSystem.js +290 -0
  61. package/kits/physics-2d/physics/behaviors/AnalogStick.jsx +101 -0
  62. package/kits/physics-2d/physics/behaviors/Draggable.jsx +79 -0
  63. package/kits/physics-2d/physics/behaviors/RigidBody.jsx +55 -0
  64. package/kits/physics-2d/physics/behaviors/Slingshot.jsx +118 -0
  65. package/kits/physics-2d/physics/controls.js +79 -0
  66. package/kits/physics-2d/physics/index.js +26 -0
  67. package/kits/physics-2d/physics/matterBridge.js +126 -0
  68. package/kits/physics-2d/pnpm-lock.yaml +1761 -0
  69. package/kits/physics-2d/scenes/main.scene +12 -0
  70. package/kits/physics-2d/scenes/sandbox.scene +13 -0
  71. package/kits/physics-2d/scripts/draw.mjs +121 -0
  72. package/kits/physics-2d/vite.config.js +1 -0
  73. package/package.json +1 -1
@@ -0,0 +1,32 @@
1
+ // Shared sprite-to-Layout geometry. Lives in engine/ (not behaviors/) so both
2
+ // Sprite.jsx (rendering) and the Collider rect logic (engine/collider.js) can
3
+ // use the same math without behaviors/ <-> engine/ import cycles.
4
+
5
+ // Destination rect for a draw mode: the Layout box for `stretch`/`tile`, or an
6
+ // aspect-ratio-preserving centered rect for `fit` and `cover`:
7
+ // - `fit` (CSS object-fit: contain): the largest rect with the art's aspect
8
+ // ratio that fits INSIDE the box -- letterboxed sides just aren't drawn.
9
+ // - `cover` (CSS object-fit: cover): the smallest rect with the art's aspect
10
+ // ratio that fully COVERS the box -- the overflow is cropped by the caller
11
+ // clipping to the Layout box (see Sprite.draw).
12
+ // `artSize` only needs `.width`/`.height` -- a rendered canvas or a sprite's
13
+ // `.resolution` both work.
14
+ export function spriteDestRect(mode, layout, artSize) {
15
+ if (mode !== 'fit' && mode !== 'cover') return layout;
16
+ const aspect = artSize.width / artSize.height;
17
+ let width = layout.width;
18
+ let height = width / aspect;
19
+ // `fit` shrinks until the art fits inside the box; `cover` grows until it
20
+ // fills the box. The comparison flips between the two.
21
+ const overflows = mode === 'fit' ? height > layout.height : height < layout.height;
22
+ if (overflows) {
23
+ height = layout.height;
24
+ width = height * aspect;
25
+ }
26
+ return {
27
+ x: layout.x + (layout.width - width) / 2,
28
+ y: layout.y + (layout.height - height) / 2,
29
+ width,
30
+ height,
31
+ };
32
+ }