Here is an example sketch by Joshua Davis, from the hype framework that has been changed to make use of ruby syntax. The declared aim of the hype library is to provide:- A collection of classes that performs the heavy lifting so that you can create sketches with the minimum amount of code. When using the hype library to create JRubyArt sketches it is suggested that you not simply ape the hype framework examples, but tailor your sketches to take advantage of the ruby language to create even more elegant code (Code as Art), not that it is relevant here.

Unzip the library in the processing libraries folder, rename the folder hype, rename distribution folder to library, rename the HYPE.jar to hype.jar. Check that you can see the library from the processing-3.2.1 ide. Note that we can use snake case in place of camel case, for constants use :: and not . to call. The important thing to learn from this sketch is how to implement the HCallback interface. This can be implemented as a closure (block), note we do not/should not try and use the vanilla processing method.

In this case we use ruby syntax in the creation of web colors (as color int). As with other shader sketches the scanlines.glsl lives in the data folder.


# encoding: utf-8
# Using a simplified scanline shader, this example demonstrates how to apply
# a PShader to an HCanvas object.
# In the two swarms on screen, half of them have scanlines. These are the
# drawables that are children of the canvas. The scanline shader is directly
# applied to the HCanvas and does not affect the drawables on the stage.
# Set the HCanvas renderer to P2D or P3D when using HShaders
load_library :hype
include_package 'hype'
# Access through Hype namespace
module Hype
  java_import 'hype.extended.colorist.HColorPool'
  java_import 'hype.extended.behavior.HTimer'
  java_import 'hype.extended.behavior.HSwarm'

attr_reader :my_shader, :swarm, :timer
PALETTE = %w(#FFFFFF #F7F7F7 #ECECEC #333333 #0095a8 #00616f #FF3300 #FF6600).freeze

def settings
  size(640, 640, P3D)

def setup
  sketch_title 'Scanlines GLSL sketch'
  @my_shader = load_shader(data_path('scanlines.glsl'))
  my_shader.set('resolution', 1.0, 1.0)
  my_shader.set('screenres', width.to_f, height.to_f)
  my_shader.set('time', millis / 1000.0)
  colors =
  canvas_shader = H.add(
  swarm =
  pool1 =
       .on_create do |obj|
     .loc(width / 2, height / 2)
  pool2 =
       .on_create do |obj|
       .loc(width / 2, height / 2)
  @timer =
                       .callback do

def draw
  my_shader.set('time', millis / 1000.0)


	A basic scanline shader for Processing, based on MattiasCRT:


#ifdef GL_ES
precision mediump float;

uniform sampler2D texture;
varying vec4 vertTexCoord;
uniform vec2 resolution;
uniform vec2 screenres;
uniform float time;

void main(void) {

	vec3 iResolution = vec3(resolution,0.0);
	float iGlobalTime = time;

	vec2 q = vertTexCoord.xy / iResolution.xy;
	vec2 uv = q;
	vec4 col = texture2D(texture, vertTexCoord.xy);

	float scans = clamp( 0.35+0.35*sin(3.5 * iGlobalTime + uv.y * screenres.y * 2.0), 0.0, 1.0);
	float s = pow(scans,1.7);
	col = col * vec4(0.4 + 0.7 * s) ;

	col*=1.0-0.65*vec4(clamp((mod(vertTexCoord.x, 2.0)-1.0)*2.0,0.0,1.0));

	gl_FragColor = col;