Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepbox8646 committed Jul 23, 2024
1 parent b879bc5 commit a924e29
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 7 deletions.
46 changes: 46 additions & 0 deletions docs/content/guide/basic/demos/demo-text-group.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<canvas ref="canvas" width="600" height="300"></canvas>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import * as nc from 'newcar'
const canvas = ref<HTMLCanvasElement>()
onMounted(async () => {
await nc.useFont('https://storage.googleapis.com/skia-cdn/misc/Roboto-Regular.ttf')
const engine = await new nc.CarEngine()
.init('https://unpkg.com/canvaskit-wasm@latest/bin/canvaskit.wasm')
const app = engine.createApp(canvas.value!).setBackgroundColor('transparent')
const scene = nc.createScene(
new nc.TextGroup([
new nc.Text('Hello', {
x: 100,
y: 100,
style: {
fontSize: 50,
fill: true
}
}),
new nc.Text(' world!', {
x: 100,
y: 150,
style: {
fontSize: 20,
fill: true,
}
}),
// ...
], {
width: 600,
x: 200,
y: 200
})
)
app.checkout(scene)
app.play()
})
</script>
31 changes: 31 additions & 0 deletions docs/content/guide/basic/demos/demo-text.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<canvas ref="canvas" width="600" height="300"></canvas>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import * as nc from 'newcar'
const canvas = ref<HTMLCanvasElement>()
onMounted(async () => {
await nc.useFont('https://storage.googleapis.com/skia-cdn/misc/Roboto-Regular.ttf')
const engine = await new nc.CarEngine()
.init('https://unpkg.com/canvaskit-wasm@latest/bin/canvaskit.wasm')
const app = engine.createApp(canvas.value!).setBackgroundColor('transparent')
const scene = nc.createScene(
new nc.Text('Hello world!', {
x: 100,
y: 100,
style: {
fillColor: nc.Color.parse('red'),
fontSize: 50
}
})
)
app.checkout(scene)
app.play()
})
</script>
Binary file added docs/content/guide/basic/demos/font.ttf
Binary file not shown.
20 changes: 13 additions & 7 deletions docs/content/guide/basic/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
title: Text and TextGroup
---

<script setup lang="ts">
import { default as DemoText } from './demos/demo-text.vue'
import { default as DemoTextGroup } from './demos/demo-text-group.vue'
</script>

# `Text` and `TextGroup`

## `Text`
Expand All @@ -22,7 +27,6 @@ widget.add(
x: 100,
y: 100,
style: {
color: nc.Color.parse('skyblue'),
fontSize: 50
},
width: 500
Expand All @@ -33,7 +37,7 @@ widget.add(

```

![The demonstration of the Text component, the sky blue "Hello world!"](/basic/text-and-textgroup-01.png)
<DemoText/>

## `TextGroup`

Expand All @@ -50,16 +54,18 @@ widget.add(
x: 100,
y: 100,
style: {
color: nc.Color.parse('skyblue'),
fontSize: 50
fontSize: 50,
fill: false,
border: true,
}
}),
new nc.Text(' world!', {
x: 100,
y: 150,
style: {
color: nc.Color.parse('red'),
fontSize: 30
fontSize: 30,
fill: false,
border: true,
}
}),
// ...
Expand All @@ -74,7 +80,7 @@ widget.add(

```

![The demonstration of the TextGroup component, the sky blue "Hello" and the red " world!"](/basic/text-and-textgroup-02.png)
<DemoTextGroup/>

## See Also:

Expand Down

0 comments on commit a924e29

Please sign in to comment.