@@ -844,8 +844,8 @@ registerPaint('arc', class {
844
844
ctx.strokeStyle = args[0] .cssText;
845
845
846
846
// Determine the center point.
847
- const x = geom.width / 2;
848
- const y = geom.height / 2;
847
+ const x = geom.width / 2;
848
+ const y = geom.height / 2;
849
849
850
850
// Convert the start and end angles to radians.
851
851
const startAngle = this.convertAngle(args[1] ) - Math.PI / 2;
@@ -926,3 +926,48 @@ registerPaint('heading-color', class {
926
926
}
927
927
});
928
928
</pre>
929
+
930
+ Example 5: Drawing outside an element's area {#example-5}
931
+ ---------------------------------------------------------
932
+
933
+ It is possible to draw outside an element's area by using the 'border-image' property.
934
+
935
+ <pre class='lang-markup'>
936
+ <style>
937
+ #overdraw {
938
+ --border-width: 10;
939
+
940
+ border-style: solid;
941
+ border-width: calc(var(--border-width) * 1px);
942
+
943
+ border-image-source: paint(overdraw);
944
+ border-image-slice: 0 fill;
945
+ border-image-outset: calc(var(--border-width) * 1px);
946
+
947
+ width: 200px;
948
+ height: 200px;
949
+ }
950
+ </style>
951
+ <div id="overdraw"></div>
952
+ <script>
953
+ CSS.paintWorklet.addModule('overdraw.js' );
954
+ </script>
955
+ </pre>
956
+
957
+ <pre class='lang-javascript'>
958
+ // overdraw.js
959
+ registerPaint('overdraw' , class {
960
+ static get inputProperties() { return ['--border-width'] ; }
961
+ paint(ctx, geom, properties) {
962
+ const borderWidth = parseInt(properties.get('--border-width' ));
963
+ ctx.shadowColor = 'rgba(0,0,0,0.25)' ;
964
+ ctx.shadowBlur = borderWidth;
965
+
966
+ ctx.fillStyle = 'rgba(255, 255, 255, 1)' ;
967
+ ctx.fillRect(borderWidth,
968
+ borderWidth,
969
+ geom.width - 2 * borderWidth,
970
+ geom.height - 2 * borderWidth);
971
+ }
972
+ });
973
+ </pre>
0 commit comments