/processing-skia

Eases Skija (Skia for Java) interoperability with Processing

Primary LanguageJava

processing-skia

Skia is an open source 2D graphics library which provides common APIs that work across a variety of hardware and software platforms.

Skija provides high-quality Java bindings for Skia.

processing-skia does the backend work of setting Skija's render target to Processing, so you can easily use any Skija bindings to draw into a Processing sketch.

Requirements

  • Java 11+
  • A Processing sketch using either the P2D or P3D renderer.

Download

Download the processing-skia jar from releases.

Example

Code

import micycle.processingSkia.SkiaCanvas;
import org.jetbrains.skija.*;

Canvas skiaCanvas;

@Override
public void settings() {
    size(800, 800, P2D);
}

@Override
public void setup() {
    skiaCanvas = SkiaCanvas.getSkiaCanvas(this);
}

@Override
public void draw() {
    background(255);
	
    Paint fill = new Paint().setShader(Shader.makeLinearGradient(400, 300, 400, 500, new int[] {0xFFFFA500, 0xFF4CA387}));
	
    skiaCanvas.drawCircle(400, 400, 200, fill);
}

Result

Example

Further Work

Further work would wrap the Skija library itself, creating Processing-like bindings around Skija's API (a PGraphicsSkia) leading to the possibility of a dedicated Skia-based renderer in Processing.

Another Example

This is the squares example as rendered in a Processing sketch. Here, the gradient fill and square-circle morphing provide features that are not easily attained in vanilla Processing, but are easily attained with the Skia renderer.

Example