-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d39e1f9
commit eca59fa
Showing
10 changed files
with
59 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import type { Base } from '@newcar/core' | ||
import { withProcess } from '@newcar/core' | ||
|
||
withProcess<Base>((ctx, process) => { | ||
ctx.widget.x.value = ctx.widget.x.value * process | ||
}) | ||
export function move(x: number, y: number) { | ||
return withProcess<Base>((ctx, process) => { | ||
ctx.widget.x.value = process * x | ||
ctx.widget.y.value = process * y | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './arc' | ||
export * from './circle' | ||
export * from './figure' | ||
export * from './path' | ||
export * from './rect' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
/* eslint-disable import/no-mutable-exports */ | ||
import CanvasKitInit from 'canvaskit-wasm' | ||
import { error } from '@newcar/utils' | ||
import { defineCreateAppApi } from './app' | ||
import type { Widget, WidgetBuilder } from './widget' | ||
|
||
export let createApp: ReturnType<typeof defineCreateAppApi> = (() => { | ||
error('Please preload Skia before you use this API!') | ||
}) as any | ||
|
||
export async function loadSkia(wasm: string) { | ||
export async function initEngine(wasm: string) { | ||
const ck = await CanvasKitInit({ | ||
locateFile: (_file: string) => wasm, | ||
}) | ||
|
||
createApp = defineCreateAppApi(ck) as ReturnType<typeof defineCreateAppApi> | ||
const createApp = defineCreateAppApi(ck) as ReturnType<typeof defineCreateAppApi> | ||
|
||
function use<T extends Widget>(builder: WidgetBuilder<T>) { | ||
return builder(ck) | ||
} | ||
|
||
return ck | ||
return { | ||
createApp, | ||
ck, | ||
use, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters