-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement new color and image filters for RN Web (#840)
- Loading branch information
1 parent
d144625
commit 380a110
Showing
34 changed files
with
301 additions
and
138 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import React from "react"; | ||
|
||
import { docPath, processResult } from "../../__tests__/setup"; | ||
import { | ||
Fill, | ||
Image, | ||
Morphology, | ||
Offset, | ||
RoundedRect, | ||
Shadow, | ||
Text, | ||
} from "../components"; | ||
|
||
import { | ||
drawOnNode, | ||
loadFont, | ||
fontSize, | ||
loadImage, | ||
width, | ||
height, | ||
} from "./setup"; | ||
|
||
describe("Test Image Filters", () => { | ||
it("Should change the text morphology", () => { | ||
const font = loadFont("skia/__tests__/assets/Roboto-Medium.ttf", fontSize); | ||
const surface = drawOnNode( | ||
<> | ||
<Fill color="white" /> | ||
<Text text="Hello World" x={96} y={96} font={font} /> | ||
<Text text="Hello World" x={96} y={192} font={font}> | ||
<Morphology radius={3} /> | ||
</Text> | ||
<Text text="Hello World" x={96} y={288} font={font}> | ||
<Morphology radius={1} operator="erode" /> | ||
</Text> | ||
</> | ||
); | ||
processResult(surface, docPath("image-filters/morphology.png")); | ||
}); | ||
it("Should offset the image", () => { | ||
const image = loadImage("skia/__tests__/assets/oslo.jpg"); | ||
const surface = drawOnNode( | ||
<> | ||
<Fill color="lightblue" /> | ||
<Image | ||
image={image} | ||
x={0} | ||
y={0} | ||
width={width} | ||
height={height} | ||
fit="cover" | ||
> | ||
<Offset x={192} y={192} /> | ||
</Image> | ||
</> | ||
); | ||
processResult(surface, docPath("image-filters/offset.png")); | ||
}); | ||
it("Should draw a dropshadow", () => { | ||
const surface = drawOnNode( | ||
<> | ||
<Fill color="lightblue" /> | ||
<RoundedRect | ||
x={96} | ||
y={96} | ||
width={576} | ||
height={576} | ||
r={96} | ||
color="lightblue" | ||
> | ||
<Shadow dx={36} dy={36} blur={75} color="#93b8c4" /> | ||
<Shadow dx={-36} dy={-36} blur={75} color="#c7f8ff" /> | ||
</RoundedRect> | ||
</> | ||
); | ||
processResult(surface, docPath("image-filters/dropshadow.png")); | ||
}); | ||
|
||
it("Should draw a innershadow", () => { | ||
const surface = drawOnNode( | ||
<> | ||
<Fill color="lightblue" /> | ||
<RoundedRect | ||
x={96} | ||
y={96} | ||
width={576} | ||
height={576} | ||
r={96} | ||
color="lightblue" | ||
> | ||
<Shadow dx={36} dy={36} blur={75} color="#93b8c4" inner /> | ||
<Shadow dx={-36} dy={-36} blur={75} color="#c7f8ff" inner /> | ||
</RoundedRect> | ||
</> | ||
); | ||
processResult(surface, docPath("image-filters/innershadow.png")); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
package/src/renderer/__tests__/documentation/Mask.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from "react"; | ||
|
||
import { docPath, processResult } from "../../../__tests__/setup"; | ||
import { Group, Mask, Circle, Rect } from "../../components"; | ||
import { drawOnNode, width } from "../setup"; | ||
|
||
describe("Mask Documentation Examples", () => { | ||
it("Should draw an alpha mask", () => { | ||
const r = width / 2; | ||
const surface = drawOnNode( | ||
<> | ||
<Mask | ||
mask={ | ||
<Group> | ||
<Circle cx={r} cy={r} r={r} opacity={0.5} /> | ||
<Circle cx={r} cy={r} r={r / 2} /> | ||
</Group> | ||
} | ||
> | ||
<Rect x={0} y={0} width={r * 2} height={r * 2} color="lightblue" /> | ||
</Mask> | ||
</> | ||
); | ||
processResult(surface, docPath("mask/alpha-mask.png")); | ||
}); | ||
it("Should draw an luminance mask", () => { | ||
const r = width / 2; | ||
const surface = drawOnNode( | ||
<> | ||
<Mask | ||
mode="luminance" | ||
mask={ | ||
<Group> | ||
<Circle cx={r} cy={r} r={r} color="white" /> | ||
<Circle cx={r} cy={r} r={r / 2} color="black" /> | ||
</Group> | ||
} | ||
> | ||
<Rect x={0} y={0} width={r * 2} height={r * 2} color="lightblue" /> | ||
</Mask> | ||
</> | ||
); | ||
processResult(surface, docPath("mask/luminance-mask.png")); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.