ranger-compiler 3.5.1 → 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1064 -20
- package/LICENSE +3 -1
- package/README.md +123 -28
- package/dist/Lang.rgr +1188 -290
- package/dist/api.d.ts +2343 -879
- package/dist/api.js +79923 -56921
- package/dist/lib/JSON.rgr +102 -91
- package/dist/lib/Shell.rgr +4 -4
- package/dist/lib/apple/AppleToolchain.rgr +4 -4
- package/dist/lib/apple/README.md +5 -4
- package/dist/lib/apple/apple_test.rgr +1 -1
- package/dist/lib/core/README.md +1 -1
- package/dist/lib/evg/EVG.rgr +12 -0
- package/dist/lib/evg/EVGA11yFromTree.rgr +302 -0
- package/dist/lib/evg/EVGA11yTree.rgr +894 -0
- package/dist/lib/evg/EVGBox.rgr +267 -0
- package/dist/lib/evg/EVGBoxShorthandTest.rgr +220 -0
- package/dist/lib/evg/EVGCodepoint.rgr +316 -0
- package/dist/lib/evg/EVGColor.rgr +700 -0
- package/dist/lib/evg/EVGCommands.rgr +177 -0
- package/dist/lib/evg/EVGComponent.rgr +331 -0
- package/dist/lib/evg/EVGComponentTest.rgr +387 -0
- package/dist/lib/evg/EVGConnector.rgr +541 -0
- package/dist/lib/evg/EVGConnectorTest.rgr +306 -0
- package/dist/lib/evg/EVGDisplayList.rgr +4186 -0
- package/dist/lib/evg/EVGEasing.rgr +370 -0
- package/dist/lib/evg/EVGEffectTest.rgr +253 -0
- package/dist/lib/evg/EVGElement.rgr +4914 -0
- package/dist/lib/evg/EVGFixedTest.rgr +289 -0
- package/dist/lib/evg/EVGFlexRulesTest.rgr +317 -0
- package/dist/lib/evg/EVGFlexWrapTest.rgr +246 -0
- package/dist/lib/evg/EVGFling.rgr +244 -0
- package/dist/lib/evg/EVGFocus.rgr +400 -0
- package/dist/lib/evg/EVGFocusTest.rgr +399 -0
- package/dist/lib/evg/EVGGradient.rgr +322 -0
- package/dist/lib/evg/EVGGrapheme.rgr +190 -0
- package/dist/lib/evg/EVGGrid.rgr +975 -0
- package/dist/lib/evg/EVGHitTest.rgr +208 -0
- package/dist/lib/evg/EVGHoles.rgr +294 -0
- package/dist/lib/evg/EVGHostMeasurerTest.rgr +281 -0
- package/dist/lib/evg/EVGHostTextMeasurer.rgr +331 -0
- package/dist/lib/evg/EVGHostTree.rgr +834 -0
- package/dist/lib/evg/EVGHostTreeTest.rgr +447 -0
- package/dist/lib/evg/EVGImageDecode.rgr +117 -0
- package/dist/lib/evg/EVGImageMeasurer.rgr +86 -0
- package/dist/lib/evg/EVGInspect.rgr +883 -0
- package/dist/lib/evg/EVGInvalidateTest.rgr +432 -0
- package/dist/lib/evg/EVGJsonTest.rgr +535 -0
- package/dist/lib/evg/EVGLayout.rgr +4220 -0
- package/dist/lib/evg/EVGMeasure.rgr +1267 -0
- package/dist/lib/evg/EVGOverlayTest.rgr +626 -0
- package/dist/lib/evg/EVGPatch.rgr +1721 -0
- package/dist/lib/evg/EVGPatchTest.rgr +692 -0
- package/dist/lib/evg/EVGPopoverTest.rgr +395 -0
- package/dist/lib/evg/EVGReconcile.rgr +226 -0
- package/dist/lib/evg/EVGReconcileTest.rgr +421 -0
- package/dist/lib/evg/EVGReject.rgr +126 -0
- package/dist/lib/evg/EVGRelayoutTest.rgr +375 -0
- package/dist/lib/evg/EVGRtlLayoutTest.rgr +319 -0
- package/dist/lib/evg/EVGRuler.rgr +232 -0
- package/dist/lib/evg/EVGRulerTest.rgr +172 -0
- package/dist/lib/evg/EVGSelectChrome.rgr +178 -0
- package/dist/lib/evg/EVGStyleCacheTest.rgr +419 -0
- package/dist/lib/evg/EVGStyleSheet.rgr +2148 -0
- package/dist/lib/evg/EVGStyleStateTest.rgr +407 -0
- package/dist/lib/evg/EVGStyleVarTest.rgr +471 -0
- package/dist/lib/evg/EVGText.rgr +105 -0
- package/dist/lib/evg/EVGTextEngine.rgr +536 -0
- package/dist/lib/evg/EVGTextMeasurer.rgr +720 -0
- package/dist/lib/evg/EVGTimingTest.rgr +1417 -0
- package/dist/lib/evg/EVGToolbar.rgr +1369 -0
- package/dist/lib/evg/EVGTransition.rgr +728 -0
- package/dist/lib/evg/EVGTreeJson.rgr +721 -0
- package/dist/lib/evg/EVGUnit.rgr +554 -0
- package/dist/lib/evg/EVGViewportUnitTest.rgr +236 -0
- package/dist/lib/evg/EvgApp.rgr +189 -0
- package/dist/lib/evg/EvgBitmapTracer.rgr +4277 -0
- package/dist/lib/evg/EvgBitmapTracerTest.rgr +2119 -0
- package/dist/lib/evg/EvgHost.rgr +451 -0
- package/dist/lib/evg/EvgTest.rgr +91 -0
- package/dist/lib/evg/EvgTraceColor.rgr +236 -0
- package/dist/lib/evg/EvgTraceCurve.rgr +648 -0
- package/dist/lib/evg/EvgTraceFit.rgr +767 -0
- package/dist/lib/evg/EvgTracePath.rgr +435 -0
- package/dist/lib/evg/EvgTraceTypes.rgr +559 -0
- package/dist/lib/evg/EvgViewport.rgr +313 -0
- package/dist/lib/evg/FxDemoDoc.rgr +185 -0
- package/dist/lib/evg/HOSTS.md +227 -0
- package/dist/lib/evg/ISSUES.md +835 -0
- package/dist/lib/evg/PLAN_ACCESSIBILITY.md +650 -0
- package/dist/lib/evg/PLAN_CSS_LAYOUT_AND_FONTS.md +1124 -0
- package/dist/lib/evg/PLAN_EFFECTS.md +431 -0
- package/dist/lib/evg/PLAN_EVG.md +518 -0
- package/dist/lib/evg/PLAN_EVG_RENDERER.md +1674 -0
- package/dist/lib/evg/PLAN_INSPECTOR.md +788 -0
- package/dist/lib/evg/PLAN_LINKS_AND_FORMS.md +157 -0
- package/dist/lib/evg/PLAN_NATIVE_HOSTS.md +671 -0
- package/dist/lib/evg/PLAN_VECTOR_IR.md +664 -0
- package/dist/lib/evg/PLAN_VIEW_TRANSFORM.md +322 -0
- package/dist/lib/evg/PathBuilder.rgr +333 -0
- package/dist/lib/evg/README.md +1236 -0
- package/dist/lib/evg/SPEC.md +1252 -0
- package/dist/lib/evg/SVGPathParser.rgr +1199 -0
- package/dist/lib/evg/SvgParser.rgr +1736 -0
- package/dist/lib/evg/TODO_EVG_RENDERER.md +595 -0
- package/dist/lib/evg/VectorShapes.rgr +331 -0
- package/dist/lib/evg/VectorStroke.rgr +107 -0
- package/dist/lib/evg/VectorViewBox.rgr +380 -0
- package/dist/lib/evg/agent/README.md +290 -0
- package/dist/lib/evg/agent/evg_agent.rgr +899 -0
- package/dist/lib/evg/agent/fixtures/broken.evg.json +7 -0
- package/dist/lib/evg/agent/fixtures/card.evg.json +9 -0
- package/dist/lib/evg/agent/fixtures/connector.css +63 -0
- package/dist/lib/evg/agent/fixtures/connector.evg.json +14 -0
- package/dist/lib/evg/agent/fixtures/drawn.evg.json +129 -0
- package/dist/lib/evg/agent/fixtures/gradient.evg.json +4 -0
- package/dist/lib/evg/agent/fixtures/popover.css +99 -0
- package/dist/lib/evg/agent/fixtures/popover.evg.json +30 -0
- package/dist/lib/evg/agent/roundtrip.sh +74 -0
- package/dist/lib/evg/agent/smoke.sh +230 -0
- package/dist/lib/evg/android/README.md +97 -0
- package/dist/lib/evg/android/androidstubs/AndroidStubs.kt +175 -0
- package/dist/lib/evg/android/androidstubs/Annotation.kt +10 -0
- package/dist/lib/evg/android/androidstubs/App.kt +30 -0
- package/dist/lib/evg/android/androidstubs/Content.kt +41 -0
- package/dist/lib/evg/android/androidstubs/ContentRes.kt +12 -0
- package/dist/lib/evg/android/androidstubs/InputMethod.kt +46 -0
- package/dist/lib/evg/android/androidstubs/Net.kt +6 -0
- package/dist/lib/evg/android/androidstubs/Os.kt +30 -0
- package/dist/lib/evg/android/androidstubs/Util.kt +15 -0
- package/dist/lib/evg/android/androidstubs/View.kt +113 -0
- package/dist/lib/evg/android/androidstubs/Widget.kt +16 -0
- package/dist/lib/evg/android/src/android/kotlin/fi/ranger/evg/AndroidEvgSurface.kt +323 -0
- package/dist/lib/evg/android/src/android/kotlin/fi/ranger/evg/AndroidTextMeasurer.kt +56 -0
- package/dist/lib/evg/android/src/android/kotlin/fi/ranger/evg/RippleEffect.kt +262 -0
- package/dist/lib/evg/android/src/awt/kotlin/fi/ranger/evg/AwtEvgSurface.kt +238 -0
- package/dist/lib/evg/android/src/awt/kotlin/fi/ranger/evg/AwtTextMeasurer.kt +85 -0
- package/dist/lib/evg/android/src/main/kotlin/fi/ranger/evg/EvgEngineThread.kt +115 -0
- package/dist/lib/evg/android/src/main/kotlin/fi/ranger/evg/EvgPainter.kt +231 -0
- package/dist/lib/evg/android/src/main/kotlin/fi/ranger/evg/EvgSurface.kt +117 -0
- package/dist/lib/evg/android/src/main/kotlin/fi/ranger/evg/RecordingSurface.kt +94 -0
- package/dist/lib/evg/apple/README.md +128 -0
- package/dist/lib/evg/apple/Sources/CoreGraphicsEvgSurface.swift +329 -0
- package/dist/lib/evg/apple/Sources/CoreTextMeasurer.swift +70 -0
- package/dist/lib/evg/apple/Sources/EvgEngineQueue.swift +105 -0
- package/dist/lib/evg/apple/Sources/EvgPainter.swift +225 -0
- package/dist/lib/evg/apple/Sources/EvgSurface.swift +163 -0
- package/dist/lib/evg/apple/Sources/RecordingSurface.swift +110 -0
- package/dist/lib/evg/bench/EvgLayoutBench.rgr +34 -0
- package/dist/lib/evg/bench/README.md +64 -0
- package/dist/lib/evg/bench/layout-bench.mjs +316 -0
- package/dist/lib/evg/bench/layout-cases.mjs +510 -0
- package/dist/lib/evg/bench/layout-conformance.mjs +254 -0
- package/dist/lib/evg/bin/.gitignore +17 -0
- package/dist/lib/evg/evg_test.rgr +313 -0
- package/dist/lib/evg/gl/README.md +198 -0
- package/dist/lib/evg/gl/a11y-paint-check.mjs +73 -0
- package/dist/lib/evg/gl/blur-check.mjs +399 -0
- package/dist/lib/evg/gl/boxmodel.json +1 -0
- package/dist/lib/evg/gl/demo.html +46 -0
- package/dist/lib/evg/gl/effect-presets.css +285 -0
- package/dist/lib/evg/gl/effect-presets.js +63 -0
- package/dist/lib/evg/gl/effect-shots.mjs +135 -0
- package/dist/lib/evg/gl/evg-a11y.js +566 -0
- package/dist/lib/evg/gl/evg-binary.js +160 -0
- package/dist/lib/evg/gl/evg-engine.js +296 -0
- package/dist/lib/evg/gl/evg-fx.js +237 -0
- package/dist/lib/evg/gl/evg-gestures.js +209 -0
- package/dist/lib/evg/gl/evg-list.js +167 -0
- package/dist/lib/evg/gl/evg-measure.js +186 -0
- package/dist/lib/evg/gl/evg-textinput.js +303 -0
- package/dist/lib/evg/gl/evg-view.js +144 -0
- package/dist/lib/evg/gl/evg-webgl.js +3942 -0
- package/dist/lib/evg/gl/fx-check.mjs +998 -0
- package/dist/lib/evg/gl/fx-demo.html +166 -0
- package/dist/lib/evg/gl/fx-demo.js +2 -0
- package/dist/lib/evg/gl/fx-serve.mjs +47 -0
- package/dist/lib/evg/gl/gestures-check.mjs +189 -0
- package/dist/lib/evg/gl/list-binary-check.mjs +152 -0
- package/dist/lib/evg/gl/measure-check.mjs +135 -0
- package/dist/lib/evg/gl/rotation-check.mjs +207 -0
- package/dist/lib/evg/gl/shift-check.mjs +113 -0
- package/dist/lib/evg/gl/stroke-check.mjs +168 -0
- package/dist/lib/evg/gl/text-snap-check.mjs +139 -0
- package/dist/lib/evg/gl/view-check.mjs +343 -0
- package/dist/lib/evg/gl/view-policy-check.mjs +184 -0
- package/dist/lib/evg/html/evg-dom.js +318 -0
- package/dist/lib/evg/html/evg-html.js +600 -0
- package/dist/lib/evg/inspect/README.md +415 -0
- package/dist/lib/evg/inspect/browser-smoke.mjs +115 -0
- package/dist/lib/evg/inspect/evg-inspect.js +947 -0
- package/dist/lib/evg/inspect/shots/css.png +0 -0
- package/dist/lib/evg/inspect/shots/dashboard.png +0 -0
- package/dist/lib/evg/inspect/shots/pptx-slide.png +0 -0
- package/dist/lib/evg/inspect/shots/state.png +0 -0
- package/dist/lib/evg/inspect/shots.mjs +226 -0
- package/dist/lib/evg/oracle/css-blur.json +576 -0
- package/dist/lib/evg/oracle/css-box.json +157 -0
- package/dist/lib/evg/oracle/css-timing.json +709 -0
- package/dist/lib/evg/oracle/css_blur_oracle.mjs +529 -0
- package/dist/lib/evg/oracle/css_box_oracle.mjs +106 -0
- package/dist/lib/evg/oracle/css_timing_oracle.mjs +389 -0
- package/dist/lib/evg/original/EVGColor.clj +310 -0
- package/dist/lib/evg/original/EVGColorContext.rgr +178 -0
- package/dist/lib/evg/original/SVGPath.rgr +627 -0
- package/dist/lib/evg/original/Vec2.crgr +103 -0
- package/dist/lib/evg/ranger.json +9 -0
- package/dist/lib/evg/showcase/README.md +246 -0
- package/dist/lib/evg/showcase/assets/emblem.svg +30 -0
- package/dist/lib/evg/showcase/assets/rosette.svg +22 -0
- package/dist/lib/evg/showcase/build.mjs +651 -0
- package/dist/lib/evg/showcase/pages/album.tsx +30 -0
- package/dist/lib/evg/showcase/pages/boxmodel.tsx +37 -0
- package/dist/lib/evg/showcase/pages/cards.tsx +41 -0
- package/dist/lib/evg/showcase/pages/chart_api.tsx +170 -0
- package/dist/lib/evg/showcase/pages/charts.tsx +219 -0
- package/dist/lib/evg/showcase/pages/drawing.tsx +160 -0
- package/dist/lib/evg/showcase/pages/emoji.tsx +91 -0
- package/dist/lib/evg/showcase/pages/flex.tsx +46 -0
- package/dist/lib/evg/showcase/pages/more.tsx +332 -0
- package/dist/lib/evg/showcase/pages/plots.tsx +262 -0
- package/dist/lib/evg/showcase/pages/svg.tsx +63 -0
- package/dist/lib/evg/showcase/pages/tables.tsx +209 -0
- package/dist/lib/evg/showcase/pages/typography.tsx +43 -0
- package/dist/lib/evg/showcase/pages/units.tsx +35 -0
- package/dist/lib/evg/showcase/pages/variants.tsx +233 -0
- package/dist/lib/evg/showcase/pages/vector.tsx +75 -0
- package/dist/lib/evg/showcase/pages/views.tsx +223 -0
- package/dist/lib/evg/showcase/tests/chart_api_smoke.mjs +339 -0
- package/dist/lib/evg/showcase/tests/gl_smoke.mjs +125 -0
- package/dist/lib/evg/showcase/themes/chart_api-default.css +15 -0
- package/dist/lib/evg/showcase/themes/charts-default.css +29 -0
- package/dist/lib/evg/showcase/themes/drawing-default.css +35 -0
- package/dist/lib/evg/showcase/themes/more-default.css +128 -0
- package/dist/lib/evg/showcase/themes/plots-default.css +18 -0
- package/dist/lib/evg/showcase/themes/showcase.css +508 -0
- package/dist/lib/evg/showcase/themes/tables-default.css +123 -0
- package/dist/lib/evg/showcase/themes/variants-default.css +15 -0
- package/dist/lib/evg/showcase/themes/views-default.css +15 -0
- package/dist/lib/evg/tools/bench_vs_potrace.mjs +290 -0
- package/dist/lib/evg/tools/evg_image_tool.rgr +488 -0
- package/dist/lib/evg/tools/evg_trace_bench.rgr +114 -0
- package/dist/lib/evg/tools/evg_trace_cli.rgr +662 -0
- package/dist/lib/evg/tools/evg_trace_cpp_bench.rgr +83 -0
- package/dist/lib/evg/tools/run_trace_bench.sh +74 -0
- package/dist/lib/evg/tools/run_trace_cli_smoke.sh +128 -0
- package/dist/lib/evg/web/responsive/EvgResponsiveCheck.rgr +271 -0
- package/dist/lib/evg/web/responsive/EvgResponsiveDemo.rgr +531 -0
- package/dist/lib/evg/web/responsive/README.md +97 -0
- package/dist/lib/evg/web/responsive/build.mjs +90 -0
- package/dist/lib/evg/web/responsive/dom-check.mjs +169 -0
- package/dist/lib/evg/web/responsive/index.html +177 -0
- package/dist/lib/evg/web/responsive/smoke.mjs +221 -0
- package/dist/lib/evg/web/tools/assets-client.mjs +95 -0
- package/dist/lib/evg/web/tools/boot-bench.mjs +189 -0
- package/dist/lib/evg/web/tools/inline-assets.mjs +119 -0
- package/dist/lib/evg/web/tools/minify.mjs +60 -0
- package/dist/lib/evg/web/tracer/build.mjs +87 -0
- package/dist/lib/evg/web/tracer/index.html +2805 -0
- package/dist/lib/evg/web/tracer/sample.png +0 -0
- package/dist/lib/evg/web/tracer/smoke.mjs +1162 -0
- package/dist/lib/evgr/Cargo.lock +21 -0
- package/dist/lib/evgr/Cargo.toml +19 -0
- package/dist/lib/evgr/README.md +140 -0
- package/dist/lib/evgr/bench/NativeBench.rgr +246 -0
- package/dist/lib/evgr/bench/compare.mjs +252 -0
- package/dist/lib/evgr/bench/speed.mjs +277 -0
- package/dist/lib/evgr/bin/.gitignore +3 -0
- package/dist/lib/evgr/src/bin/bench.rs +106 -0
- package/dist/lib/evgr/src/bin/smoke.rs +13 -0
- package/dist/lib/evgr/src/grid.rs +730 -0
- package/dist/lib/evgr/src/lib.rs +1003 -0
- package/dist/lib/evgr/src/style.rs +468 -0
- package/dist/lib/evgr/src/text.rs +83 -0
- package/dist/lib/image/BitReader.rgr +171 -0
- package/dist/lib/image/Buffer.rgr +173 -0
- package/dist/lib/image/DCT.rgr +283 -0
- package/dist/lib/image/Deflate.rgr +339 -0
- package/dist/lib/image/HuffmanDecoder.rgr +181 -0
- package/dist/lib/image/ImageBuffer.rgr +706 -0
- package/dist/lib/image/JPEGDecoder.rgr +808 -0
- package/dist/lib/image/PNGDecoder.rgr +544 -0
- package/dist/lib/image/PNGEncoder.rgr +388 -0
- package/dist/lib/image/PPMImage.rgr +224 -0
- package/dist/lib/image/ProgressiveJPEGDecoder.rgr +1154 -0
- package/dist/lib/image/README.md +33 -0
- package/dist/lib/image/RasterBuffer.rgr +294 -0
- package/dist/lib/image/VP8BoolDecoder.rgr +163 -0
- package/dist/lib/image/WebPDecoder.rgr +433 -0
- package/dist/lib/image/WebPLossless.rgr +1035 -0
- package/dist/lib/image/WebPLossy.rgr +1929 -0
- package/dist/lib/image/ranger.json +9 -0
- package/dist/lib/image/testdata/webp/anim_2f_24x16.webp +0 -0
- package/dist/lib/image/testdata/webp/fixtures.txt +33 -0
- package/dist/lib/image/testdata/webp/gen_fixtures.py +261 -0
- package/dist/lib/image/testdata/webp/ll_1x1.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_alpha_29x21.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_gradient_64x64.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_meta_32x32.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_noise_17x9.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_pal11_23x11.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_pal2_19x7.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_pal40_16x16.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_pal4_13x5.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_photo_40x30.webp +0 -0
- package/dist/lib/image/testdata/webp/ll_predictors_64x32.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_1x1.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_alph_raw_f0_21x13.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_alph_raw_f1_21x13.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_alph_raw_f2_21x13.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_alph_raw_f3_21x13.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_alph_vp8l_f0_21x13.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_alph_vp8l_f1_21x13.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_alph_vp8l_f2_21x13.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_alph_vp8l_f3_21x13.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_alpha_33x17.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_exif_15x11.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_i16_96x80.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_nofilter_24x20.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_odd_17x9.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_photo_48x40.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_q100_20x18.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_sharp_40x36.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_simple_filter_33x31.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_vpx_parts8_37x45.webp +0 -0
- package/dist/lib/image/testdata/webp/ly_vpx_skip_96x80.webp +0 -0
- package/dist/lib/image/tests/WebPDecodeTool.rgr +81 -0
- package/dist/lib/image/tests/WebPDecoderTest.rgr +1162 -0
- package/dist/lib/image/tests/run_webp_tests.sh +39 -0
- package/dist/lib/rust/RsJson.rgr +468 -0
- package/dist/lib/rust/RsPrelude.rgr +1663 -0
- package/dist/lib/shell_test.rgr +7 -7
- package/dist/lib/stdlib.rgr +21 -5
- package/dist/lib/zip/ranger.json +6 -0
- package/dist/rgrc.js +87318 -67610
- package/package.json +1010 -1040
- package/dist/README.md +0 -117
- package/dist/package.json +0 -47
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
; SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
; ==============================================================================
|
|
4
|
+
; EVGFlexWrapTest — a row must not wrap because of its own arithmetic
|
|
5
|
+
; ==============================================================================
|
|
6
|
+
;
|
|
7
|
+
; The case, which is the commonest two-column layout there is:
|
|
8
|
+
;
|
|
9
|
+
; .body { display: flex; gap: 24px } ; wrap allowed — the default here
|
|
10
|
+
; .side { width: 240px }
|
|
11
|
+
; .main { flex: 1 }
|
|
12
|
+
;
|
|
13
|
+
; `.main`'s width is computed BY THE LAYOUT out of the same line it is then
|
|
14
|
+
; measured against: take the inner width, subtract the sidebar and the gap, and
|
|
15
|
+
; the remainder is `.main`. Adding those three back up is not guaranteed to
|
|
16
|
+
; return the number they were subtracted from — in binary floating point
|
|
17
|
+
; `(a - b - c) + b + c` can land one ulp above `a` — and the wrap test then
|
|
18
|
+
; reads the row as too wide for itself and puts `.main` on a second line.
|
|
19
|
+
;
|
|
20
|
+
; It is not a rare case. Before the tolerance went into `EVGLayout`, the page in
|
|
21
|
+
; `lib/evg/web/responsive` wrapped at 127 of the 680 integer window widths
|
|
22
|
+
; between 821 and 1500, scattered rather than in a band: dragging the window
|
|
23
|
+
; edge dropped the content below the sidebar and pulled it back up a pixel
|
|
24
|
+
; later, over and over. That is what this file is here to stop coming back.
|
|
25
|
+
;
|
|
26
|
+
; --- WHAT IS ACTUALLY ASSERTED ------------------------------------------------
|
|
27
|
+
;
|
|
28
|
+
; Three things, in the order that matters:
|
|
29
|
+
;
|
|
30
|
+
; 1. Across a fine sweep of widths — including fractional ones, because a
|
|
31
|
+
; device pixel ratio and a `vw` padding both produce them — the two boxes
|
|
32
|
+
; stay on the same line. One width would prove nothing; the defect was
|
|
33
|
+
; that SOME widths failed.
|
|
34
|
+
; 2. A row that genuinely does not fit still wraps. A tolerance that stops
|
|
35
|
+
; every wrap would pass test 1 and be worse than the bug.
|
|
36
|
+
; 3. `flex-wrap: nowrap` still means nowrap.
|
|
37
|
+
; ==============================================================================
|
|
38
|
+
|
|
39
|
+
Import "EVGElement.rgr"
|
|
40
|
+
Import "EVGUnit.rgr"
|
|
41
|
+
Import "EVGLayout.rgr"
|
|
42
|
+
Import "EVGStyleSheet.rgr"
|
|
43
|
+
|
|
44
|
+
class FlexWrapCheck {
|
|
45
|
+
def passed:int 0
|
|
46
|
+
def failed:int 0
|
|
47
|
+
|
|
48
|
+
Constructor () {
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fn ok:void (name:string cond:boolean) {
|
|
52
|
+
if cond {
|
|
53
|
+
passed = (passed + 1)
|
|
54
|
+
print (" PASS " + name)
|
|
55
|
+
} {
|
|
56
|
+
failed = (failed + 1)
|
|
57
|
+
print (" FAIL " + name)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
; A page with `4vw` side padding — the padding matters, because it is what
|
|
62
|
+
; makes the inner width fractional and therefore makes the sum that has to
|
|
63
|
+
; come back out exact.
|
|
64
|
+
fn build:EVGElement (sideWidth:string mainFlex:string wrap:string) {
|
|
65
|
+
def page (EVGElement.createDiv())
|
|
66
|
+
page.className = "page"
|
|
67
|
+
page.setAttribute("display" "flex")
|
|
68
|
+
page.setAttribute("flex-direction" "column")
|
|
69
|
+
page.setAttribute("padding-left" "4vw")
|
|
70
|
+
page.setAttribute("padding-right" "4vw")
|
|
71
|
+
|
|
72
|
+
def body (EVGElement.createDiv())
|
|
73
|
+
body.className = "body"
|
|
74
|
+
body.setAttribute("display" "flex")
|
|
75
|
+
body.setAttribute("flex-direction" "row")
|
|
76
|
+
body.setAttribute("gap" "24px")
|
|
77
|
+
if ((strlen wrap) > 0) {
|
|
78
|
+
body.setAttribute("flex-wrap" wrap)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
def side (EVGElement.createDiv())
|
|
82
|
+
side.className = "side"
|
|
83
|
+
side.setAttribute("width" sideWidth)
|
|
84
|
+
side.setAttribute("height" "300px")
|
|
85
|
+
|
|
86
|
+
def main (EVGElement.createDiv())
|
|
87
|
+
main.className = "main"
|
|
88
|
+
main.setAttribute("flex" mainFlex)
|
|
89
|
+
main.setAttribute("height" "300px")
|
|
90
|
+
|
|
91
|
+
body.addChild(side)
|
|
92
|
+
body.addChild(main)
|
|
93
|
+
page.addChild(body)
|
|
94
|
+
return page
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fn childAt:EVGElement (root:EVGElement a:int b:int) {
|
|
98
|
+
def outer:EVGElement (root.getChild(a))
|
|
99
|
+
return (outer.getChild(b))
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
; True when the two children of `.body` sit on one line.
|
|
103
|
+
fn sameRow:boolean (root:EVGElement) {
|
|
104
|
+
def side:EVGElement (this.childAt(root 0 0))
|
|
105
|
+
def main:EVGElement (this.childAt(root 0 1))
|
|
106
|
+
def dy:double (main.calculatedY - side.calculatedY)
|
|
107
|
+
if (dy < 0.0) {
|
|
108
|
+
dy = (0.0 - dy)
|
|
109
|
+
}
|
|
110
|
+
return (dy < 1.0)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
fn layoutAt:EVGElement (root:EVGElement w:double) {
|
|
114
|
+
def lay (new EVGLayout())
|
|
115
|
+
lay.setPageSize(w 900.0)
|
|
116
|
+
lay.layout(root)
|
|
117
|
+
return root
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
fn run:void () {
|
|
121
|
+
print "EVGFlexWrapTest"
|
|
122
|
+
|
|
123
|
+
; --- 1. the sweep -----------------------------------------------------
|
|
124
|
+
;
|
|
125
|
+
; 0.25px steps so fractional widths are covered too. Every failure is
|
|
126
|
+
; named — a count alone would not say whether the tolerance is slightly
|
|
127
|
+
; short or missing entirely.
|
|
128
|
+
def wrapped:int 0
|
|
129
|
+
def shown:int 0
|
|
130
|
+
def w:double 400.0
|
|
131
|
+
while (w <= 1800.0) {
|
|
132
|
+
def root:EVGElement (this.build("240px" "1" ""))
|
|
133
|
+
this.layoutAt(root w)
|
|
134
|
+
if ((this.sameRow(root)) == false) {
|
|
135
|
+
wrapped = (wrapped + 1)
|
|
136
|
+
if (shown < 8) {
|
|
137
|
+
shown = (shown + 1)
|
|
138
|
+
print (" wrapped at width " + (to_string w))
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
w = (w + 0.25)
|
|
142
|
+
}
|
|
143
|
+
this.ok("a 240px sidebar and a flex:1 panel stay on one line at every width"
|
|
144
|
+
(wrapped == 0))
|
|
145
|
+
|
|
146
|
+
; The same, with the sidebar in a unit that does not divide evenly.
|
|
147
|
+
def wrapped2:int 0
|
|
148
|
+
def w2:double 400.0
|
|
149
|
+
while (w2 <= 1200.0) {
|
|
150
|
+
def root2:EVGElement (this.build("33.3333%" "1" ""))
|
|
151
|
+
this.layoutAt(root2 w2)
|
|
152
|
+
if ((this.sameRow(root2)) == false) {
|
|
153
|
+
wrapped2 = (wrapped2 + 1)
|
|
154
|
+
}
|
|
155
|
+
w2 = (w2 + 0.25)
|
|
156
|
+
}
|
|
157
|
+
this.ok("a percentage sidebar and a flex:1 panel stay on one line"
|
|
158
|
+
(wrapped2 == 0))
|
|
159
|
+
|
|
160
|
+
; --- 2. a row that really does not fit still wraps ---------------------
|
|
161
|
+
;
|
|
162
|
+
; Two fixed children whose declared widths exceed the line by whole
|
|
163
|
+
; pixels. Nothing here is a rounding artifact, so the wrap must happen.
|
|
164
|
+
def big (EVGElement.createDiv())
|
|
165
|
+
big.className = "page"
|
|
166
|
+
big.setAttribute("display" "flex")
|
|
167
|
+
def row (EVGElement.createDiv())
|
|
168
|
+
row.setAttribute("display" "flex")
|
|
169
|
+
row.setAttribute("flex-direction" "row")
|
|
170
|
+
def a (EVGElement.createDiv())
|
|
171
|
+
a.setAttribute("width" "400px")
|
|
172
|
+
a.setAttribute("height" "50px")
|
|
173
|
+
def b (EVGElement.createDiv())
|
|
174
|
+
b.setAttribute("width" "400px")
|
|
175
|
+
b.setAttribute("height" "50px")
|
|
176
|
+
row.addChild(a)
|
|
177
|
+
row.addChild(b)
|
|
178
|
+
big.addChild(row)
|
|
179
|
+
def lay2 (new EVGLayout())
|
|
180
|
+
lay2.setPageSize(600.0 900.0)
|
|
181
|
+
lay2.layout(big)
|
|
182
|
+
this.ok("two 400px boxes on a 600px line still wrap"
|
|
183
|
+
((b.calculatedY - a.calculatedY) > 1.0))
|
|
184
|
+
|
|
185
|
+
; And one that misses by a single whole pixel, which is the smallest
|
|
186
|
+
; overflow that is a layout rather than an artifact.
|
|
187
|
+
def big2 (EVGElement.createDiv())
|
|
188
|
+
big2.setAttribute("display" "flex")
|
|
189
|
+
def row2 (EVGElement.createDiv())
|
|
190
|
+
row2.setAttribute("display" "flex")
|
|
191
|
+
row2.setAttribute("flex-direction" "row")
|
|
192
|
+
def c (EVGElement.createDiv())
|
|
193
|
+
c.setAttribute("width" "300px")
|
|
194
|
+
c.setAttribute("height" "50px")
|
|
195
|
+
def d (EVGElement.createDiv())
|
|
196
|
+
d.setAttribute("width" "301px")
|
|
197
|
+
d.setAttribute("height" "50px")
|
|
198
|
+
row2.addChild(c)
|
|
199
|
+
row2.addChild(d)
|
|
200
|
+
big2.addChild(row2)
|
|
201
|
+
def lay3 (new EVGLayout())
|
|
202
|
+
lay3.setPageSize(600.0 900.0)
|
|
203
|
+
lay3.layout(big2)
|
|
204
|
+
this.ok("300px + 301px on a 600px line wraps"
|
|
205
|
+
((d.calculatedY - c.calculatedY) > 1.0))
|
|
206
|
+
|
|
207
|
+
; --- 3. nowrap still means nowrap --------------------------------------
|
|
208
|
+
def nw (EVGElement.createDiv())
|
|
209
|
+
nw.setAttribute("display" "flex")
|
|
210
|
+
def row3 (EVGElement.createDiv())
|
|
211
|
+
row3.setAttribute("display" "flex")
|
|
212
|
+
row3.setAttribute("flex-direction" "row")
|
|
213
|
+
row3.setAttribute("flex-wrap" "nowrap")
|
|
214
|
+
def e (EVGElement.createDiv())
|
|
215
|
+
e.setAttribute("width" "400px")
|
|
216
|
+
e.setAttribute("height" "50px")
|
|
217
|
+
def f (EVGElement.createDiv())
|
|
218
|
+
f.setAttribute("width" "400px")
|
|
219
|
+
f.setAttribute("height" "50px")
|
|
220
|
+
row3.addChild(e)
|
|
221
|
+
row3.addChild(f)
|
|
222
|
+
nw.addChild(row3)
|
|
223
|
+
def lay4 (new EVGLayout())
|
|
224
|
+
lay4.setPageSize(600.0 900.0)
|
|
225
|
+
lay4.layout(nw)
|
|
226
|
+
def dy4:double (f.calculatedY - e.calculatedY)
|
|
227
|
+
if (dy4 < 0.0) {
|
|
228
|
+
dy4 = (0.0 - dy4)
|
|
229
|
+
}
|
|
230
|
+
this.ok("flex-wrap: nowrap keeps two overflowing boxes on one line"
|
|
231
|
+
(dy4 < 1.0))
|
|
232
|
+
|
|
233
|
+
print ""
|
|
234
|
+
print ((("Passed: " + (to_string passed)) + " Failed: ") + (to_string failed))
|
|
235
|
+
if (failed > 0) {
|
|
236
|
+
print "FAILED"
|
|
237
|
+
} {
|
|
238
|
+
print "OK"
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
sfn m@(main):void () {
|
|
243
|
+
def c (new FlexWrapCheck())
|
|
244
|
+
c.run()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
; SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
; ==============================================================================
|
|
4
|
+
; EVGFling — a finger that leaves the glass moving is still scrolling
|
|
5
|
+
; ==============================================================================
|
|
6
|
+
;
|
|
7
|
+
; A drag that stops when the finger lifts is the difference between a page that
|
|
8
|
+
; feels like a phone and one that feels like a spreadsheet. What a phone does
|
|
9
|
+
; is simple and worth stating exactly, because every part of it is a decision:
|
|
10
|
+
;
|
|
11
|
+
; THE SPEED IS MEASURED OVER A WINDOW, not from the last two points. The last
|
|
12
|
+
; sample before a lift is very often a slow one — a finger decelerates on the
|
|
13
|
+
; glass in the few milliseconds before it leaves — and a fling taken from it
|
|
14
|
+
; is a fling that barely moves. So the last few samples inside `windowMs` are
|
|
15
|
+
; summed and the speed is the total distance over the total time.
|
|
16
|
+
;
|
|
17
|
+
; IT DECAYS IN PROPORTION TO ITSELF, which makes the distance travelled
|
|
18
|
+
; exactly proportional to the speed of the throw: a swipe twice as fast goes
|
|
19
|
+
; twice as far. That is the property being asked for, and it falls out of
|
|
20
|
+
; the decay rather than being a rule on top of it — the total is
|
|
21
|
+
; `velocity / friction`, and at the default that is four hundred times the
|
|
22
|
+
; speed in pixels per millisecond, so a firm 3 px/ms flick carries about
|
|
23
|
+
; 1200 pixels, a page and a half of a phone.
|
|
24
|
+
;
|
|
25
|
+
; The step is `v - v*friction*dt` and not `v * decay^dt`, because Ranger has
|
|
26
|
+
; no `pow` and does not need one here: over a frame `friction*dt` is between
|
|
27
|
+
; 0.02 and 0.08, where the two agree to a tenth of a percent. The factor is
|
|
28
|
+
; clamped so a very long frame — a tab coming back to the foreground — stops
|
|
29
|
+
; the page rather than throwing it backwards.
|
|
30
|
+
;
|
|
31
|
+
; IT IS DRIVEN BY THE REAL FRAME TIME. `step(dtMs)` asks for a distance, so a
|
|
32
|
+
; dropped frame moves further rather than slowing the page down; nothing here
|
|
33
|
+
; assumes sixty of anything.
|
|
34
|
+
;
|
|
35
|
+
; It scrolls nothing itself. `step` returns a distance and the caller decides
|
|
36
|
+
; what it means, which is what lets the same object serve a browser's wheel
|
|
37
|
+
; handler, a UIPanGestureRecognizer and a headless check.
|
|
38
|
+
; ==============================================================================
|
|
39
|
+
|
|
40
|
+
class EVGFling {
|
|
41
|
+
; The samples still inside the window: how far, and over how long.
|
|
42
|
+
def dys:[double]
|
|
43
|
+
def dts:[double]
|
|
44
|
+
; What the page is doing now, in pixels per millisecond. Zero is stopped.
|
|
45
|
+
def velocity:double 0.0
|
|
46
|
+
|
|
47
|
+
; --- the numbers, and why they are these numbers --------------------------
|
|
48
|
+
;
|
|
49
|
+
; The fraction of the speed lost per millisecond. Higher stops sooner.
|
|
50
|
+
;
|
|
51
|
+
; 0.002 is a total distance of five hundred times the speed in pixels per
|
|
52
|
+
; millisecond, and a glide of about two seconds. In the sizes a phone
|
|
53
|
+
; actually produces: an idle drag of 0.5 px/ms carries 250 pixels, a
|
|
54
|
+
; normal swipe of 2 carries a thousand — more than a screen — and a hard
|
|
55
|
+
; flick of 4 carries two thousand, which is two and a half screens of a
|
|
56
|
+
; 390x844 phone. Those are the numbers `web/scroll-check.mjs` holds it to.
|
|
57
|
+
def frictionPerMs:double 0.002
|
|
58
|
+
; Below this a lift is a stop and not a throw — a third of a pixel a frame
|
|
59
|
+
; at sixty of them, which is under the smallest movement anyone sees.
|
|
60
|
+
def minVelocity:double 0.05
|
|
61
|
+
; A single sample cannot make the page faster than this. A finger that
|
|
62
|
+
; jumps — a lost frame, a warped timestamp, a synthetic event — would
|
|
63
|
+
; otherwise launch the document into next week.
|
|
64
|
+
def maxVelocity:double 8.0
|
|
65
|
+
; How far back the speed is measured. Long enough to average out one bad
|
|
66
|
+
; sample, short enough that a finger that paused before lifting is read as
|
|
67
|
+
; having stopped, which is exactly what it did.
|
|
68
|
+
def windowMs:double 90.0
|
|
69
|
+
|
|
70
|
+
Constructor () {
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
; How quickly a throw runs out. Higher is shorter; `distanceFor` says
|
|
74
|
+
; what a given value means in pixels.
|
|
75
|
+
fn setFriction:void (perMs:double) {
|
|
76
|
+
frictionPerMs = perMs
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
; One sample of a drag: how far it moved and how long that took. Sign is
|
|
80
|
+
; the caller's — whatever `scroll by this much` means to it.
|
|
81
|
+
fn track:void (dy:double dtMs:double) {
|
|
82
|
+
; TWO MOVES INSIDE ONE TICK OF THE CALLER'S CLOCK. A host whose only
|
|
83
|
+
; clock is the frame — the iOS one, whose pan callbacks arrive between
|
|
84
|
+
; frames — reports the second move of a frame as having taken no time.
|
|
85
|
+
; Dropping it would lose most of a fast swipe, which is the swipe that
|
|
86
|
+
; matters, so it is folded into the sample already there: the
|
|
87
|
+
; distances add and the time stays the frame's, which is what happened.
|
|
88
|
+
if (dtMs <= 0.0) {
|
|
89
|
+
def n:int (array_length dys)
|
|
90
|
+
if (n > 0) {
|
|
91
|
+
dys = (this.withAdded(dys (n - 1) dy))
|
|
92
|
+
}
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
; A gap longer than the window is a new gesture as far as speed is
|
|
96
|
+
; concerned: whatever was moving before it is not moving now.
|
|
97
|
+
if (dtMs > windowMs) {
|
|
98
|
+
this.clearSamples()
|
|
99
|
+
}
|
|
100
|
+
push dys dy
|
|
101
|
+
push dts dtMs
|
|
102
|
+
this.trim()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
; `dys` with `dy` added to the entry at `i`. A list is rebuilt rather than
|
|
106
|
+
; written into because Ranger has no indexed assignment on one, and the
|
|
107
|
+
; list is at most a handful of samples long.
|
|
108
|
+
fn withAdded:[double] (src:[double] i:int dy:double) {
|
|
109
|
+
def out:[double]
|
|
110
|
+
def k:int 0
|
|
111
|
+
while (k < (array_length src)) {
|
|
112
|
+
def v:double (itemAt src k)
|
|
113
|
+
if (k == i) {
|
|
114
|
+
v = (v + dy)
|
|
115
|
+
}
|
|
116
|
+
push out v
|
|
117
|
+
k = (k + 1)
|
|
118
|
+
}
|
|
119
|
+
return out
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fn clearSamples:void () {
|
|
123
|
+
def a:[double]
|
|
124
|
+
dys = a
|
|
125
|
+
def b:[double]
|
|
126
|
+
dts = b
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
; Drop whatever has fallen out of the window, oldest first, but always keep
|
|
130
|
+
; the last sample: a single slow one is still the best answer there is.
|
|
131
|
+
fn trim:void () {
|
|
132
|
+
def total:double (this.windowTotalTime())
|
|
133
|
+
while ((array_length dts) > 1) {
|
|
134
|
+
def oldest:double (itemAt dts 0)
|
|
135
|
+
if ((total - oldest) < windowMs) {
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
total = (total - oldest)
|
|
139
|
+
def ky:[double]
|
|
140
|
+
def kt:[double]
|
|
141
|
+
def i:int 1
|
|
142
|
+
while (i < (array_length dts)) {
|
|
143
|
+
push ky (itemAt dys i)
|
|
144
|
+
push kt (itemAt dts i)
|
|
145
|
+
i = (i + 1)
|
|
146
|
+
}
|
|
147
|
+
dys = ky
|
|
148
|
+
dts = kt
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
fn windowTotalTime:double () {
|
|
153
|
+
def t:double 0.0
|
|
154
|
+
def i:int 0
|
|
155
|
+
while (i < (array_length dts)) {
|
|
156
|
+
t = (t + (itemAt dts i))
|
|
157
|
+
i = (i + 1)
|
|
158
|
+
}
|
|
159
|
+
return t
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
fn windowTotalDistance:double () {
|
|
163
|
+
def d:double 0.0
|
|
164
|
+
def i:int 0
|
|
165
|
+
while (i < (array_length dys)) {
|
|
166
|
+
d = (d + (itemAt dys i))
|
|
167
|
+
i = (i + 1)
|
|
168
|
+
}
|
|
169
|
+
return d
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
; The speed of the drag as it stands, over the window. Public because a
|
|
173
|
+
; host that wants to decide for itself whether a gesture was a throw can
|
|
174
|
+
; ask, and because it is the one number worth seeing in a test.
|
|
175
|
+
fn trackedVelocity:double () {
|
|
176
|
+
def t:double (this.windowTotalTime())
|
|
177
|
+
if (t <= 0.0) {
|
|
178
|
+
return 0.0
|
|
179
|
+
}
|
|
180
|
+
def v:double ((this.windowTotalDistance()) / t)
|
|
181
|
+
if (v > maxVelocity) {
|
|
182
|
+
return maxVelocity
|
|
183
|
+
}
|
|
184
|
+
if (v < (0.0 - maxVelocity)) {
|
|
185
|
+
return (0.0 - maxVelocity)
|
|
186
|
+
}
|
|
187
|
+
return v
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
; The finger left. Returns whether that started a fling — a lift below
|
|
191
|
+
; `minVelocity` is a stop, and says so.
|
|
192
|
+
fn release:boolean () {
|
|
193
|
+
def v:double (this.trackedVelocity())
|
|
194
|
+
this.clearSamples()
|
|
195
|
+
if ((fabs v) < minVelocity) {
|
|
196
|
+
velocity = 0.0
|
|
197
|
+
return false
|
|
198
|
+
}
|
|
199
|
+
velocity = v
|
|
200
|
+
return true
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
; Stop dead. A finger going down catches the page where it is, the way it
|
|
204
|
+
; does on a phone, and a wheel event takes it over.
|
|
205
|
+
fn halt:void () {
|
|
206
|
+
velocity = 0.0
|
|
207
|
+
this.clearSamples()
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
fn running:boolean () {
|
|
211
|
+
return (velocity != 0.0)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
; How far to scroll for this frame, and the speed left afterwards. Zero
|
|
215
|
+
; when there is no fling, so a caller can ask on every frame.
|
|
216
|
+
fn step:double (dtMs:double) {
|
|
217
|
+
if (velocity == 0.0) {
|
|
218
|
+
return 0.0
|
|
219
|
+
}
|
|
220
|
+
if (dtMs <= 0.0) {
|
|
221
|
+
return 0.0
|
|
222
|
+
}
|
|
223
|
+
def d:double (velocity * dtMs)
|
|
224
|
+
def keep:double (1.0 - (frictionPerMs * dtMs))
|
|
225
|
+
if (keep < 0.0) {
|
|
226
|
+
keep = 0.0
|
|
227
|
+
}
|
|
228
|
+
velocity = (velocity * keep)
|
|
229
|
+
if ((fabs velocity) < minVelocity) {
|
|
230
|
+
velocity = 0.0
|
|
231
|
+
}
|
|
232
|
+
return d
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
; What a throw at this speed would cover in total, if nothing stopped it.
|
|
236
|
+
; The integral of the decay, and the reason "twice as fast goes twice as
|
|
237
|
+
; far" is a fact about this class rather than a hope: it is linear in `v`.
|
|
238
|
+
fn distanceFor:double (v:double) {
|
|
239
|
+
if (frictionPerMs <= 0.0) {
|
|
240
|
+
return 0.0
|
|
241
|
+
}
|
|
242
|
+
return (v / frictionPerMs)
|
|
243
|
+
}
|
|
244
|
+
}
|