Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
c0c091c8
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
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看板
提交
c0c091c8
编写于
9月 15, 2023
作者:
张
张磊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支持贝塞尔曲线
上级
2722c735
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
292 addition
and
269 deletion
+292
-269
pages/component/view/view-draw.uvue
pages/component/view/view-draw.uvue
+292
-269
未找到文件。
pages/component/view/view-draw.uvue
浏览文件 @
c0c091c8
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
<view ref="draw-house" style="width: 750rpx;height: 550rpx; background-color: lightgray;margin: 30rpx 0rpx;"></view>
<view ref="draw-house" style="width: 750rpx;height: 550rpx; background-color: lightgray;margin: 30rpx 0rpx;"></view>
<view ref="draw-style" style="width: 750rpx;height: 550rpx; background-color: lightgray;margin: 30rpx 0rpx;"></view>
<view ref="draw-style" style="width: 750rpx;height: 550rpx; background-color: lightgray;margin: 30rpx 0rpx;"></view>
<view ref="draw-odd" style="width: 750rpx;height: 550rpx; background-color: lightgray;margin: 30rpx 0rpx;"></view>
<view ref="draw-odd" style="width: 750rpx;height: 550rpx; background-color: lightgray;margin: 30rpx 0rpx;"></view>
<view ref="draw-arcto" style="width: 750rpx;height: 550rpx; background-color: lightgray;margin: 30rpx 0rpx;"></view>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
...
@@ -49,13 +50,14 @@
...
@@ -49,13 +50,14 @@
this.drawhouse()
this.drawhouse()
this.drawPoint()
this.drawPoint()
this.drawRect()
this.drawRect()
this.drawArcTo()
},
},
onUnload() {
onUnload() {
y = 160
y = 160
},
},
methods: {
methods: {
drawText() {
drawText() {
let node = (this.$refs['draw-text-view'] as Element
)
let node = (this.$refs['draw-text-view'] as INode
)
let ctx = node.getDrawableContext()
let ctx = node.getDrawableContext()
let width = node.getBoundingClientRect().width
let width = node.getBoundingClientRect().width
ctx!!.reset()
ctx!!.reset()
...
@@ -72,7 +74,7 @@
...
@@ -72,7 +74,7 @@
ctx!!.update()
ctx!!.update()
},
},
drawLines() {
drawLines() {
let ctx = (this.$refs['draw-line-view'] as Element
).getDrawableContext()
let ctx = (this.$refs['draw-line-view'] as INode
).getDrawableContext()
ctx!!.reset()
ctx!!.reset()
ctx!!.lineWidth = 10;
ctx!!.lineWidth = 10;
...
@@ -106,14 +108,14 @@
...
@@ -106,14 +108,14 @@
ctx!.stroke();
ctx!.stroke();
});
});
ctx!.lineWidth = 1;
ctx!.lineWidth = 1;
this.drawDashedLine([], ctx
);
this.drawDashedLine([], ctx!
);
this.drawDashedLine([2, 2], ctx
);
this.drawDashedLine([2, 2], ctx!
);
this.drawDashedLine([10, 10], ctx
);
this.drawDashedLine([10, 10], ctx!
);
this.drawDashedLine([20, 5], ctx
);
this.drawDashedLine([20, 5], ctx!
);
this.drawDashedLine([15, 3, 3, 3], ctx
);
this.drawDashedLine([15, 3, 3, 3], ctx!
);
this.drawDashedLine([20, 3, 3, 3, 3, 3, 3, 3], ctx
);
this.drawDashedLine([20, 3, 3, 3, 3, 3, 3, 3], ctx!
);
ctx!.lineDashOffset = 18;
ctx!.lineDashOffset = 18;
this.drawDashedLine([12, 3, 3], ctx
);
this.drawDashedLine([12, 3, 3], ctx!
);
ctx!.lineDashOffset = 0
ctx!.lineDashOffset = 0
ctx!.setLineDash([0])
ctx!.setLineDash([0])
ctx!!.update()
ctx!!.update()
...
@@ -127,7 +129,7 @@
...
@@ -127,7 +129,7 @@
y += 15;
y += 15;
},
},
drawCircles() {
drawCircles() {
let ctx = (this.$refs['draw-circle-view'] as Element
).getDrawableContext()
let ctx = (this.$refs['draw-circle-view'] as INode
).getDrawableContext()
ctx!!.reset()
ctx!!.reset()
// Draw shapes
// Draw shapes
for (var i = 0; i < 4; i++) {
for (var i = 0; i < 4; i++) {
...
@@ -153,7 +155,7 @@
...
@@ -153,7 +155,7 @@
},
},
drawStar() {
drawStar() {
let ctx = (this.$refs['draw-dash-line'] as Element
).getDrawableContext()
let ctx = (this.$refs['draw-dash-line'] as INode
).getDrawableContext()
ctx!!.reset()
ctx!!.reset()
ctx!!.beginPath();
ctx!!.beginPath();
var horn = 5; // 画5个角
var horn = 5; // 画5个角
...
@@ -224,7 +226,7 @@
...
@@ -224,7 +226,7 @@
return result
return result
},
},
drawhouse() {
drawhouse() {
let ctx = (this.$refs['draw-house'] as Element
).getDrawableContext()
let ctx = (this.$refs['draw-house'] as INode
).getDrawableContext()
ctx!!.reset()
ctx!!.reset()
ctx!!.lineWidth = 10;
ctx!!.lineWidth = 10;
...
@@ -244,7 +246,7 @@
...
@@ -244,7 +246,7 @@
ctx!!.update()
ctx!!.update()
},
},
drawPoint() {
drawPoint() {
let ctx = (this.$refs['draw-style'] as Element
).getDrawableContext()
let ctx = (this.$refs['draw-style'] as INode
).getDrawableContext()
ctx!!.reset()
ctx!!.reset()
for (let i = 0; i < 6; i++) {
for (let i = 0; i < 6; i++) {
for (let j = 0; j < 6; j++) {
for (let j = 0; j < 6; j++) {
...
@@ -263,7 +265,7 @@
...
@@ -263,7 +265,7 @@
ctx!!.update()
ctx!!.update()
},
},
drawRect() {
drawRect() {
let ctx = (this.$refs['draw-odd'] as Element
).getDrawableContext()
let ctx = (this.$refs['draw-odd'] as INode
).getDrawableContext()
ctx!!.reset()
ctx!!.reset()
// Create path
// Create path
ctx!!.moveTo(30, 90);
ctx!!.moveTo(30, 90);
...
@@ -279,6 +281,27 @@
...
@@ -279,6 +281,27 @@
ctx!.fill("evenodd");
ctx!.fill("evenodd");
ctx!!.update()
ctx!!.update()
},
drawArcTo() {
let ctx = (this.$refs['draw-arcto'] as INode).getDrawableContext()
ctx!.reset()
ctx!.beginPath();
ctx!.moveTo(50, 20);
ctx!.bezierCurveTo(230, 30, 150, 60, 50, 100);
ctx!.stroke();
ctx!.fillStyle = "blue";
// start point
ctx!.fillRect(50, 20, 10, 10);
// end point
ctx!.fillRect(50, 100, 10, 10);
ctx!.fillStyle = "red";
// control point one
ctx!.fillRect(230, 30, 10, 10);
// control point two
ctx!.fillRect(150, 70, 10, 10);
ctx!.update()
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录