Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
8a9ae272
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5996
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8a9ae272
编写于
7月 25, 2024
作者:
X
xty
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善canvas 中一些不清晰的示例
上级
1190d92a
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
10 addition
and
14 deletion
+10
-14
pages/component/canvas/canvas.uvue
pages/component/canvas/canvas.uvue
+10
-14
未找到文件。
pages/component/canvas/canvas.uvue
浏览文件 @
8a9ae272
...
...
@@ -24,7 +24,7 @@
data() {
const API_PATH = ["arc", "arcTo", "bezierCurveTo", "quadraticCurve", "moveTo", "lineTo", "rect", "clip", "pattern"]
const API_DRAW = ["stroke", "strokeRect", "strokeText", "fill", "fillRect", "fillText", "drawImage", "drawImageLocal", "clearRect"]
const API_STATE = ["beginPath", "closePath",
"restore", "reset", "setTransform", "transform", "rotate", "resetTransform", "sav
e", "scale", "translate"]
const API_STATE = ["beginPath", "closePath",
"reset", "transform", "rotate", "resetTransform", "save", "restor
e", "scale", "translate"]
const API_PROPERTIES = ["setLineCap", "setLineJoin", "setLineWidth", "setMiterLimit", "setFillStyle", "setStrokeStyle", "setGlobalAlpha", "lineDash", "linearGradient", "radialGradient", "textAlign"]
return {
title: 'Context2D',
...
...
@@ -124,9 +124,6 @@
case "scale":
this.scale();
break;
case "setTransform":
this.setTransform();
break;
case "stroke":
this.stroke();
break;
...
...
@@ -362,7 +359,7 @@
const context = this.canvasContext!
this.image = new Image(100, 100)
this.image!.src = '
https://web-ext-storage.dcloud.net.cn/uni-app-x/hello-uniappx-qrcode
.png';
this.image!.src = '
../../../static/api
.png';
// this.image!.src = 'https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createPattern/canvas_createpattern.png';
// Only use the image after it's loaded
this.image!.onload = () => {
...
...
@@ -370,7 +367,7 @@
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight)
const pattern = context.createPattern(this.image!, "repeat")
context.fillStyle = pattern
context.fillRect(0, 0,
64, 64
)
context.fillRect(0, 0,
100, 100
)
context.restore()
};
},
...
...
@@ -530,8 +527,6 @@
context.restore()
},
setTransform() {
},
rotate() {
const context = this.canvasContext!
...
...
@@ -623,7 +618,7 @@
},
save() {
const context = this.canvasContext!
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight)
context.save()
context.beginPath()
context.strokeStyle = '#00ff00'
...
...
@@ -641,6 +636,7 @@
},
restore() {
const context = this.canvasContext!;
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
[3, 2, 1].forEach((item) => {
context.save()
context.beginPath()
...
...
@@ -652,21 +648,21 @@
},
drawImageLocal() {
const context = this.canvasContext!
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight)
let image = new Image(100, 100)
image.src = '../../
static/1.jp
g'
image.src = '../../
../static/uni.pn
g'
image.onload = () => {
context.drawImage(image, 0, 0, 100, 100)
}
},
drawImage() {
const context = this.canvasContext!
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight)
let image = new Image(100, 100);
image.src = 'https://web-ext-storage.dcloud.net.cn/uni-app-x/hello-uniappx-qrcode.png'
image.onload = () => {
context.drawImage(image, 0, 0, 100, 100)
uni.getElementById("page-canvas")?.appendChild(image)
//
uni.getElementById("page-canvas")?.appendChild(image)
}
},
rect() {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录