1 | if (typeof registerPaint !== 'undefined') {
|
2 | class CrossOut {
|
3 | static get inputProperties() {
|
4 | return ['--extra-crossNumber', '--extra-crossColor', '--extra-crossSpread', '--extra-crossWidth']
|
5 | }
|
6 |
|
7 | paint(ctx, size, properties) {
|
8 | const lineWidth = properties.get('--extra-crossWidth')
|
9 | const color = properties.get('--extra-crossColor')
|
10 | const spread = properties.get('--extra-crossSpread')
|
11 | const spreadPercent = (spread - 1) / 100
|
12 | const verticalStart = (size.height - lineWidth) * spreadPercent + lineWidth
|
13 |
|
14 | ctx.lineWidth = lineWidth
|
15 | ctx.strokeStyle = color
|
16 |
|
17 | ctx.beginPath()
|
18 | ctx.moveTo(lineWidth, lineWidth)
|
19 | ctx.lineTo(size.width - lineWidth, verticalStart)
|
20 | ctx.moveTo(size.width - lineWidth, lineWidth)
|
21 | ctx.lineTo(lineWidth, verticalStart + size.height)
|
22 | ctx.stroke()
|
23 | }
|
24 | }
|
25 |
|
26 | registerPaint('extra-crossOut', CrossOut)
|
27 | } |
\ | No newline at end of file |