-
Notifications
You must be signed in to change notification settings - Fork 0
/
labs-future-card.js
74 lines (65 loc) · 2.16 KB
/
labs-future-card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
registerPaint('labs-future-card', class {
static get inputProperties() {
return ['--card-border-color', '--card-border-size', '--card-background-color', '--card-width'];
}
paint(ctx, size, properties) {
const d = properties.get('--card-border-size').value;
const color = properties.get('--card-border-color');
const bgColor = properties.get('--card-background-color');
const width = properties.get('--card-width').value || size.width;
const height = size.height;
ctx.translate((size.width - width) / 2, 0);
ctx.beginPath();
ctx.moveTo(width - d * 2, 0);
ctx.lineTo(width - d, 0);
ctx.lineTo(width, d);
ctx.lineTo(width, d * 2);
ctx.strokeStyle = color;
ctx.lineWidth = 4;
ctx.stroke();
ctx.beginPath();
ctx.moveTo(width - d * 2 - 5, 10);
ctx.lineTo(width - d, 10);
ctx.lineTo(width - 7, d + 5);
ctx.lineTo(width - 7, d * 2 + 10);
ctx.filter = 'blur(10px)';
ctx.lineWidth = 3;
ctx.stroke();
ctx.filter = 'blur(0)';
ctx.beginPath();
ctx.moveTo(width, d * 2);
ctx.lineTo(width, height);
ctx.lineWidth = 1;
ctx.stroke();
ctx.beginPath();
ctx.moveTo(d + d , height);
ctx.lineTo(d - d / 2, height);
ctx.lineTo(0, height - d);
ctx.lineTo(0, height - d * 2);
ctx.lineWidth = 4;
ctx.stroke();
ctx.beginPath();
ctx.moveTo(d + d , height - 10);
ctx.lineTo(d - 5 , height - 10);
ctx.lineTo(10, height - d);
ctx.lineTo(10, height - d * 2);
ctx.lineWidth = 3;
ctx.filter = 'blur(10px)'
ctx.stroke();
ctx.filter = 'blur(0)';
ctx.beginPath();
ctx.moveTo(0, height - d * 2);
ctx.lineTo(0, 0);
ctx.lineWidth = 1;
ctx.stroke();
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(width - d, 0);
ctx.lineTo(width, d);
ctx.lineTo(width, height);
ctx.lineTo(d / 2, height);
ctx.lineTo(0, height - d );
ctx.fillStyle = bgColor;
ctx.fill();
}
});