swf2js 0.1.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -14
- package/package.json +11 -7
- package/studio/actionscript-roundtrip.test.js +54 -0
- package/studio/actionscript-scripts.test.js +169 -0
- package/studio/animated-image.test.js +137 -0
- package/studio/arithmetic.test.js +16 -0
- package/studio/as3-import.test.js +110 -0
- package/studio/audio-info.test.js +44 -0
- package/studio/components.test.js +152 -0
- package/studio/document-editing.test.js +92 -0
- package/studio/examples/01-space-mission.json +1628 -0
- package/studio/examples/02-clockwork-vault.json +1079 -0
- package/studio/examples/03-neon-synth.json +1364 -0
- package/studio/examples/04-kinetic-poster.json +923 -0
- package/studio/examples/05-signal-relay.json +1131 -0
- package/studio/examples/06-calculator.json +564 -0
- package/studio/frame-editing.test.js +129 -0
- package/studio/frame-events.test.js +117 -0
- package/studio/groups.test.js +88 -0
- package/studio/index.html +962 -0
- package/studio/interaction-triggers.test.js +37 -0
- package/studio/linked-actions.test.js +48 -0
- package/studio/lottie.test.js +208 -0
- package/studio/masks.test.js +43 -0
- package/studio/media-assets.test.js +62 -0
- package/studio/paint-tools.test.js +60 -0
- package/studio/playback.test.js +17 -0
- package/studio/project-io.test.js +405 -0
- package/studio/project-preview.test.js +475 -0
- package/studio/scene-transition.test.js +32 -0
- package/studio/server/archive-companions.js +27 -0
- package/studio/server/as3-library.js +91 -0
- package/studio/server/assets.js +162 -0
- package/studio/server/audio-info.js +82 -0
- package/studio/server/font-files.js +332 -0
- package/studio/server/http.js +135 -0
- package/studio/server/linked-actions.js +93 -0
- package/studio/server/png-decode.js +1 -0
- package/studio/server/project-movie.js +1164 -0
- package/studio/server/project-preview.js +152 -0
- package/studio/server/projects.js +370 -0
- package/studio/server/report.js +29 -0
- package/studio/server/routes.js +93 -0
- package/studio/server/swf-authoring.js +90 -0
- package/studio/server/swf-control-runtime.as +513 -0
- package/studio/server/swf-controls.js +119 -0
- package/studio/server/swf-export.js +293 -0
- package/studio/server/swf-import.js +1675 -0
- package/studio/server/swf-morphs.js +64 -0
- package/studio/server/swf-routes.js +42 -0
- package/studio/server/swf-streams.js +80 -0
- package/studio/server/swf-transition-runtime.as +52 -0
- package/studio/server/tween-recovery.js +106 -0
- package/studio/server-api.test.js +283 -0
- package/studio/server.js +320 -0
- package/studio/src/animated-image.js +423 -0
- package/studio/src/appearance-inspector.js +63 -0
- package/studio/src/arithmetic.js +50 -0
- package/studio/src/authored-controls.js +42 -0
- package/studio/src/busy.js +41 -0
- package/studio/src/canvas.js +430 -0
- package/studio/src/clipper-browser.js +2 -0
- package/studio/src/color-transform.js +38 -0
- package/studio/src/component-inspector.js +126 -0
- package/studio/src/components.js +268 -0
- package/studio/src/display-frame.js +262 -0
- package/studio/src/document-editing.js +69 -0
- package/studio/src/event-editor.js +150 -0
- package/studio/src/frame-editing.js +150 -0
- package/studio/src/frame-events.js +128 -0
- package/studio/src/frame-image.js +28 -0
- package/studio/src/groups.js +125 -0
- package/studio/src/handler-editor.js +122 -0
- package/studio/src/history.js +83 -0
- package/studio/src/imported-paths.js +99 -0
- package/studio/src/index.js +3582 -0
- package/studio/src/interaction-triggers.js +42 -0
- package/studio/src/json-patch.js +77 -0
- package/studio/src/layer-icons.js +25 -0
- package/studio/src/lottie-export.js +948 -0
- package/studio/src/lottie-import.js +1138 -0
- package/studio/src/masks.js +69 -0
- package/studio/src/media-assets.js +188 -0
- package/studio/src/media-library.js +193 -0
- package/studio/src/model.js +431 -0
- package/studio/src/numeric-fields.js +46 -0
- package/studio/src/object-list.js +57 -0
- package/studio/src/paint-tools.js +76 -0
- package/studio/src/placement-effects.js +74 -0
- package/studio/src/playback.js +10 -0
- package/studio/src/preview-audio.js +64 -0
- package/studio/src/preview-interactions.js +106 -0
- package/studio/src/preview-recorder.js +335 -0
- package/studio/src/preview-surface.js +338 -0
- package/studio/src/project-io.js +905 -0
- package/studio/src/project-session.js +375 -0
- package/studio/src/projects-dialog.js +319 -0
- package/studio/src/scene-transition.js +129 -0
- package/studio/src/script-editor.js +175 -0
- package/studio/src/script-references.js +74 -0
- package/studio/src/scripted-controls.js +146 -0
- package/studio/src/scripts.js +185 -0
- package/studio/src/stage-guides.js +101 -0
- package/studio/src/svg-animation.js +416 -0
- package/studio/src/svg-context.js +522 -0
- package/studio/src/svg-frame.js +413 -0
- package/studio/src/svg-import.js +1208 -0
- package/studio/src/swf-recording.js +104 -0
- package/studio/src/symbol-library.js +39 -0
- package/studio/src/symbols.js +62 -0
- package/studio/src/text-fields.js +58 -0
- package/studio/src/theme.js +43 -0
- package/studio/src/timeline.js +321 -0
- package/studio/src/vector-cut.js +103 -0
- package/studio/src/vector-geometry.js +254 -0
- package/studio/src/vector-style.js +146 -0
- package/studio/src/video-encode.js +84 -0
- package/studio/src/video-export.js +331 -0
- package/studio/src/video-mux.js +339 -0
- package/studio/src/video-playback.js +281 -0
- package/studio/src/workspace.js +344 -0
- package/studio/stroke-style.test.js +119 -0
- package/studio/styles.css +1547 -0
- package/studio/svg-export.test.js +162 -0
- package/studio/svg-import.test.js +318 -0
- package/studio/swf-authoring.test.js +140 -0
- package/studio/swf-export.test.js +324 -0
- package/studio/swf-import.test.js +489 -0
- package/studio/symbols.test.js +68 -0
- package/studio/tests/accessibility-interactions.mjs +138 -0
- package/studio/tests/appearance-interactions.mjs +103 -0
- package/studio/tests/control-interactions.mjs +60 -0
- package/studio/tests/event-interactions.mjs +117 -0
- package/studio/tests/external-resources.mjs +174 -0
- package/studio/tests/frame-image.mjs +71 -0
- package/studio/tests/html-export.mjs +68 -0
- package/studio/tests/import-files.mjs +131 -0
- package/studio/tests/lottie.mjs +125 -0
- package/studio/tests/mask-interactions.mjs +148 -0
- package/studio/tests/media-interactions.mjs +109 -0
- package/studio/tests/paint-interactions.mjs +64 -0
- package/studio/tests/project-interactions.mjs +244 -0
- package/studio/tests/script-interactions.mjs +178 -0
- package/studio/tests/scripted-control-interactions.mjs +107 -0
- package/studio/tests/svg-export.mjs +149 -0
- package/studio/tests/text-field-interactions.mjs +64 -0
- package/studio/tests/theme-interactions.mjs +53 -0
- package/studio/tests/timeline-browser.mjs +507 -0
- package/studio/tests/transition-interactions.mjs +94 -0
- package/studio/tests/trigger-interactions.mjs +93 -0
- package/studio/tests/video-export.mjs +243 -0
- package/studio/tests/workspace-interactions.mjs +226 -0
- package/studio/tween-recovery.test.js +31 -0
- package/studio/vector-style.test.js +56 -0
- package/studio/video-export.test.js +326 -0
- package/studiospec/actionscript.md +88 -0
- package/studiospec/architecture.md +378 -0
- package/studiospec/controls.md +100 -0
- package/studiospec/file-support.md +268 -0
- package/studiospec/lottie.md +69 -0
- package/studiospec/requirements.md +135 -0
- package/studiospec/stroke-style.md +95 -0
- package/studiospec/svg-export.md +83 -0
- package/studiospec/svg-import.md +139 -0
- package/studiospec/swooflib-integration.md +115 -0
- package/studiospec/tasks.md +573 -0
- package/studiospec/video-export.md +127 -0
- package/swf2js/__tests__/actionscript.test.js +1609 -0
- package/swf2js/__tests__/adpcm-audio.test.js +43 -0
- package/swf2js/__tests__/as2-compiler.test.js +153 -0
- package/swf2js/__tests__/as3-mixed-depth.test.js +498 -0
- package/swf2js/__tests__/authored-sprite-hit.test.js +118 -0
- package/swf2js/__tests__/authored-sprite-sizing.test.js +164 -0
- package/swf2js/__tests__/avm1-action-prefix.test.js +134 -0
- package/swf2js/__tests__/avm1-attach-movie.test.js +1151 -0
- package/swf2js/__tests__/avm1-boxhead-budget.test.js +73 -0
- package/swf2js/__tests__/avm1-cfg-bubble-tanks.test.js +101 -0
- package/swf2js/__tests__/avm1-cfg-mario-kart.test.js +184 -0
- package/swf2js/__tests__/avm1-cfg-mario.test.js +31 -0
- package/swf2js/__tests__/avm1-cfg-pacman.test.js +49 -0
- package/swf2js/__tests__/avm1-checkers-gameplay.test.js +122 -0
- package/swf2js/__tests__/avm1-clip-actions.test.js +2002 -0
- package/swf2js/__tests__/avm1-clone-drag.test.js +626 -0
- package/swf2js/__tests__/avm1-decompiler.test.js +102 -0
- package/swf2js/__tests__/avm1-dynamic-locals.test.js +159 -0
- package/swf2js/__tests__/avm1-formal-parameters.test.js +71 -0
- package/swf2js/__tests__/avm1-key-events.test.js +52 -0
- package/swf2js/__tests__/avm1-load-bitmap.test.js +75 -0
- package/swf2js/__tests__/avm1-loading-host-actions.test.js +764 -0
- package/swf2js/__tests__/avm1-multibyte-strings.test.js +63 -0
- package/swf2js/__tests__/avm1-pacman-gameplay.test.js +115 -0
- package/swf2js/__tests__/avm1-shape-hittest.test.js +311 -0
- package/swf2js/__tests__/avm1-shared-bodies.test.js +57 -0
- package/swf2js/__tests__/avm1-shared-runtime.test.js +1364 -0
- package/swf2js/__tests__/avm1-snake-gameplay.test.js +139 -0
- package/swf2js/__tests__/avm1-super.test.js +70 -0
- package/swf2js/__tests__/avm1-target-path.test.js +325 -0
- package/swf2js/__tests__/avm1-try.test.js +229 -0
- package/swf2js/__tests__/avm2-activation-closures.test.js +65 -0
- package/swf2js/__tests__/avm2-applytype.test.js +180 -0
- package/swf2js/__tests__/avm2-call-ops.test.js +232 -0
- package/swf2js/__tests__/avm2-callsuperid.test.js +231 -0
- package/swf2js/__tests__/avm2-class-initializer.test.js +219 -0
- package/swf2js/__tests__/avm2-custom-namespace.test.js +139 -0
- package/swf2js/__tests__/avm2-describe-type.test.js +96 -0
- package/swf2js/__tests__/avm2-dictionary.test.js +96 -0
- package/swf2js/__tests__/avm2-domain-memory.test.js +332 -0
- package/swf2js/__tests__/avm2-e4x.test.js +326 -0
- package/swf2js/__tests__/avm2-exceptions.test.js +81 -0
- package/swf2js/__tests__/avm2-findprop.test.js +110 -0
- package/swf2js/__tests__/avm2-getlex.test.js +166 -0
- package/swf2js/__tests__/avm2-global-slot.test.js +106 -0
- package/swf2js/__tests__/avm2-interface.test.js +95 -0
- package/swf2js/__tests__/avm2-multiname-precedence.test.js +148 -0
- package/swf2js/__tests__/avm2-named-namespace-types.test.js +106 -0
- package/swf2js/__tests__/avm2-optional-args.test.js +100 -0
- package/swf2js/__tests__/avm2-outer-scopes.test.js +101 -0
- package/swf2js/__tests__/avm2-package-internal-class.test.js +106 -0
- package/swf2js/__tests__/avm2-protected-namespace.test.js +105 -0
- package/swf2js/__tests__/avm2-protected.test.js +214 -0
- package/swf2js/__tests__/avm2-qwop-gameplay.test.js +116 -0
- package/swf2js/__tests__/avm2-runtime-namespaces.test.js +159 -0
- package/swf2js/__tests__/avm2-script-traits.test.js +89 -0
- package/swf2js/__tests__/avm2-shared-runtime.test.js +52 -0
- package/swf2js/__tests__/avm2-slot-ops.test.js +117 -0
- package/swf2js/__tests__/avm2-type-ops.test.js +224 -0
- package/swf2js/__tests__/bevel-filter.test.js +116 -0
- package/swf2js/__tests__/bitmap-button-mask.test.js +106 -0
- package/swf2js/__tests__/bitmap-data-draw.test.js +388 -0
- package/swf2js/__tests__/bitmap-decoder.test.js +108 -0
- package/swf2js/__tests__/bitmapdata-color-bounds.test.js +70 -0
- package/swf2js/__tests__/bitmapdata-copy-channel.test.js +91 -0
- package/swf2js/__tests__/bitmapdata-copy-pixels.test.js +136 -0
- package/swf2js/__tests__/bitmapdata-fill-compare.test.js +241 -0
- package/swf2js/__tests__/bitmapdata-filter.test.js +232 -0
- package/swf2js/__tests__/bitmapdata-hit-test.test.js +71 -0
- package/swf2js/__tests__/bitmapdata-merge.test.js +84 -0
- package/swf2js/__tests__/bitmapdata-palette-map.test.js +92 -0
- package/swf2js/__tests__/bitmapdata-pixels-io.test.js +198 -0
- package/swf2js/__tests__/bitmapdata-threshold.test.js +97 -0
- package/swf2js/__tests__/bitmapdata-vector.test.js +82 -0
- package/swf2js/__tests__/blur-filter.test.js +48 -0
- package/swf2js/__tests__/bundle-emitter.test.js +394 -0
- package/swf2js/__tests__/button-actions.test.js +370 -0
- package/swf2js/__tests__/button-color-transform.test.js +48 -0
- package/swf2js/__tests__/button-decoder.test.js +106 -0
- package/swf2js/__tests__/button-hit-test.test.js +825 -0
- package/swf2js/__tests__/button-scaling-grid.test.js +124 -0
- package/swf2js/__tests__/button-sound.test.js +105 -0
- package/swf2js/__tests__/bytearray-coercion.test.js +23 -0
- package/swf2js/__tests__/bytearray-object-serialization.test.js +380 -0
- package/swf2js/__tests__/cfg-switch-loop.test.js +103 -0
- package/swf2js/__tests__/clip-depth-mask.test.js +119 -0
- package/swf2js/__tests__/clipped-bitmap-fill.test.js +118 -0
- package/swf2js/__tests__/companion-swf.test.js +638 -0
- package/swf2js/__tests__/context-menu.test.js +149 -0
- package/swf2js/__tests__/convolution-filter.test.js +74 -0
- package/swf2js/__tests__/definefont4.test.js +280 -0
- package/swf2js/__tests__/display-displacement.test.js +161 -0
- package/swf2js/__tests__/display-list.test.js +80 -0
- package/swf2js/__tests__/display-mask-render.test.js +656 -0
- package/swf2js/__tests__/displayobject-stage.test.js +320 -0
- package/swf2js/__tests__/embedded-script-audio.test.js +131 -0
- package/swf2js/__tests__/embedded-swf.test.js +202 -0
- package/swf2js/__tests__/embedded-textfield.test.js +107 -0
- package/swf2js/__tests__/embedded-timeline-audio.test.js +182 -0
- package/swf2js/__tests__/embedded-timeline-input.test.js +420 -0
- package/swf2js/__tests__/embedded-timer-lifecycle.test.js +145 -0
- package/swf2js/__tests__/event-priority-order.test.js +125 -0
- package/swf2js/__tests__/event-weak-listeners.test.js +53 -0
- package/swf2js/__tests__/event-will-trigger.test.js +43 -0
- package/swf2js/__tests__/flash-text-engine-content.test.js +115 -0
- package/swf2js/__tests__/flash-text-engine-format.test.js +95 -0
- package/swf2js/__tests__/flash-text-engine-line.test.js +314 -0
- package/swf2js/__tests__/font-encoder.test.js +95 -0
- package/swf2js/__tests__/font-outline-text.test.js +659 -0
- package/swf2js/__tests__/glow-shadow-filter.test.js +68 -0
- package/swf2js/__tests__/graphics-bitmap-smoothing.test.js +32 -0
- package/swf2js/__tests__/graphics-fill-lifetime.test.js +36 -0
- package/swf2js/__tests__/graphics-gradient-matrix.test.js +53 -0
- package/swf2js/__tests__/graphics-stroke-hit-test.test.js +457 -0
- package/swf2js/__tests__/hit-test-primitives.test.js +414 -0
- package/swf2js/__tests__/input-events.test.js +714 -0
- package/swf2js/__tests__/integration/corpus.test.js +41 -0
- package/swf2js/__tests__/loader-embedded-swf.test.js +210 -0
- package/swf2js/__tests__/loader-info.test.js +81 -0
- package/swf2js/__tests__/local-connection.test.js +122 -0
- package/swf2js/__tests__/morph-focal-gradient.test.js +51 -0
- package/swf2js/__tests__/morph-topology.test.js +267 -0
- package/swf2js/__tests__/movie-data-codec.test.js +128 -0
- package/swf2js/__tests__/nellymoser-audio.test.js +84 -0
- package/swf2js/__tests__/opaque-background-cache.test.js +352 -0
- package/swf2js/__tests__/path-stream.test.js +81 -0
- package/swf2js/__tests__/place-object-filters.test.js +88 -0
- package/swf2js/__tests__/place-object3-decoder.test.js +116 -0
- package/swf2js/__tests__/place-object3-image.test.js +85 -0
- package/swf2js/__tests__/player-version.test.js +46 -0
- package/swf2js/__tests__/root-textfield.test.js +287 -0
- package/swf2js/__tests__/scaling-grid.test.js +183 -0
- package/swf2js/__tests__/shape-decoder.test.js +361 -0
- package/swf2js/__tests__/shape-line-style2.test.js +138 -0
- package/swf2js/__tests__/shape-nonscaling-stroke.test.js +131 -0
- package/swf2js/__tests__/shape-pixel-hint.test.js +101 -0
- package/swf2js/__tests__/simplebutton-pointer.test.js +1477 -0
- package/swf2js/__tests__/socket-offline.test.js +67 -0
- package/swf2js/__tests__/sound-avm1-stop.test.js +99 -0
- package/swf2js/__tests__/sound-envelope.test.js +110 -0
- package/swf2js/__tests__/sound-extract.test.js +168 -0
- package/swf2js/__tests__/sound-id3.test.js +283 -0
- package/swf2js/__tests__/sound-load.test.js +259 -0
- package/swf2js/__tests__/sound-mixer-spectrum.test.js +261 -0
- package/swf2js/__tests__/sound-stream-sprite.test.js +624 -0
- package/swf2js/__tests__/sound-transform.test.js +104 -0
- package/swf2js/__tests__/speex-audio.test.js +77 -0
- package/swf2js/__tests__/stage-noscale.test.js +45 -0
- package/swf2js/__tests__/swf-encoder.test.js +134 -0
- package/swf2js/__tests__/swflib-assemble.test.js +20 -0
- package/swf2js/__tests__/textfield-html-text.test.js +368 -0
- package/swf2js/__tests__/textfield-line-layout.test.js +339 -0
- package/swf2js/__tests__/textfield-programmatic-overlay.test.js +2506 -0
- package/swf2js/__tests__/textfield-scroll.test.js +79 -0
- package/swf2js/__tests__/textfield-selection.test.js +383 -0
- package/swf2js/__tests__/timeline-effect-surfaces.test.js +295 -0
- package/swf2js/__tests__/timeline-named-anchor.test.js +139 -0
- package/swf2js/__tests__/timeline-scenes.test.js +1723 -0
- package/swf2js/__tests__/urlloader-http-status.test.js +236 -0
- package/{src → swf2js}/cli.js +43 -11
- package/swf2js/compiler/as2-classes.js +156 -0
- package/swf2js/compiler/as2-parser.js +598 -0
- package/swf2js/compiler/avm1-codegen.js +897 -0
- package/swf2js/compiler/index.js +28 -0
- package/{src → swf2js}/decoder/button-decoder.js +3 -1
- package/swf2js/decoder/png.js +114 -0
- package/{src → swf2js}/decoder/shape-decoder.js +20 -10
- package/{src → swf2js}/decoder/tag-decoder.js +5 -3
- package/{src → swf2js}/decoder/tag-types.js +4 -0
- package/swf2js/decompiler/avm1-decompiler.js +1138 -0
- package/{src → swf2js}/emitter/asset-encoder.js +66 -113
- package/{src → swf2js}/emitter/bundle-emitter.js +209 -78
- package/swf2js/emitter/external-resources.js +39 -0
- package/swf2js/emitter/movie-data-codec.js +91 -0
- package/swf2js/encoder/bit-writer.js +182 -0
- package/swf2js/encoder/shape-encoder.js +310 -0
- package/swf2js/encoder/swf-builder.js +639 -0
- package/swf2js/encoder/swf-writer.js +55 -0
- package/{src/runtime/swflib/assemble.js → swf2js/runtime/assemble-swooflib.js} +4 -3
- package/{src → swf2js}/runtime/avm1-runtime.js +102 -63
- package/{src → swf2js}/runtime/index.js +1 -1
- package/{src → swf2js}/runtime/movie-runtime.js +28 -2
- package/{src → swf2js}/transpiler/actionscript.js +82 -19
- package/{src → swf2js}/transpiler/avm1/avm1-opcodes.js +5 -3
- package/{src → swf2js}/transpiler/avm1/avm1-transpiler.js +69 -6
- package/{src → swf2js}/transpiler/avm2/avm2-transpiler.js +1 -1
- package/{src → swf2js}/transpiler/timeline/display-list.js +41 -22
- package/{src → swf2js}/transpiler/timeline/timeline-codegen.js +97 -36
- package/swooflib/README.md +569 -0
- package/swooflib/adpcm.js +147 -0
- package/{src/runtime/swflib → swooflib}/builtins.js +6 -0
- package/{src/runtime/swflib → swooflib}/context-menu.js +7 -1
- package/swooflib/control-definitions.js +42 -0
- package/swooflib/control-widget.js +763 -0
- package/swooflib/controls.js +300 -0
- package/{src/runtime/swflib → swooflib}/display.js +16 -10
- package/{src/runtime/swflib → swooflib}/events.js +11 -0
- package/{src/runtime/swflib → swooflib}/flash.js +6 -5
- package/{src/runtime/swflib → swooflib}/graphics.js +81 -19
- package/{src/runtime/swflib → swooflib}/input.js +12 -14
- package/{src/runtime/swflib → swooflib}/loader.js +52 -22
- package/swooflib/movie-network.js +86 -0
- package/swooflib/path-stream.js +169 -0
- package/{src/runtime/swflib → swooflib}/render.js +3 -13
- package/{src/runtime/swflib → swooflib}/sound.js +25 -2
- package/{src/runtime/swflib → swooflib}/stage.js +3 -3
- package/swooflib/stream-time.js +21 -0
- package/{src/runtime/swflib → swooflib}/system.js +88 -37
- package/{src/runtime/swflib → swooflib}/text-paint.js +14 -3
- package/{src/runtime/swflib → swooflib}/text.js +8 -0
- package/swooflib/xml-node.js +53 -0
- package/src/emitter/timeline-data-codec.js +0 -58
- /package/{src → swf2js}/decoder/symbol-table.js +0 -0
- /package/{src → swf2js}/emitter/embedded-swf.js +0 -0
- /package/{src → swf2js}/emitter/font-encoder.js +0 -0
- /package/{src → swf2js}/model/swf-document.js +0 -0
- /package/{src → swf2js}/model/transpile-result.js +0 -0
- /package/{src → swf2js}/parser/bit-reader.js +0 -0
- /package/{src → swf2js}/parser/decompressor.js +0 -0
- /package/{src → swf2js}/parser/swf-parser.js +0 -0
- /package/{src → swf2js}/pretty-printer/pretty-printer.js +0 -0
- /package/{src → swf2js}/runtime/avm2-runtime.js +0 -0
- /package/{src → swf2js}/runtime/embedded-movie-runtime.js +0 -0
- /package/{src → swf2js}/transpiler/avm1/avm1-ir.js +0 -0
- /package/{src → swf2js}/transpiler/avm1/avm1-rewrite.js +0 -0
- /package/{src → swf2js}/transpiler/avm2/abc-reader.js +0 -0
- /package/{src → swf2js}/transpiler/cfg-structurer.js +0 -0
- /package/{src → swf2js}/util/diagnostics.js +0 -0
- /package/{src → swf2js}/util/logger.js +0 -0
- /package/{src/runtime/swflib → swooflib}/bitmap-image.js +0 -0
- /package/{src/runtime/swflib → swooflib}/bitmap.js +0 -0
- /package/{src/runtime/swflib → swooflib}/bytearray.js +0 -0
- /package/{src/runtime/swflib → swooflib}/compiled-swf.js +0 -0
- /package/{src/runtime/swflib → swooflib}/cursor-flag.js +0 -0
- /package/{src/runtime/swflib → swooflib}/dictionary.js +0 -0
- /package/{src/runtime/swflib → swooflib}/filters.js +0 -0
- /package/{src/runtime/swflib → swooflib}/geom.js +0 -0
- /package/{src/runtime/swflib → swooflib}/glyph-metrics.js +0 -0
- /package/{src/runtime/swflib → swooflib}/host.js +0 -0
- /package/{src/runtime/swflib → swooflib}/inherit.js +0 -0
- /package/{src/runtime/swflib → swooflib}/marks.js +0 -0
- /package/{src/runtime/swflib → swooflib}/matrix3d.js +0 -0
- /package/{src/runtime/swflib → swooflib}/pointer-bridge.js +0 -0
- /package/{src/runtime/swflib → swooflib}/projection.js +0 -0
- /package/{src/runtime/swflib → swooflib}/sprite-drag.js +0 -0
- /package/{src/runtime/swflib → swooflib}/stage-ref.js +0 -0
- /package/{src/runtime/swflib → swooflib}/text-field.js +0 -0
- /package/{src/runtime/swflib → swooflib}/transform.js +0 -0
- /package/{src/runtime/swflib → swooflib}/xml.js +0 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { parse } from '../parser/swf-parser.js';
|
|
4
|
+
import { decode, decodeTag } from '../decoder/tag-decoder.js';
|
|
5
|
+
import { decodeMorphShape, decodeShape } from '../decoder/shape-decoder.js';
|
|
6
|
+
import { SymbolTable } from '../decoder/symbol-table.js';
|
|
7
|
+
import { TAG } from '../decoder/tag-types.js';
|
|
8
|
+
import { hitTestAvm1ShapeGeometry } from '../runtime/avm1-runtime.js';
|
|
9
|
+
import { buildDisplayList } from '../transpiler/timeline/display-list.js';
|
|
10
|
+
import { generateTimelineEngine, hitTestButtonGeometry, morphDrawsFor } from '../transpiler/timeline/timeline-codegen.js';
|
|
11
|
+
import { DiagnosticsCollector } from '../util/diagnostics.js';
|
|
12
|
+
|
|
13
|
+
function overlappingShapeRecords(withFillStyle = true) {
|
|
14
|
+
const signed = value => (value & 0x1ff).toString(2).padStart(9, '0');
|
|
15
|
+
const moveTo = (x, y, selectFill) =>
|
|
16
|
+
`${selectFill ? '000011' : '000001'}01001${signed(x)}${signed(y)}${selectFill ? '1' : ''}`;
|
|
17
|
+
const edge = (vertical, delta) => `1101110${+vertical}${signed(delta)}`;
|
|
18
|
+
const square = edge(false, 200) + edge(true, 200) + edge(false, -200) + edge(true, -200);
|
|
19
|
+
const bits = moveTo(0, 0, withFillStyle) + square + moveTo(100, 100, false) + square + '000000';
|
|
20
|
+
return [withFillStyle ? 0x10 : 0, ...bits.match(/.{1,8}/g).map(byte => parseInt(byte.padEnd(8, '0'), 2))];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function originalShapeCharacters(filename, ids) {
|
|
24
|
+
const { doc, diagnostics } = await parse(readFileSync(filename));
|
|
25
|
+
const shapeCodes = [TAG.DefineShape, TAG.DefineShape2, TAG.DefineShape3, TAG.DefineShape4];
|
|
26
|
+
const symbols = new SymbolTable();
|
|
27
|
+
for (const tag of doc.tags) {
|
|
28
|
+
if (!shapeCodes.includes(tag.code)) continue;
|
|
29
|
+
const characterId = tag.data[0] + tag.data[1] * 256;
|
|
30
|
+
if (ids.includes(characterId)) symbols.set(characterId, decodeTag(tag, doc, diagnostics));
|
|
31
|
+
}
|
|
32
|
+
return buildDisplayList([], symbols, diagnostics).characters;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function renderedLinearGradientStops(characterId, characters, endpoints = []) {
|
|
36
|
+
const engine = generateTimelineEngine({
|
|
37
|
+
frames: [{ places: [{ depth: 1, characterId }] }], characters,
|
|
38
|
+
}, { frameCount: 1 });
|
|
39
|
+
const stops = [];
|
|
40
|
+
const ctx = {
|
|
41
|
+
save() {}, restore() {}, setTransform() {}, fillRect() {}, fill() {}, stroke() {},
|
|
42
|
+
createLinearGradient(...coordinates) {
|
|
43
|
+
endpoints.push(coordinates);
|
|
44
|
+
return { addColorStop(ratio, color) { stops.push({ ratio, color }); } };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
class Path2D { moveTo() {} lineTo() {} quadraticCurveTo() {} closePath() {} }
|
|
48
|
+
new Function('ctx', 'Path2D', `
|
|
49
|
+
var BACKGROUND = '#000', STAGE_WIDTH = 600, STAGE_HEIGHT = 440, loaded = {};
|
|
50
|
+
${engine}
|
|
51
|
+
timeline.render();
|
|
52
|
+
`)(ctx, Path2D);
|
|
53
|
+
return stops;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
describe('shape-decoder', () => {
|
|
57
|
+
it.each([
|
|
58
|
+
{ filename: 'archive/flasharchive/Tron.swf', characterId: 122, expected: [0, 179.5, 360, 179.5] },
|
|
59
|
+
{ filename: 'archive/Swf/strike-force-heroes-2.swf', characterId: 1887, expected: [1568.75, -192.2, 1568.75, -216.5] },
|
|
60
|
+
])('paints the authored linear gradient span in $filename shape $characterId', async ({ filename, characterId, expected }) => {
|
|
61
|
+
const characters = await originalShapeCharacters(filename, [characterId]);
|
|
62
|
+
const engine = generateTimelineEngine({
|
|
63
|
+
frames: [{ places: [{ depth: 1, characterId }] }],
|
|
64
|
+
characters,
|
|
65
|
+
}, { frameCount: 1 });
|
|
66
|
+
const endpoints = [];
|
|
67
|
+
const ctx = {
|
|
68
|
+
save() {}, restore() {}, setTransform() {}, fillRect() {}, fill() {}, stroke() {},
|
|
69
|
+
createLinearGradient(...coordinates) { endpoints.push(coordinates); return { addColorStop() {} }; },
|
|
70
|
+
};
|
|
71
|
+
class Path2D { moveTo() {} lineTo() {} quadraticCurveTo() {} closePath() {} }
|
|
72
|
+
new Function('ctx', 'Path2D', `
|
|
73
|
+
var BACKGROUND = '#000', STAGE_WIDTH = 400, STAGE_HEIGHT = 400, loaded = {};
|
|
74
|
+
${engine}
|
|
75
|
+
timeline.render();
|
|
76
|
+
`)(ctx, Path2D);
|
|
77
|
+
|
|
78
|
+
expect(endpoints[0]).toEqual(expected);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('paints the original Plazma Burst 2 repeat gradients over their full authored extents', async () => {
|
|
82
|
+
const characters = await originalShapeCharacters('archive/Swf/plazma-burst-2.swf', [5, 1154]);
|
|
83
|
+
const engine = generateTimelineEngine({
|
|
84
|
+
frames: [{ places: [{ depth: 1, characterId: 5 }, { depth: 2, characterId: 1154 }] }],
|
|
85
|
+
characters,
|
|
86
|
+
}, { frameCount: 1 });
|
|
87
|
+
const gradients = [];
|
|
88
|
+
const ctx = {
|
|
89
|
+
save() {}, restore() {}, setTransform() {}, fillRect() {}, fill() {}, stroke() {},
|
|
90
|
+
createLinearGradient(...coordinates) {
|
|
91
|
+
const stops = [];
|
|
92
|
+
gradients.push({ coordinates, stops });
|
|
93
|
+
return { addColorStop(ratio, color) { stops.push([ratio, color]); } };
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
class Path2D { moveTo() {} lineTo() {} closePath() {} }
|
|
97
|
+
new Function('ctx', 'Path2D', `
|
|
98
|
+
var BACKGROUND = '#fff', STAGE_WIDTH = 800, STAGE_HEIGHT = 400, loaded = {};
|
|
99
|
+
${engine}
|
|
100
|
+
timeline.render();
|
|
101
|
+
timeline.render();
|
|
102
|
+
`)(ctx, Path2D);
|
|
103
|
+
|
|
104
|
+
expect(gradients).toHaveLength(2);
|
|
105
|
+
expect(gradients[0].coordinates).toEqual([10.5, -14.5, 289.5, 264.5]);
|
|
106
|
+
expect(gradients[0].stops).toHaveLength(93 * 4);
|
|
107
|
+
const { coordinates, stops } = gradients[1];
|
|
108
|
+
expect(coordinates).toEqual([10.5, -14.5, 613.5, 588.5]);
|
|
109
|
+
expect(stops).toHaveLength(201 * 4);
|
|
110
|
+
expect(stops.slice(0, 5)).toEqual([
|
|
111
|
+
[0, 'rgba(0,0,0,0.8118)'],
|
|
112
|
+
[100 / 255 / 201, 'rgba(0,0,0,0.8118)'],
|
|
113
|
+
[105 / 255 / 201, 'rgba(0,0,0,0.8627)'],
|
|
114
|
+
[1 / 201, 'rgba(0,0,0,0.8627)'],
|
|
115
|
+
[1 / 201, 'rgba(0,0,0,0.8118)'],
|
|
116
|
+
]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it.each([1, 2])('extends LineStyle2 linear spread mode %i to the stroke caps', spreadMode => {
|
|
120
|
+
const bits = (number, width) => number.toString(2).padStart(width, '0');
|
|
121
|
+
const bytes = values => values.match(/.{1,8}/g).map(byte => parseInt(byte.padEnd(8, '0'), 2));
|
|
122
|
+
const rect = bounds => bytes(bits(13, 5) + bounds.map(value => bits(value, 13)).join(''));
|
|
123
|
+
// Ten pixels per period, with period zero beginning at x = 0.
|
|
124
|
+
const matrix = bytes('1' + bits(11, 5) + bits(400, 11) + bits(400, 11)
|
|
125
|
+
+ '0' + bits(8, 5) + bits(100, 8) + bits(0, 8));
|
|
126
|
+
const line = '001001' + bits(13, 5) + bits(1200, 13) + bits(100, 13) + '1'
|
|
127
|
+
+ '11' + bits(10, 4) + '00' + bits(1200, 12) + '000000';
|
|
128
|
+
const raw = Uint8Array.of(
|
|
129
|
+
1, 0, ...rect([1160, 2440, 60, 140]), ...rect([1200, 2400, 100, 100]), 1,
|
|
130
|
+
0, 1, 80, 0, 0x08, 0, 0x10, ...matrix, (spreadMode << 6) | 2,
|
|
131
|
+
0, 255, 0, 0, 255, 255, 0, 255, 0, 255,
|
|
132
|
+
0x01, ...bytes(line),
|
|
133
|
+
);
|
|
134
|
+
const shape = decodeShape(raw, 4);
|
|
135
|
+
const endpoints = [];
|
|
136
|
+
const stops = renderedLinearGradientStops(1, { 1: { type: 'shape', draws: shape.draws } }, endpoints);
|
|
137
|
+
expect(endpoints).toEqual([[50, 0, 130, 0]]);
|
|
138
|
+
expect(stops).toHaveLength(16);
|
|
139
|
+
expect(stops[0]).toEqual({ ratio: 0, color: spreadMode === 1 ? '#00ff00' : '#ff0000' });
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('renders the original Avalanche 69 linear-RGB ramp within one channel level', async () => {
|
|
143
|
+
const characters = await originalShapeCharacters('archive/flasharchive/Avalanche.swf', [69]);
|
|
144
|
+
const stops = renderedLinearGradientStops(69, characters).map(({ ratio, color }) => {
|
|
145
|
+
const [red, , , alpha] = color[0] === '#'
|
|
146
|
+
? [parseInt(color.slice(1, 3), 16), 0, 0, 1]
|
|
147
|
+
: color.slice(5, -1).split(',').map(Number);
|
|
148
|
+
return { ratio, red, alpha };
|
|
149
|
+
});
|
|
150
|
+
let maxError = 0;
|
|
151
|
+
for (let i = 0; i < 512; i++) {
|
|
152
|
+
const ratio = i / 512;
|
|
153
|
+
const rightIndex = stops.findIndex(stop => stop.ratio > ratio);
|
|
154
|
+
const left = stops[rightIndex - 1], right = stops[rightIndex];
|
|
155
|
+
const t = (ratio - left.ratio) / (right.ratio - left.ratio);
|
|
156
|
+
const sampled = left.red + (right.red - left.red) * t;
|
|
157
|
+
const expected = 255 * (ratio <= 0.0031308 ? 12.92 * ratio : 1.055 * ratio ** (1 / 2.4) - 0.055);
|
|
158
|
+
maxError = Math.max(maxError, Math.abs(expected - sampled));
|
|
159
|
+
expect(left.alpha + (right.alpha - left.alpha) * t).toBeCloseTo(0.502 + 0.498 * ratio, 10);
|
|
160
|
+
}
|
|
161
|
+
expect(maxError).toBeLessThan(1);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it.each([0, 1])('keeps both colors at a coincident linear-RGB stop with spread mode %s', spreadMode => {
|
|
165
|
+
const stops = renderedLinearGradientStops(1, {
|
|
166
|
+
1: { type: 'shape', draws: [{
|
|
167
|
+
path: [['M', -800, 0], ['L', 2400, 0], ['L', 2400, 20], ['L', -800, 20], ['Z']],
|
|
168
|
+
fill: {
|
|
169
|
+
type: 'linear', interpolationMode: 1, spreadMode,
|
|
170
|
+
stops: [
|
|
171
|
+
{ ratio: 0, color: '#000000' }, { ratio: 128, color: '#ff0000' },
|
|
172
|
+
{ ratio: 128, color: '#0000ff' }, { ratio: 255, color: '#ffffff' },
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
}] },
|
|
176
|
+
});
|
|
177
|
+
const colorsAt = ratio => stops.filter(stop => stop.ratio === ratio).map(stop => stop.color);
|
|
178
|
+
const hardStop = 128 / 255;
|
|
179
|
+
expect(colorsAt(spreadMode ? hardStop / 2 : hardStop)).toEqual(['#ff0000', '#0000ff']);
|
|
180
|
+
if (spreadMode) expect(colorsAt((1 + (1 - hardStop)) / 2)).toEqual(['#0000ff', '#ff0000']);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('applies the radial gradient matrix independently from Plazma Burst 2 shape 304 geometry', async () => {
|
|
184
|
+
const characterId = 304;
|
|
185
|
+
const characters = await originalShapeCharacters('archive/Swf/plazma-burst-2.swf', [characterId]);
|
|
186
|
+
const shape = characters[characterId];
|
|
187
|
+
const gradient = shape.draws[0].fill.matrix;
|
|
188
|
+
const engine = generateTimelineEngine({
|
|
189
|
+
frames: [{ places: [{
|
|
190
|
+
depth: 1, characterId, matrix: { a: 1, b: 0, c: 0, d: 1, tx: 2000, ty: 600 },
|
|
191
|
+
}] }],
|
|
192
|
+
characters,
|
|
193
|
+
}, { frameCount: 1 });
|
|
194
|
+
let transform;
|
|
195
|
+
const transforms = [], fills = [];
|
|
196
|
+
const ctx = {
|
|
197
|
+
save() { transforms.push(transform); },
|
|
198
|
+
restore() { transform = transforms.pop(); },
|
|
199
|
+
setTransform(a, b, c, d, e, f) { transform = { a, b, c, d, e, f }; },
|
|
200
|
+
transform(a, b, c, d, e, f) {
|
|
201
|
+
const { a: x, b: y, c: u, d: v, e: tx, f: ty } = transform;
|
|
202
|
+
this.setTransform(x * a + u * b, y * a + v * b, x * c + u * d,
|
|
203
|
+
y * c + v * d, x * e + u * f + tx, y * e + v * f + ty);
|
|
204
|
+
},
|
|
205
|
+
fillRect() {}, stroke() {},
|
|
206
|
+
createRadialGradient(...coordinates) { return { coordinates, addColorStop() {} }; },
|
|
207
|
+
fill(path, rule) { fills.push({ path, rule, transform, style: this.fillStyle }); },
|
|
208
|
+
};
|
|
209
|
+
class Path2D {
|
|
210
|
+
moveTo() {} lineTo() {} quadraticCurveTo() {} closePath() {}
|
|
211
|
+
addPath(source, inverse) { this.source = source; this.inverse = inverse; }
|
|
212
|
+
}
|
|
213
|
+
new Function('ctx', 'Path2D', `
|
|
214
|
+
var BACKGROUND = '#000', STAGE_WIDTH = 500, STAGE_HEIGHT = 500, loaded = {};
|
|
215
|
+
${engine}
|
|
216
|
+
timeline.render();
|
|
217
|
+
`)(ctx, Path2D);
|
|
218
|
+
|
|
219
|
+
const first = fills[0];
|
|
220
|
+
expect(first.transform).toEqual({
|
|
221
|
+
a: gradient.a, b: gradient.b, c: gradient.c, d: gradient.d, e: 100 + gradient.tx, f: 30 + gradient.ty,
|
|
222
|
+
});
|
|
223
|
+
expect(first.style.coordinates).toEqual([0, 0, 0, 0, 0, 819.2]);
|
|
224
|
+
expect(first.rule).toBe('evenodd');
|
|
225
|
+
expect(first.path.source).toBeInstanceOf(Path2D);
|
|
226
|
+
const [x, y] = shape.draws[0].path[0].slice(1);
|
|
227
|
+
const point = (m, x, y) => [m.a * x + m.c * y + m.e, m.b * x + m.d * y + m.f];
|
|
228
|
+
const mapped = point(first.transform, ...point(first.path.inverse, x, y));
|
|
229
|
+
expect(mapped[0]).toBeCloseTo(100 + x);
|
|
230
|
+
expect(mapped[1]).toBeCloseTo(30 + y);
|
|
231
|
+
expect(fills[1].transform).toEqual({ a: 1, b: 0, c: 0, d: 1, e: 100, f: 30 });
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('reflects the original Super Mario 63 focal gradient from its authored first circle', async () => {
|
|
235
|
+
const characterId = 5228;
|
|
236
|
+
const characters = await originalShapeCharacters('archive/flasharchive/Super Mario 63.swf', [characterId]);
|
|
237
|
+
const shape = characters[characterId];
|
|
238
|
+
const draw = shape.draws.find(draw => draw.fill?.type === 'radial' && draw.fill.spreadMode === 1);
|
|
239
|
+
const { matrix, focal, stops: authoredStops } = draw.fill;
|
|
240
|
+
const engine = generateTimelineEngine({
|
|
241
|
+
frames: [{ places: [{ depth: 1, characterId }] }],
|
|
242
|
+
characters: { [characterId]: { ...shape, draws: [draw] } },
|
|
243
|
+
}, { frameCount: 1 });
|
|
244
|
+
let circles;
|
|
245
|
+
const stops = [];
|
|
246
|
+
const ctx = {
|
|
247
|
+
save() {}, restore() {}, fillRect() {}, setTransform() {}, fill() {},
|
|
248
|
+
createRadialGradient(...coordinates) {
|
|
249
|
+
circles = coordinates;
|
|
250
|
+
return { addColorStop(ratio, color) { stops.push([ratio, color]); } };
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
class Path2D { moveTo() {} lineTo() {} closePath() {} }
|
|
254
|
+
new Function('ctx', 'Path2D', `
|
|
255
|
+
var BACKGROUND = '#000', STAGE_WIDTH = 500, STAGE_HEIGHT = 500, loaded = {};
|
|
256
|
+
${engine}
|
|
257
|
+
timeline.render();
|
|
258
|
+
`)(ctx, Path2D);
|
|
259
|
+
|
|
260
|
+
const [startX, startY, startRadius, endX, endY, endRadius] = circles;
|
|
261
|
+
const radius = 819.2 * matrix.a;
|
|
262
|
+
const [firstRing, firstRingColor] = stops[1];
|
|
263
|
+
expect(startX).toBeCloseTo(matrix.tx + focal * radius);
|
|
264
|
+
expect(startY).toBeCloseTo(matrix.ty);
|
|
265
|
+
expect(startRadius).toBe(0);
|
|
266
|
+
expect(startX + (endX - startX) * firstRing).toBeCloseTo(matrix.tx);
|
|
267
|
+
expect(startY + (endY - startY) * firstRing).toBeCloseTo(matrix.ty);
|
|
268
|
+
expect(endRadius * firstRing).toBeCloseTo(radius);
|
|
269
|
+
expect(firstRingColor).toBe(authoredStops[1].color);
|
|
270
|
+
expect(stops.slice(2, 4)).toEqual([
|
|
271
|
+
[firstRing, authoredStops[1].color],
|
|
272
|
+
[2 * firstRing, authoredStops[0].color],
|
|
273
|
+
]);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it.each([[3, false], [4, false], [4, true]])('uses the authored fill rule for DefineShape%s with winding flag %s', (version, winding) => {
|
|
277
|
+
const rect = [0x08, 0];
|
|
278
|
+
const shape4Fields = version === 4 ? [...rect, winding ? 0x04 : 0] : [];
|
|
279
|
+
const body = [1, 0, ...rect, ...shape4Fields, 1, 0, 255, 0, 0, 255, 0, ...overlappingShapeRecords()];
|
|
280
|
+
const decoded = decodeShape(new Uint8Array(body), version);
|
|
281
|
+
expect(decoded.evenOdd).toBe(!winding);
|
|
282
|
+
|
|
283
|
+
const characters = { 1: { type: 'shape', ...decoded } };
|
|
284
|
+
const engine = generateTimelineEngine({ frames: [{ places: [{ depth: 1, characterId: 1 }] }], characters }, { frameCount: 1 });
|
|
285
|
+
const fillRules = [];
|
|
286
|
+
const ctx = { save() {}, restore() {}, fillRect() {}, setTransform() {}, fill(_, rule) { fillRules.push(rule); } };
|
|
287
|
+
class Path2D { moveTo() {} lineTo() {} closePath() {} }
|
|
288
|
+
new Function('ctx', 'Path2D', `
|
|
289
|
+
var BACKGROUND = '#fff', STAGE_WIDTH = 20, STAGE_HEIGHT = 20, FRAME_RATE = 24, loaded = {};
|
|
290
|
+
${engine}
|
|
291
|
+
timeline.render();
|
|
292
|
+
`)(ctx, Path2D);
|
|
293
|
+
expect(fillRules).toEqual([winding ? 'nonzero' : 'evenodd']);
|
|
294
|
+
|
|
295
|
+
for (const [x, y, expected] of [[2, 2, true], [7, 7, winding], [12, 12, true], [17, 17, false]]) {
|
|
296
|
+
expect(hitTestAvm1ShapeGeometry(characters, 1, { x, y })).toBe(expected);
|
|
297
|
+
expect(hitTestButtonGeometry(characters, 1, null, x, y)).toBe(expected);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('keeps the default fill rule through morph interpolation', () => {
|
|
302
|
+
const rect = [0x08, 0];
|
|
303
|
+
const start = [1, 0, 255, 0, 0, 255, 0, 0, 255, 255, 0, ...overlappingShapeRecords()];
|
|
304
|
+
const body = new Uint8Array([1, 0, ...rect, ...rect, start.length, 0, 0, 0, ...start, ...overlappingShapeRecords(false)]);
|
|
305
|
+
const decoded = decodeMorphShape(body);
|
|
306
|
+
const morph = { startDraws: decoded.startDraws, endDraws: decoded.endDraws };
|
|
307
|
+
expect([0, 32768, 65535].map(ratio => morphDrawsFor({ morph }, ratio)[0].evenOdd)).toEqual([true, true, true]);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('decodes all age-of-war DefineShape tags into path draws', async () => {
|
|
311
|
+
const diag = new DiagnosticsCollector();
|
|
312
|
+
const bytes = new Uint8Array(readFileSync('archive/Swf/age-of-war.swf'));
|
|
313
|
+
const { doc } = await parse(bytes, diag);
|
|
314
|
+
const { symbolTable } = decode(doc, diag);
|
|
315
|
+
|
|
316
|
+
let shapes = 0;
|
|
317
|
+
let draws = 0;
|
|
318
|
+
for (const id of symbolTable.ids()) {
|
|
319
|
+
const c = symbolTable.get(id);
|
|
320
|
+
if (c.type !== 'Shape') continue;
|
|
321
|
+
shapes++;
|
|
322
|
+
const decoded = decodeShape(c.rawData, c.version);
|
|
323
|
+
expect(decoded.draws.length).toBeGreaterThan(0);
|
|
324
|
+
draws += decoded.draws.length;
|
|
325
|
+
const first = decoded.draws[0];
|
|
326
|
+
expect(first.path[0][0]).toBe('M');
|
|
327
|
+
if (first.fill) {
|
|
328
|
+
expect(['solid', 'linear', 'radial', 'bitmap']).toContain(first.fill.type);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
expect(shapes).toBeGreaterThan(100);
|
|
332
|
+
expect(draws).toBeGreaterThan(shapes);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('embeds draws on display-list shape characters', async () => {
|
|
336
|
+
const diag = new DiagnosticsCollector();
|
|
337
|
+
const bytes = new Uint8Array(readFileSync('archive/Swf/age-of-war.swf'));
|
|
338
|
+
const { doc } = await parse(bytes, diag);
|
|
339
|
+
const { tags, symbolTable } = decode(doc, diag);
|
|
340
|
+
const { characters } = buildDisplayList(tags, symbolTable, diag);
|
|
341
|
+
const shaped = Object.values(characters).filter((c) => c.type === 'shape' && c.draws?.length);
|
|
342
|
+
expect(shaped.length).toBeGreaterThan(100);
|
|
343
|
+
expect(shaped[0].draws[0].path[0][0]).toBe('M');
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it('decodes drawable start and end states for Plazma Burst morphs', async () => {
|
|
347
|
+
const diag = new DiagnosticsCollector();
|
|
348
|
+
const bytes = new Uint8Array(readFileSync('archive/Swf/plazma-burst-2.swf'));
|
|
349
|
+
const { doc } = await parse(bytes, diag);
|
|
350
|
+
const { tags, symbolTable } = decode(doc, diag);
|
|
351
|
+
const { characters } = buildDisplayList(tags, symbolTable, diag);
|
|
352
|
+
const morphs = Object.values(characters).filter((c) => c.morph);
|
|
353
|
+
expect(morphs.length).toBeGreaterThan(0);
|
|
354
|
+
for (const morph of morphs) {
|
|
355
|
+
expect(morph.morph.startDraws.length).toBeGreaterThan(0);
|
|
356
|
+
expect(morph.morph.endDraws.length).toBe(morph.morph.startDraws.length);
|
|
357
|
+
expect(morph.morph.startDraws[0].path[0][0]).toBe('M');
|
|
358
|
+
}
|
|
359
|
+
expect(diag.warnings().filter((item) => item.message.includes('MorphShape'))).toHaveLength(0);
|
|
360
|
+
});
|
|
361
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { decodeShape } from '../decoder/shape-decoder.js';
|
|
3
|
+
import { generateTimelineEngine, unequalStrokeCaps } from '../transpiler/timeline/timeline-codegen.js';
|
|
4
|
+
|
|
5
|
+
function bitsToBytes(bits) {
|
|
6
|
+
const bytes = [];
|
|
7
|
+
for (let i = 0; i < bits.length; i += 8) {
|
|
8
|
+
bytes.push(parseInt(bits.slice(i, i + 8).padEnd(8, '0'), 2));
|
|
9
|
+
}
|
|
10
|
+
return bytes;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function zeroRect() {
|
|
14
|
+
// RECT with Nbits=1 and all four signed values set to zero.
|
|
15
|
+
return [0x08, 0x00];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function defineShape4LineStyle2(noHScale, noVScale, { noClose = true, edges = '11000010100' } = {}) {
|
|
19
|
+
const body = [1, 0, ...zeroRect(), ...zeroRect(), 0x01, 0, 1];
|
|
20
|
+
// One 2px line. Start/end cap square, miter join, fill style enabled,
|
|
21
|
+
// directional scaling flags, pixel hinting and noClose enabled.
|
|
22
|
+
body.push(40, 0);
|
|
23
|
+
const lineFlags = ['10', '10', '1', +noHScale, +noVScale, '1', '00000', +noClose, '10'].join('');
|
|
24
|
+
body.push(...bitsToBytes(lineFlags));
|
|
25
|
+
body.push(0x80, 0x02); // miter limit 640/256 = 2.5
|
|
26
|
+
body.push(0, 255, 32, 16, 255); // solid RGBA fill
|
|
27
|
+
body.push(0x01); // NumFillBits=0, NumLineBits=1
|
|
28
|
+
// Set line style 1, then a short straight edge.
|
|
29
|
+
body.push(...bitsToBytes('0010001' + edges + '000000'));
|
|
30
|
+
return new Uint8Array(body);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const signed6 = value => (value & 63).toString(2).padStart(6, '0');
|
|
34
|
+
const edge = (vertical, length) => '1101000' + Number(vertical) + signed6(length);
|
|
35
|
+
const moveTo = (x, y) => '00000100110' + signed6(x) + signed6(y);
|
|
36
|
+
|
|
37
|
+
describe('DefineShape4 LineStyle2', () => {
|
|
38
|
+
it.each([[true, false], [false, true]])(
|
|
39
|
+
'preserves cap, join, miter, fill, and independent %s/%s scaling flags',
|
|
40
|
+
(noHScale, noVScale) => {
|
|
41
|
+
const shape = decodeShape(defineShape4LineStyle2(noHScale, noVScale), 4);
|
|
42
|
+
expect(shape.draws).toHaveLength(1);
|
|
43
|
+
expect(shape.draws[0].stroke).toMatchObject({
|
|
44
|
+
width: 2,
|
|
45
|
+
color: '#ff2010',
|
|
46
|
+
fill: { type: 'solid', color: '#ff2010' },
|
|
47
|
+
startCap: 2,
|
|
48
|
+
endCap: 2,
|
|
49
|
+
joinStyle: 2,
|
|
50
|
+
miterLimit: 2.5,
|
|
51
|
+
noHScale,
|
|
52
|
+
noVScale,
|
|
53
|
+
pixelHinting: true,
|
|
54
|
+
noClose: true,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it.each([false, true])('keeps caps at a MoveTo even when consecutive runs meet (NoClose %s)', noClose => {
|
|
59
|
+
const edges = edge(false, 20) + moveTo(20, 0) + edge(true, 20);
|
|
60
|
+
const shape = decodeShape(defineShape4LineStyle2(false, false, { noClose, edges }), 4);
|
|
61
|
+
expect(shape.draws[0].path).toEqual([['M', 0, 0], ['L', 1, 0], ['M', 1, 0], ['L', 1, 1]]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('closes only when the last edge of the stroke returns to its start', () => {
|
|
65
|
+
const returningEdges = edge(false, 20) + edge(false, -20);
|
|
66
|
+
const open = decodeShape(defineShape4LineStyle2(false, false, {
|
|
67
|
+
noClose: false, edges: returningEdges + edge(true, 20),
|
|
68
|
+
}), 4);
|
|
69
|
+
const closed = decodeShape(defineShape4LineStyle2(false, false, {
|
|
70
|
+
noClose: false, edges: returningEdges,
|
|
71
|
+
}), 4);
|
|
72
|
+
const capped = decodeShape(defineShape4LineStyle2(false, false, { edges: returningEdges }), 4);
|
|
73
|
+
const edges = [['M', 0, 0], ['L', 1, 0], ['L', 0, 0]];
|
|
74
|
+
expect(open.draws[0].path).toEqual([...edges, ['L', 0, 1]]);
|
|
75
|
+
expect(closed.draws[0].path).toEqual([...edges, ['Z']]);
|
|
76
|
+
expect(capped.draws[0].path).toEqual(edges);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('emits Canvas mappings for SWF LineStyle2 caps, joins, miter, and fill', () => {
|
|
80
|
+
const engine = generateTimelineEngine({ frames: [], characters: {} }, {
|
|
81
|
+
frameRate: 24, frameCount: 1, stageW: 100, stageH: 100, backgroundColor: '#fff',
|
|
82
|
+
});
|
|
83
|
+
expect(engine).toContain("fillStyleFor(ctx, strokePlan.fill)");
|
|
84
|
+
expect(engine).toContain("startCap === 2 ? 'square'");
|
|
85
|
+
expect(engine).toContain("d.stroke.joinStyle === 1 ? 'bevel' : 'miter'");
|
|
86
|
+
expect(engine).toContain('ctx.miterLimit = d.stroke.miterLimit');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('uses decoded bitmap smoothing flags for fills and line fills', () => {
|
|
90
|
+
const layout = [
|
|
91
|
+
{ fill: { type: 'bitmap', bitmapId: 7, smoothed: true } },
|
|
92
|
+
{ stroke: { width: 1, fill: { type: 'bitmap', bitmapId: 7, smoothed: false } } },
|
|
93
|
+
{ stroke: { width: 1, fill: { type: 'bitmap', bitmapId: 7, smoothed: true } } },
|
|
94
|
+
].map(styles => ({ path: [['M', 0, 0], ['L', 10, 0], ['L', 10, 10], ['Z']], ...styles }));
|
|
95
|
+
const engine = generateTimelineEngine({
|
|
96
|
+
frames: [{ places: [{ depth: 1, characterId: 1 }] }],
|
|
97
|
+
characters: { 1: { type: 'shape', draws: layout } },
|
|
98
|
+
}, { frameCount: 1 });
|
|
99
|
+
const smoothing = [];
|
|
100
|
+
const ctx = {
|
|
101
|
+
imageSmoothingEnabled: true,
|
|
102
|
+
save() {}, restore() {}, fillRect() {}, setTransform() {},
|
|
103
|
+
createPattern() { return {}; },
|
|
104
|
+
fill() { smoothing.push(this.imageSmoothingEnabled); },
|
|
105
|
+
stroke() { smoothing.push(this.imageSmoothingEnabled); },
|
|
106
|
+
};
|
|
107
|
+
const runtime = { stage: { quality: 'high' } };
|
|
108
|
+
class Path2D { moveTo() {} lineTo() {} closePath() {} }
|
|
109
|
+
const render = new Function('ctx', 'Path2D', '__swoof_swflib', `
|
|
110
|
+
var BACKGROUND = '#fff', STAGE_WIDTH = 100, STAGE_HEIGHT = 100, FRAME_RATE = 24;
|
|
111
|
+
var loaded = { 7: {} };
|
|
112
|
+
${engine}
|
|
113
|
+
return () => timeline.render();
|
|
114
|
+
`)(ctx, Path2D, runtime);
|
|
115
|
+
render();
|
|
116
|
+
runtime.stage.quality = 'low';
|
|
117
|
+
render();
|
|
118
|
+
expect(smoothing).toEqual([true, false, true, false, false, false]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('draws separate outward square and round caps on open strokes', () => {
|
|
122
|
+
class RecordedPath {
|
|
123
|
+
lines = [];
|
|
124
|
+
arcs = [];
|
|
125
|
+
moveTo() {}
|
|
126
|
+
lineTo(...point) { this.lines.push(point); }
|
|
127
|
+
arc(...curve) { this.arcs.push(curve); }
|
|
128
|
+
closePath() {}
|
|
129
|
+
}
|
|
130
|
+
const build = new Function('Path2D', `return (${unequalStrokeCaps.toString()})`)(RecordedPath);
|
|
131
|
+
const line = [['M', 0, 0], ['L', 10, 0]];
|
|
132
|
+
const caps = build(line, 2, 0, 1);
|
|
133
|
+
expect(caps.lines).toEqual([[-1, 1], [-1, -1], [0, -1]]);
|
|
134
|
+
expect(caps.arcs).toEqual([[10, 0, 1, -Math.PI / 2, Math.PI / 2]]);
|
|
135
|
+
expect(build([...line, ['Z']], 2, 0, 1)).toBeNull();
|
|
136
|
+
expect(build(line, 2, 2, 1)).toBeNull();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { generateTimelineEngine, hitTestButtonRecords, prepareStrokeOutput } from '../transpiler/timeline/timeline-codegen.js';
|
|
3
|
+
import { hitTestAvm1ClipGeometry } from '../transpiler/avm1/avm1-transpiler.js';
|
|
4
|
+
|
|
5
|
+
describe('DefineShape2/4 non-scaling strokes', () => {
|
|
6
|
+
it('keeps both-axis no-scale stroke width fixed under rotated anisotropic transforms', () => {
|
|
7
|
+
const matrix = { a: 0, b: 3, c: -0.5, d: 0, tx: 400, ty: 200 };
|
|
8
|
+
const commands = [['M', 0, 0], ['L', 10, 0]];
|
|
9
|
+
const plan = prepareStrokeOutput({ width: 2.5, noHScale: true, noVScale: true }, commands, matrix);
|
|
10
|
+
|
|
11
|
+
expect(plan.outputSpace).toBe(true);
|
|
12
|
+
expect(plan.width).toBe(2.5);
|
|
13
|
+
expect(plan.commands).toEqual([['M', 20, 10], ['L', 20, 40]]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('transforms fill-based strokes into output space with their geometry', () => {
|
|
17
|
+
const matrix = { a: 2, b: 0, c: 0, d: 3, tx: 200, ty: 400 };
|
|
18
|
+
const fill = { type: 'linear', matrix: { a: 0.5, b: 0, c: 0, d: 0.5, tx: 4, ty: 5 }, stops: [] };
|
|
19
|
+
const plan = prepareStrokeOutput({ width: 1, noHScale: true, noVScale: true, fill }, [], matrix);
|
|
20
|
+
|
|
21
|
+
expect(plan.fill.matrix).toEqual({ a: 1, b: 0, c: 0, d: 1.5, tx: 18, ty: 35 });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it.each([
|
|
25
|
+
['noHScale', { noHScale: true, width: 2 }, 2, [0, 1, -0.5, 0, 20, 10], [[0, 0], [30, 0]], [1.5, 0, 0, 0.5, 12, 5]],
|
|
26
|
+
['noVScale', { noVScale: true, width: 2 }, 2, [0, 3, -1, 0, 20, 10], [[0, 0], [10, 0]], [0.5, 0, 0, 0.25, 4, 2.5]],
|
|
27
|
+
['hairline', { width: 0 }, 1, [1, 0, 0, 1, 0, 0], [[20, 10], [20, 40]], [0, 1.5, -0.25, 0, 17.5, 22]],
|
|
28
|
+
['hinted hairline', { width: 0, pixelHinting: true }, 1, [1, 0, 0, 1, 0, 0], [[20.5, 10], [20.5, 40]], [0, 1.5, -0.25, 0, 17.5, 22]],
|
|
29
|
+
])('paints authored %s strokes in pen space with a matching fill matrix', (_mode, style, width, pen, points, fillMatrix) => {
|
|
30
|
+
const matrix = { a: 0, b: 3, c: -0.5, d: 0, tx: 400, ty: 200 };
|
|
31
|
+
const fill = { type: 'bitmap', bitmapId: 4, repeat: true, smoothed: false,
|
|
32
|
+
matrix: { a: 0.5, b: 0, c: 0, d: 0.5, tx: 4, ty: 5 } };
|
|
33
|
+
const engine = generateTimelineEngine({
|
|
34
|
+
frames: [{ places: [{ depth: 1, characterId: 1, matrix }] }],
|
|
35
|
+
characters: { 1: { type: 'shape', draws: [{
|
|
36
|
+
stroke: { ...style, startCap: 1, endCap: 1, fill },
|
|
37
|
+
path: [['M', 0, 0], ['L', 10, 0]],
|
|
38
|
+
}] } },
|
|
39
|
+
}, { frameCount: 1 });
|
|
40
|
+
const strokes = [];
|
|
41
|
+
const context = {
|
|
42
|
+
save() {}, restore() {}, fillRect() {}, fillText() {},
|
|
43
|
+
setTransform(...value) { this.transform = value; },
|
|
44
|
+
createPattern() {
|
|
45
|
+
return { setTransform(value) { this.matrix = value.values; } };
|
|
46
|
+
},
|
|
47
|
+
stroke(path) {
|
|
48
|
+
strokes.push({
|
|
49
|
+
pen: this.transform, width: this.lineWidth, points: path.points, fillMatrix: this.strokeStyle.matrix,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const Path2D = class {
|
|
54
|
+
points = [];
|
|
55
|
+
moveTo(x, y) { this.points.push([x, y]); }
|
|
56
|
+
lineTo(x, y) { this.points.push([x, y]); }
|
|
57
|
+
};
|
|
58
|
+
const DOMMatrix = class { constructor(values) { this.values = values; } };
|
|
59
|
+
new Function('ctx', 'window', 'Path2D', 'DOMMatrix', 'document', `
|
|
60
|
+
var BACKGROUND = '#000', STAGE_WIDTH = 100, STAGE_HEIGHT = 100, FRAME_RATE = 24;
|
|
61
|
+
var loaded = { 4: {} };
|
|
62
|
+
${engine}
|
|
63
|
+
timeline.render();
|
|
64
|
+
`)(context, { __swoof: {} }, Path2D, DOMMatrix, undefined);
|
|
65
|
+
|
|
66
|
+
expect(strokes).toEqual([{ pen, width, points, fillMatrix }]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it.each([
|
|
70
|
+
['noHScale', [['M', 0, 0], ['L', 0, 10]], [17.5, 10.8], [17.5, 11.5], true],
|
|
71
|
+
['noVScale', [['M', 0, 0], ['L', 10, 0]], [20.8, 25], [21.2, 25], false],
|
|
72
|
+
])('uses authored %s pen geometry in nested button records and AVM1 shape hits',
|
|
73
|
+
(flag, path, inside, outside, normalReachesOutside) => {
|
|
74
|
+
const matrix = { a: 0, b: 3, c: -0.5, d: 0, tx: 400, ty: 200 };
|
|
75
|
+
const placement = { characterId: 1, matrix, depth: 1 };
|
|
76
|
+
const line = { width: 2, startCap: 1, endCap: 1 };
|
|
77
|
+
const characters = {
|
|
78
|
+
1: { type: 'shape', draws: [{ stroke: line, path }] },
|
|
79
|
+
2: { type: 'sprite', frames: [{ places: [placement] }] },
|
|
80
|
+
};
|
|
81
|
+
const buttonRecords = [{ characterId: 2, matrix: { a: 1, b: 0, c: 0, d: 1, tx: 100, ty: 0 } }];
|
|
82
|
+
const clip = { x: 5, _swoofCharacterId: 2 };
|
|
83
|
+
function hits(point) {
|
|
84
|
+
return [
|
|
85
|
+
hitTestButtonRecords(characters, buttonRecords, null, point[0] + 5, point[1]),
|
|
86
|
+
hitTestAvm1ClipGeometry(characters, clip, point[0] + 5, point[1]),
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
expect(hits(normalReachesOutside ? outside : inside)).toEqual([normalReachesOutside, normalReachesOutside]);
|
|
90
|
+
line[flag] = true;
|
|
91
|
+
expect(hits(inside)).toEqual([true, true]);
|
|
92
|
+
expect(hits(outside)).toEqual([false, false]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('hit tests one device pixel for authored hairlines under nested nonuniform scale', () => {
|
|
96
|
+
const matrix = { a: 0, b: 4, c: -3, d: 0, tx: 400, ty: 200 };
|
|
97
|
+
const characters = {
|
|
98
|
+
1: { type: 'shape', draws: [{
|
|
99
|
+
stroke: { width: 0, startCap: 1, endCap: 1 },
|
|
100
|
+
path: [['M', 0, 0], ['L', 10, 0]],
|
|
101
|
+
}] },
|
|
102
|
+
2: { type: 'sprite', frames: [{ places: [{ depth: 1, characterId: 1, matrix }] }] },
|
|
103
|
+
};
|
|
104
|
+
const clip = { _swoofCharacterId: 2 };
|
|
105
|
+
const records = [{ characterId: 2 }];
|
|
106
|
+
expect(hitTestButtonRecords(characters, records, null, 20.4, 30)).toBe(true);
|
|
107
|
+
expect(hitTestButtonRecords(characters, records, null, 20.6, 30)).toBe(false);
|
|
108
|
+
expect(hitTestAvm1ClipGeometry(characters, clip, 20.4, 30)).toBe(true);
|
|
109
|
+
expect(hitTestAvm1ClipGeometry(characters, clip, 20.6, 30)).toBe(false);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('hit tests only the shifted centerline of a hinted authored stroke', () => {
|
|
113
|
+
const characters = { 1: { type: 'shape', draws: [{
|
|
114
|
+
stroke: { width: 0.2, noVScale: true, pixelHinting: true, startCap: 1, endCap: 1 },
|
|
115
|
+
path: [['M', 0, 0], ['L', 10, 0]],
|
|
116
|
+
}] } };
|
|
117
|
+
const matrix = { a: 2, b: 0, c: 0, d: 3, tx: 0, ty: 12 };
|
|
118
|
+
const records = [{ characterId: 1, matrix }];
|
|
119
|
+
expect(hitTestButtonRecords(characters, records, null, 5, 1)).toBe(true);
|
|
120
|
+
expect(hitTestButtonRecords(characters, records, null, 5, 0.6)).toBe(false);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('emits identity-space stroke painting while ordinary strokes keep the object transform', () => {
|
|
124
|
+
const engine = generateTimelineEngine({ frames: [], characters: {} }, {
|
|
125
|
+
frameRate: 24, frameCount: 1, stageW: 320, stageH: 240, backgroundColor: '#000',
|
|
126
|
+
});
|
|
127
|
+
expect(engine).toContain('var strokePlan = prepareStrokeOutput(d.stroke, d.path, m, true);');
|
|
128
|
+
expect(engine).toContain('if (strokePlan.outputSpace) ctx.setTransform(1, 0, 0, 1, 0, 0);');
|
|
129
|
+
expect(engine).toContain('ctx.lineWidth = strokePlan.width;');
|
|
130
|
+
});
|
|
131
|
+
});
|