From 58e7e21cccbe82a7fdc20cde341a3226c872852a Mon Sep 17 00:00:00 2001 From: moonmoon <64200419+Moon-DaeSeung@users.noreply.github.com> Date: Mon, 13 May 2024 13:09:27 +0900 Subject: [PATCH] Opacity --- .vscode/settings.json | 1 + packages/flitter-svelte/src/lib/Widget.svelte | 17 ++- .../src/component/base/BaseColoredBox.ts | 26 +++- .../src/component/base/BaseCustomPaint.ts | 2 +- .../src/component/base/BaseGestureDetector.ts | 2 +- .../flitter/src/component/base/BaseOpacity.ts | 21 ++- .../src/component/base/BaseRichText.ts | 2 +- packages/flitter/src/framework/index.ts | 3 +- .../renderer/canvas/canvas-painter.ts | 61 ++++++++- .../canvas/canvas-painting-context.ts | 82 ++++++++++++ .../renderer/canvas/canvas-renderer.ts | 85 +++++++++--- .../src/framework/renderer/canvas/layer.ts | 121 ++++++++++++++++++ .../src/framework/renderer/renderer.ts | 53 +++++++- .../src/framework/renderer/svg/svg-painter.ts | 63 ++------- .../framework/renderer/svg/svg-renderer.ts | 16 +-- .../flitter/src/renderobject/RenderObject.ts | 27 +++- .../flitter/src/renderobject/RenderView.ts | 20 ++- packages/flitter/src/runApp.ts | 23 ++-- .../flitter/src/type/_types/text-painter.ts | 2 +- packages/flitter/src/utils/type.ts | 7 - packages/story/src/Widget.svelte | 5 +- .../stories/Container/Container.stories.ts | 13 ++ .../src/stories/Opacity/Widget.stories.ts | 36 ++++++ 23 files changed, 558 insertions(+), 130 deletions(-) create mode 100644 packages/flitter/src/framework/renderer/canvas/canvas-painting-context.ts create mode 100644 packages/flitter/src/framework/renderer/canvas/layer.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 64ca25d..cec2c64 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "flutterjs", "lerp", "linkedom", + "LTWH", "meursyphus", "popmotion", "postbuild", diff --git a/packages/flitter-svelte/src/lib/Widget.svelte b/packages/flitter-svelte/src/lib/Widget.svelte index 6688a25..1381b6e 100644 --- a/packages/flitter-svelte/src/lib/Widget.svelte +++ b/packages/flitter-svelte/src/lib/Widget.svelte @@ -4,6 +4,7 @@ import { type Widget, Alignment, AppRunner, Container, Text } from '@meursyphus/flitter'; const browser = typeof window !== 'undefined'; + export let renderer: 'svg' | 'canvas' = 'svg'; export let widget: Widget = Container({ width: Infinity, height: Infinity, @@ -22,7 +23,7 @@ export let width = '100%'; export let height = '300px'; - let svgEl: SVGSVGElement; + let renderEl: SVGSVGElement | HTMLCanvasElement; let containerEl: HTMLElement; let runner: AppRunner; let innerHTML: string = ''; @@ -40,12 +41,12 @@ onMount(() => { runner = new AppRunner({ - view: svgEl, + view: renderEl, window: window, document: document, ssrSize: ssr?.size }); - svgEl.innerHTML = ''; + renderEl.innerHTML = ''; runner.runApp(widget); runner.onMount({ resizeTarget: containerEl @@ -58,9 +59,13 @@
- - {@html innerHTML} - + {#if renderer === 'canvas' && browser} + + {:else} + + {@html innerHTML} + + {/if}