提交 d8c18a5d 编写于 作者: L lanyill 提交者: lanyi

fixed d3a80b29 from https://gitee.com/lanyill/docs/pulls/14803

Canvas js文档整改
Signed-off-by: Nlanyill <lanyi3@huawei.com>
上级 637693e3
...@@ -584,7 +584,7 @@ fillRect(x: number, y: number, width:number, height: number): void ...@@ -584,7 +584,7 @@ fillRect(x: number, y: number, width:number, height: number): void
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div> <div>
<canvas ref="canvas" style="width: 500px; height: 500px; "></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
...@@ -620,7 +620,7 @@ clearRect(x: number, y: number, width:number, height: number): void ...@@ -620,7 +620,7 @@ clearRect(x: number, y: number, width:number, height: number): void
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div> <div>
<canvas ref="canvas" style="width: 500px; height: 500px;"></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
......
...@@ -94,12 +94,36 @@ isPointInPath(path?: Path2D, x: number, y: number): boolean ...@@ -94,12 +94,36 @@ isPointInPath(path?: Path2D, x: number, y: number): boolean
**示例:** **示例:**
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div style="width: 500px; height: 500px;"> <div class="container" style="width: 500px; height: 500px;">
<text>In path:{{textValue}}</text> <text class="textsize">In path:{{textValue}}</text>
<canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
```css
/* xxx.css */
.container {
display: flex;
flex-direction: column;
background-color: #F1F3F5;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
canvas {
width: 600px;
height: 600px;
background-color: #fdfdfd;
border: none;
}
.textsize {
font-size: 40px;
}
```
```js ```js
// xxx.js // xxx.js
export default { export default {
...@@ -144,12 +168,36 @@ isPointInStroke(path?: Path2D, x: number, y: number): boolean ...@@ -144,12 +168,36 @@ isPointInStroke(path?: Path2D, x: number, y: number): boolean
**示例:** **示例:**
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div style="width: 500px; height: 500px;"> <div class="container" style="width: 500px; height: 500px;">
<text>In path:{{textValue}}</text> <text class="textsize">In stroke:{{textValue}}</text>
<canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
```css
/* xxx.css */
.container {
display: flex;
flex-direction: column;
background-color: #F1F3F5;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
canvas {
width: 600px;
height: 600px;
background-color: #fdfdfd;
border: none;
}
.textsize {
font-size: 40px;
}
```
```js ```js
// xxx.js // xxx.js
export default { export default {
...@@ -180,12 +228,36 @@ resetTransform(): void ...@@ -180,12 +228,36 @@ resetTransform(): void
**示例:** **示例:**
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div style="width: 500px; height: 500px;"> <div class="container" style="width: 500px; height: 500px;">
<text>In path:{{textValue}}</text> <text class="textsize">In path:{{textValue}}</text>
<canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
```css
/* xxx.css */
.container {
display: flex;
flex-direction: column;
background-color: #F1F3F5;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
canvas {
width: 600px;
height: 600px;
background-color: #fdfdfd;
border: none;
}
.textsize {
font-size: 40px;
}
```
```js ```js
// xxx.js // xxx.js
export default { export default {
......
...@@ -58,7 +58,7 @@ export default { ...@@ -58,7 +58,7 @@ export default {
path.closePath(); path.closePath();
// 门 // 门
path.moveTo(250, 450); path.moveTo(250, 450);
path.rect(250, 450, 350, 600); path.rect(250, 450, 100, 600);
path.closePath(); path.closePath();
// 烟囱 // 烟囱
path.moveTo(365, 250); path.moveTo(365, 250);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册