Last active
November 26, 2020 22:26
-
-
Save stathissideris/5e536c800923a3a6fa1181e37672a8e3 to your computer and use it in GitHub Desktop.
Basic Clojure example for Skija
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
(ns skija.core | |
(:import [org.jetbrains.skija Canvas Surface Paint Color4f | |
EncodedImageFormat] | |
[java.nio.file Path Files OpenOption])) | |
(defn write-bytes [#^bytes b path] | |
(Files/write (Path/of "output.png" (make-array String 0)) b (make-array OpenOption 0))) | |
(defn show [] | |
(let [surface (Surface/makeRasterN32Premul 100 100) | |
canvas (.getCanvas surface) | |
paint (doto (Paint.) (.setColor4f (Color4f. (float 1) (float 0) (float 0))))] | |
(.drawCircle canvas 50 50 30 paint) | |
(write-bytes | |
(-> surface | |
.makeImageSnapshot | |
(.encodeToData EncodedImageFormat/PNG) | |
.getBytes) | |
"output.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
{:deps {org.clojure/clojure {:mvn/version "1.10.1"} | |
org.jetbrains.skija/skija-macos {:mvn/version "0.6.10"}} | |
:mvn/repos {"space-maven" {:url "https://packages.jetbrains.team/maven/p/skija/maven"}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on this example from the official docs https://github.com/JetBrains/skija/blob/master/docs/Getting%20Started.md#rendering-the-first-image