-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
8 changed files
with
88 additions
and
34 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<script setup lang="ts"> | ||
import * as nc from 'newcar' | ||
import { onMounted, ref } from 'vue' | ||
const canvas = ref<HTMLCanvasElement>() | ||
const engine = await new nc.CarEngine().init('https://unpkg.com/canvaskit-wasm@latest/bin/canvaskit.wasm') | ||
const app = engine.createApp(canvas.value!).setBackgroundColor('transparent') | ||
onMounted(async () => { | ||
const root = new nc.Circle(100,{ | ||
x:100, | ||
y:100 | ||
}) | ||
.animate( | ||
nc.parallel( | ||
nc.create().withAttr({ duration: 1 }), | ||
// nc.discolorate().withAttr({ duration: 1, to: nc.Color.parse('skyblue') }) | ||
) | ||
) | ||
const scene = nc.createScene(root) | ||
app.checkout(scene) | ||
}) | ||
function play(){ | ||
app.play() | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="div"> | ||
<button calss="bottom" @click.once="play">play</button> | ||
<canvas ref="canvas" width="200" height="300"></canvas> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="css"> | ||
.div{ | ||
} | ||
</style> |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: 录制器 | ||
--- | ||
|
||
# Recorder | ||
|
||
到目前为止,经过前面的学习,我相信您已经掌握了Newcar的基本用法。目前,如果您想向朋友展示你制作的动画或将其上传到社交媒体上,屏幕录制是一个不错的选择。但是,我们建议使用 `录制器` 来记录您的动画并以 `mp4` 或`webm`格式导出视频。 | ||
|
||
```javascript | ||
// First, create a Recorder, specifying the Canvas Element type | ||
const recorder = new Recorder(document.querySelector('#canvas'), 'mp4') | ||
|
||
// Start recording | ||
recorder.start(2000, (url) => { | ||
// After 2000ms, output the video's URL address | ||
console.log(url) | ||
}) | ||
``` | ||
|
||
现在,您可以访问这个URL来下载视频。 |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: 单位制 | ||
--- | ||
|
||
# 单位制 | ||
|
||
Newcar 提供了三种单位制:`帧`、`秒` 和 `毫秒`。默认单位通常是秒,与应用程序绑定,除了 [Recorder](./recorder) 使用毫秒。 | ||
|
||
## 设置单位制 | ||
|
||
```ts | ||
app.config.unit = 'frame' | ||
app.config.unit = 's' | ||
app.config.unit = 'ms' | ||
``` |