提交 49a26bee 编写于 作者: E ester.zhou

update docs (14806)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 12741510
...@@ -585,7 +585,7 @@ Fills a rectangle on the canvas. ...@@ -585,7 +585,7 @@ Fills a rectangle on the canvas.
```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>
``` ```
...@@ -621,7 +621,7 @@ Clears the content in a rectangle on the canvas. ...@@ -621,7 +621,7 @@ Clears the content in a rectangle on the canvas.
```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>
``` ```
...@@ -1735,9 +1735,9 @@ Creates a radial gradient and returns a **CanvasGradient** object. ...@@ -1735,9 +1735,9 @@ Creates a radial gradient and returns a **CanvasGradient** object.
// Radial gradient: inner circle(200,200,r:50) outer circle(200,200,r:200) // Radial gradient: inner circle(200,200,r:50) outer circle(200,200,r:200)
var gradient = ctx.createRadialGradient(200,200,50, 200,200,200); var gradient = ctx.createRadialGradient(200,200,50, 200,200,200);
// Add three color stops // Add three color stops
gradient.addColorStop(0.0, 'red'); gradient.addColorStop(0.0, '#ff0000');
gradient.addColorStop(0.5, 'white'); gradient.addColorStop(0.5, '#ffffff');
gradient.addColorStop(1.0, 'green'); gradient.addColorStop(1.0, '#00ff00');
// Set the fill style and draw a rectangle // Set the fill style and draw a rectangle
ctx.fillStyle = gradient; ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 500, 500); ctx.fillRect(0, 0, 500, 500);
......
...@@ -95,12 +95,36 @@ Checks whether a specified point is in the path area. ...@@ -95,12 +95,36 @@ Checks whether a specified point is in the path area.
**Example** **Example**
```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 {
...@@ -145,12 +169,36 @@ Checks whether a specified point is on the edge line of a path. ...@@ -145,12 +169,36 @@ Checks whether a specified point is on the edge line of a path.
**Example** **Example**
```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 {
...@@ -181,12 +229,36 @@ resetTransform(): void ...@@ -181,12 +229,36 @@ resetTransform(): void
**Example** **Example**
```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 {
......
...@@ -36,8 +36,6 @@ canvas { ...@@ -36,8 +36,6 @@ canvas {
```js ```js
// xxx.js // xxx.js
import promptAction from '@ohos.promptAction';
export default { export default {
onShow() { onShow() {
let ctx = this.$refs.canvas.getContext('2d', { let ctx = this.$refs.canvas.getContext('2d', {
...@@ -60,7 +58,7 @@ export default { ...@@ -60,7 +58,7 @@ export default {
path.closePath(); path.closePath();
// Door // Door
path.moveTo(250, 450); path.moveTo(250, 450);
path.rect(250, 450, 350, 600); path.rect(250, 450, 100, 600);
path.closePath(); path.closePath();
// Chimney // Chimney
path.moveTo(365, 250); path.moveTo(365, 250);
...@@ -139,8 +137,6 @@ text { ...@@ -139,8 +137,6 @@ text {
```js ```js
// xxx.js // xxx.js
import promptAction from '@ohos.promptAction';
export default { export default {
data: { data: {
ctx: null, ctx: null,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册