Skip to content

Commit 594501b

Browse files
committed
detail change
1 parent a297a96 commit 594501b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

08 - Fun with HTML5 Canvas/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
![HTML5 Canvas 画板效果](https://cl.ly/412q1g0u3N31/Screen%20recording%202017-01-04%20at%2007.38.05%20PM.gif)
99

10-
用 HTML5 中的 Canvas 的路径绘制实现一个绘画板,可供鼠标画画,颜色呈彩虹色渐变,画笔大小同样呈渐变效果。这部分不涉及 CSS 内容,全部由 JS 来实现。
10+
用 HTML5 中的 Canvas 的路径绘制实现一个绘画板,可供鼠标画画,颜色呈彩虹色渐变,画笔大小同样呈渐变效果。这部分不涉及 CSS 内容,全部由 JS 来实现。[在线体验请看这个链接](http://soyaine.cn/JavaScript30/08%20-%20Fun%20with%20HTML5%20Canvas/index-SOYAINE.html)
1111

1212
## 涉及特性
1313

08 - Fun with HTML5 Canvas/index-SOYAINE.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
ctx.lineWidth = 90;
2121
ctx.lineCap = "round";
22-
ctx.lineJoin = "miter";
22+
ctx.lineJoin = "round";
2323
ctx.strokeStyle = "#f00";
2424
ctx.fillStyle = "#f00";
2525

@@ -46,14 +46,14 @@
4646
ctx.strokeStyle = `hsl(${ hue }, 90%, 50%)`;
4747
if(hue >= 360) hue = 0;
4848
hue++;
49-
//
49+
5050
// 水墨效果
5151
// ctx.strokeStyle = `rgba(0, 0, 0, ${ hue })`;
5252
// if(hue >= 0.7) hue = 0;
5353
// hue += 0.01;
5454

5555
// 控制笔触大小
56-
if(ctx.lineWidth > 100 || ctx.lineWidth < 80) {
56+
if(ctx.lineWidth > 120 || ctx.lineWidth < 10) {
5757
direction = !direction;
5858
}
5959
if (direction) {
@@ -74,7 +74,6 @@
7474
// console.log(ctx.lineWidth);
7575
// console.log(x +"-" + e.offsetX);
7676
}
77-
7877
canvas.addEventListener('mousedown', (e) => {
7978
isDrawing = true;
8079
[lastX, lastY] = [e.offsetX, e.offsetY];

0 commit comments

Comments
 (0)