Created
January 7, 2023 18:07
-
-
Save wcandillon/7a0fb5cb8b1f00aeb154a4f8cacb674d to your computer and use it in GitHub Desktop.
Skia Shader Line SDF Starter
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
import React from "react"; | |
import { Canvas, Skia, Shader, Fill } from "@shopify/react-native-skia"; | |
const source = Skia.RuntimeEffect.Make(` | |
uniform float4 colors[4]; | |
vec4 main(vec2 xy) { | |
return colors[1]; | |
}`)!; | |
const colors = ["#dafb61", "#61DAFB", "#fb61da", "#61fbcf"].map((c) => | |
Skia.Color(c) | |
); | |
export const SDF = () => { | |
return ( | |
<Canvas style={{ flex: 1 }}> | |
<Fill> | |
<Shader source={source} uniforms={{ colors }} /> | |
</Fill> | |
</Canvas> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment