|
1 | 1 | import React from "react"; |
2 | 2 |
|
3 | 3 | import { checkImage, docPath } from "../../../__tests__/setup"; |
4 | | -import { Image, Group, Fill, FitBox, Path } from "../../components"; |
| 4 | +import { |
| 5 | + Image, |
| 6 | + Group, |
| 7 | + Fill, |
| 8 | + FitBox, |
| 9 | + Path, |
| 10 | + Rect, |
| 11 | + Circle, |
| 12 | + Paint, |
| 13 | + Blur, |
| 14 | +} from "../../components"; |
5 | 15 | import { images, importSkia, PIXEL_RATIO, surface } from "../setup"; |
6 | 16 |
|
7 | 17 | describe("Group", () => { |
@@ -164,6 +174,48 @@ describe("Group", () => { |
164 | 174 | ); |
165 | 175 | checkImage(img, docPath("group/bloom.png")); |
166 | 176 | }); |
| 177 | + it("Copies a layer and adds new content to it (decl)", async () => { |
| 178 | + const { width, height } = surface; |
| 179 | + const centreY = height / 2; |
| 180 | + const { SaveLayerFlag, rect } = importSkia(); |
| 181 | + const img = await surface.draw( |
| 182 | + <> |
| 183 | + <Fill color="black" /> |
| 184 | + <Rect |
| 185 | + x={0} |
| 186 | + y={centreY - 0.1 * height} |
| 187 | + width={width} |
| 188 | + height={0.2 * height} |
| 189 | + color={[0, 0, 0.6, 1]} |
| 190 | + /> |
| 191 | + <Circle |
| 192 | + cx={0.25 * width} |
| 193 | + cy={centreY} |
| 194 | + r={0.2 * width} |
| 195 | + color={[0.8, 0, 0, 1]} |
| 196 | + /> |
| 197 | + <Group clip={rect(0, 0, width, centreY)}> |
| 198 | + <Group |
| 199 | + saveLayerFlags={SaveLayerFlag.SaveLayerInitWithPrevious} |
| 200 | + layer={ |
| 201 | + <Paint blendMode={"screen"}> |
| 202 | + <Blur blur={width * 0.05} mode={"decal"} /> |
| 203 | + </Paint> |
| 204 | + } |
| 205 | + > |
| 206 | + <Circle |
| 207 | + cx={0.75 * width} |
| 208 | + cy={centreY} |
| 209 | + r={0.2 * width} |
| 210 | + color={[0.8, 0, 0, 1]} |
| 211 | + /> |
| 212 | + </Group> |
| 213 | + </Group> |
| 214 | + </> |
| 215 | + ); |
| 216 | + |
| 217 | + checkImage(img, docPath("group/bloom.png")); |
| 218 | + }); |
167 | 219 | it("Copies a layer through a backdrop filter and adds new content to it", async () => { |
168 | 220 | const { width, height } = surface; |
169 | 221 | const centreY = height / 2; |
@@ -200,4 +252,46 @@ describe("Group", () => { |
200 | 252 | ); |
201 | 253 | checkImage(img, docPath("group/bloom2.png")); |
202 | 254 | }); |
| 255 | + it("Copies a layer through a backdrop filter and adds new content to it (decl)", async () => { |
| 256 | + const { width, height } = surface; |
| 257 | + const centreY = height / 2; |
| 258 | + const { TileMode, rect, Skia } = importSkia(); |
| 259 | + const img = await surface.draw( |
| 260 | + <> |
| 261 | + <Fill color="black" /> |
| 262 | + <Rect |
| 263 | + x={0} |
| 264 | + y={centreY - 0.1 * height} |
| 265 | + width={width} |
| 266 | + height={0.2 * height} |
| 267 | + color={[0, 0, 0.6, 1]} |
| 268 | + /> |
| 269 | + <Circle |
| 270 | + cx={0.25 * width} |
| 271 | + cy={centreY} |
| 272 | + r={0.2 * width} |
| 273 | + color={[0.8, 0, 0, 1]} |
| 274 | + /> |
| 275 | + <Group clip={rect(0, 0, width, centreY)}> |
| 276 | + <Group |
| 277 | + layer={<Paint blendMode={"screen"} />} |
| 278 | + backdropFilter={Skia.ImageFilter.MakeBlur( |
| 279 | + width * 0.05, |
| 280 | + width * 0.05, |
| 281 | + TileMode.Decal |
| 282 | + )} |
| 283 | + > |
| 284 | + <Circle |
| 285 | + cx={0.75 * width} |
| 286 | + cy={centreY} |
| 287 | + r={0.2 * width} |
| 288 | + color={[0.8, 0, 0, 1]} |
| 289 | + /> |
| 290 | + </Group> |
| 291 | + </Group> |
| 292 | + </> |
| 293 | + ); |
| 294 | + |
| 295 | + checkImage(img, docPath("group/bloom2.png")); |
| 296 | + }); |
203 | 297 | }); |
0 commit comments