1
1
import {
2
- deflate ,
3
2
enumKey ,
4
3
fitRects ,
5
- inflate ,
6
- NodeType ,
7
4
processCircle ,
8
5
processColor ,
9
6
processPath ,
@@ -12,8 +9,6 @@ import {
12
9
} from "../../../dom/nodes" ;
13
10
import type {
14
11
AtlasProps ,
15
- BoxProps ,
16
- BoxShadowProps ,
17
12
CircleProps ,
18
13
DiffRectProps ,
19
14
DrawingNodeProps ,
@@ -38,18 +33,13 @@ import { saturate } from "../../../renderer/processors";
38
33
import type { SkPoint , SkRSXform } from "../../../skia/types" ;
39
34
import {
40
35
BlendMode ,
41
- BlurStyle ,
42
- ClipOp ,
43
36
FillType ,
44
37
FilterMode ,
45
38
isCubicSampling ,
46
- isRRect ,
47
39
MipmapMode ,
48
40
PointMode ,
49
41
VertexMode ,
50
42
} from "../../../skia/types" ;
51
- import type { Node } from "../../Node" ;
52
- import { materialize } from "../../utils" ;
53
43
import type { DrawingContext } from "../DrawingContext" ;
54
44
55
45
export const drawLine = ( ctx : DrawingContext , props : LineProps ) => {
@@ -64,61 +54,6 @@ export const drawOval = (ctx: DrawingContext, props: OvalProps) => {
64
54
ctx . canvas . drawOval ( rect , ctx . paint ) ;
65
55
} ;
66
56
67
- export const drawBox = (
68
- ctx : DrawingContext ,
69
- props : BoxProps ,
70
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
- children : Node < any > [ ]
72
- ) => {
73
- "worklet" ;
74
- const { paint, Skia, canvas } = ctx ;
75
- const { box : defaultBox } = props ;
76
- const opacity = paint . getAlphaf ( ) ;
77
- const box = isRRect ( defaultBox ) ? defaultBox : Skia . RRectXY ( defaultBox , 0 , 0 ) ;
78
- const shadows = children
79
- . map ( ( node ) => {
80
- if ( node . type === NodeType . BoxShadow ) {
81
- return materialize ( node . props ) ;
82
- }
83
- return null ;
84
- } )
85
- . filter ( ( n ) : n is BoxShadowProps => n !== null ) ;
86
- shadows
87
- . filter ( ( shadow ) => ! shadow . inner )
88
- . map ( ( shadow ) => {
89
- const { color = "black" , blur, spread = 0 , dx = 0 , dy = 0 } = shadow ;
90
- const lPaint = Skia . Paint ( ) ;
91
- lPaint . setColor ( processColor ( Skia , color ) ) ;
92
- lPaint . setAlphaf ( paint . getAlphaf ( ) * opacity ) ;
93
- lPaint . setMaskFilter (
94
- Skia . MaskFilter . MakeBlur ( BlurStyle . Normal , blur , true )
95
- ) ;
96
- canvas . drawRRect ( inflate ( Skia , box , spread , spread , dx , dy ) , lPaint ) ;
97
- } ) ;
98
-
99
- canvas . drawRRect ( box , paint ) ;
100
-
101
- shadows
102
- . filter ( ( shadow ) => shadow . inner )
103
- . map ( ( shadow ) => {
104
- const { color = "black" , blur, spread = 0 , dx = 0 , dy = 0 } = shadow ;
105
- const delta = Skia . Point ( 10 + Math . abs ( dx ) , 10 + Math . abs ( dy ) ) ;
106
- canvas . save ( ) ;
107
- canvas . clipRRect ( box , ClipOp . Intersect , false ) ;
108
- const lPaint = Skia . Paint ( ) ;
109
- lPaint . setColor ( processColor ( Skia , color ) ) ;
110
- lPaint . setAlphaf ( paint . getAlphaf ( ) * opacity ) ;
111
-
112
- lPaint . setMaskFilter (
113
- Skia . MaskFilter . MakeBlur ( BlurStyle . Normal , blur , true )
114
- ) ;
115
- const inner = deflate ( Skia , box , spread , spread , dx , dy ) ;
116
- const outer = inflate ( Skia , box , delta . x , delta . y ) ;
117
- canvas . drawDRRect ( outer , inner , lPaint ) ;
118
- canvas . restore ( ) ;
119
- } ) ;
120
- } ;
121
-
122
57
export const drawImage = ( ctx : DrawingContext , props : ImageProps ) => {
123
58
"worklet" ;
124
59
const { image, sampling } = props ;
0 commit comments