Haxademic
Haxademic is my personal Processing-based creative coding toolkit, built to run in Eclipse with Java and the latest version of Processing. It's a starting point for interactive visuals, installations, rendering and writing Processing "sketches" in a more robust environment. It loads a bunch of useful Java/Processing libraries and contains a ton of other useful tools that I've written.
State of affairs
While the code has been open-sourced, I don't plan on making it easy/viable for others to use - I don't have the time or desire to support it. This repository is more about sharing the interesting code within, and I fully endorse borrowing it however you see fit.
Notable code
Below you'll find a long list of classes and utilities that I've built to make my life easier. I've tried to make as many basic demos as possible for all of these features. The demo
package mostly mirrors the core
directory and should give you an idea of how to implement these object on your own.
App
com.haxademic.core.app
-
PAppletHax - This is the base class for every Processing app that I build. It initializes tools for app-level concerns, rendering, multiple input devices, audio FFT, and debugging tools. Tons of additional tools and utilities can be found in the library.
-
P - This class holds static references and methods - primarily to the app instance so I don't have to pass it around everywhere.
-
AppWindow - This object helps set up properties related to the app window, which can mostly be configured in
Config
viaAppSettings
.
com.haxademic.core.app.config
-
AppSettings - Static constants to help set app properties and initialize special objects in
PAppletHax
. Used in tandem withConfig
. -
Config - Loads properties from
data/properties/run.properties
(or an additional custom .properties file), using the same string constants inAppSettings
. All of these properties can be overridden in PAppletHax in the automatically-calledconfig()
function on app initialization. Also helps access & parse command line arguments.
Data
com.haxademic.core.data
-
ConvertUtil - A collection of basic Java type-conversion methods.
-
Patterns - A collection of pattern generators for step sequencer.
com.haxademic.core.data.constants
-
GLBlendModes - Fancy OpenGL blend modes with helper methods to set them on a given PGraphics context.
-
PBlendModes - Static constants list of Processing blend modes.
-
PRenderers - Static constants list of Processing renderers.
-
PShapeTypes - Static constants list of Processing shape types.
-
PStrokeCaps - Static constants list of Processing stoke cap types.
-
PTextAlign - Static constants list of Processing text alignment options.
com.haxademic.core.data.store
-
AppStore - A singleton data store and emitter. As values are updated, subscribers are notified. Uses IAppStoreListener as the callback interface for
AppStore
updates. -
AppStoreDistributed - A WebSockets-enabled extension of
AppStore
to keep multiple machines in sync with a shared data structure.
Debug
com.haxademic.core.debug
- DebugView - Instantiated with every
PAppletHax
app viaP
, the object allows us to toggle and add relatime properties to theDebugView
HashMap and log values on-screen, rather than trying to watch Java console values fly by. Press/
to toggle. Also includes a panel for key commands and extra developer-defined info.
Draw
com.haxademic.core.draw.camera
- CameraUtil - Primarily just a helper method to increase the camera distance on a PGraphics context.
com.haxademic.core.draw.color
-
ColorsHax - Some predefined easy-to-use color palettes.
-
ColorUtil - Handy color conversion methods.
-
EasingColor - An object that represents a single color with interpolation and helpful getter/setter methods. Has some overlap with
ColorUtil
- the two classes should possibly be merged. -
ImageGradient - Loads an image and samples its colors horizontally via a normalized input float. Works well for gradients and comes with a library of presets.
com.haxademic.core.draw.context
-
OpenGLUtil - Lower-level helper methods to set OpenGL flags that aren't obviously available in Processing.
-
OrientationUtil - Helper methods to orient the graphics context rotation towards a specific 3d location. These utilities help point 3d objects toward each other.
-
PG - Lots of static helper methods to initialize and set properties on the specified PGraphics context. Used constantly throughout the core and demos.
-
PGraphics32 - A custom PGraphics object with 32-bit float texture enabled for use as a data texture in shaders.
com.haxademic.core.draw.filters.pgraphics
- A collection of PGraphics-based image/video filters. These effects redraw an image in traditional Processing style on a PGraphics buffer.
com.haxademic.core.draw.filters.pshader
- A collection of (over 100) PShader filter effects. These Java classes are convenience wrappers for GLSL programs/files and provide a common interface and (as minimal as) one-line implementations for shader filters. Shader uniforms are exposed through public setter methods.
com.haxademic.core.draw.image
-
AnimatedGifEncoder - Renders a gif file directly out of a Processing app. I've mostly abandoned this in favor of rendering a video, then using conversion tools like ffmpeg to more precisely convert to gif.
-
Base64Image - Encodes and decodes between a PImage and a base64-encoded string.
-
BlobFinder - Wraps v3ga's BlobDetection library with some GPU-accelerated enhancements.
-
BufferActivityMonitor - Gives us an "activity" rating of a moving image, like a webcam, video, or other PGraphics instance that animates. Useful for motion detection.
-
BufferColorObjectDetection - Finds the center of mass of a specific color (within a threshold) on an image. Useful for object tracking in controlled situations.
-
BufferMotionDetectionMap - Uses shaders for fast frame-diffing to detect motion between video/camera frames. Includes helpers to find random motion points in the motion map result.
-
BufferThresholdMonitor - Copies an image to a low-res buffer, runs a threshold filter, and counts white vs black pixels. Useful as a step in certain CV processes.
-
FrozenImageMonitor - Helps detect a frozen video stream (from a webcam, most likely). Camera feeds have some natural noise that will change over time, even if the subject doesn't. If the feed is frozen, this can be detected.
-
GridHelper - A UI-enabled grid-drawing tool to help align and design an app's graphics.
-
ImageCyclerBuffer - Uses GLSL transitions to create a slideshow from an array of PImages.
-
ImageSequenceMovieClip - Loads and plays back an image sequence like a Movie object does for video files.
-
ImageSequenceRecorder - Builds an array of PGraphics objects to record recent video frames and play them back for time distortion effects or short video compiling.
-
ImageUtil - Lots of tools for dealing with images and drawing them to screen.
-
OpticalFlow - A GPU-accelerated Optical flow algorithm, adapted from TouchDesigner's optical flow shader.
-
TickerScroller - Repeats a texture across a PGraphics and scrolls.
-
TiledTexture - A drawing helper that takes advantage of OpenGL's texture repeat function and lets us draw a rectangle with a texture fill. Includes zoom & rotation controls for fancy texture & pattern tiling.
com.haxademic.core.draw.mapping
-
BaseSavedQuadUI - Base class for
CaptureKeystoneToRectBuffer
andPGraphicsKeystone
. Stores/recalls a quad to text file and provides a GUI and keyboard controls to move the vertices. -
CaptureKeystoneToRectBuffer - Reverse-projection-mapping tool. Pulls from an image with a configurable quad and draws to a PGraphics instance.
-
PGraphicsKeystone - Projection-mapping tool. Draws a PGraphics buffer to screen, with custom keystoning backed by a text file.
-
SavedRectangle - Basic mapping tool. Provides rectangle data controlled by a mouse-based UI, backed by a text file.
com.haxademic.core.draw.particle
-
ForceDirectedLayout - Force-directed layout implementation.
-
ParticleLauncherGPU - GPU particle implementation.
-
VectorFlyer - 3D particle that flies toward a destination point.
com.haxademic.core.draw.shapes
-
Extrude2dPoints - Turns a set of 2d points into a 3d extrusion.
-
Icosahedron - Icosahedron generator, with optional texture application.
-
MarchingCubes - Marching cubes implementation.
-
MeshShapes - A collection of interesting generative mesh shape drawing functions.
-
LinesDeformAndTextureFilter - GPU displacement shader for a textured LINES PShape.
-
MeshDeformAndTextureFilter - GPU displacement shader for a standard PShape.
-
PointsDeformAndTextureFilter - GPU displacement shader for a textured POINTS PShape.
-
PShapeSolid - Accepts a SPhape and tracks shared vertices, providing multiple deformation strategies without letting connected triangles diverge.
-
PShapeUtil - A large collection of normalization, texturing and other manipulation methods to apply to PShape objects.
-
Shapes - Some custom mesh-drawing tools.
-
Superformula - A superformula implementation.
-
TextToPShape - Text with a custom font turned into a 2d or 3d mesh.
com.haxademic.core.draw.textures
- SimplexNoiseTexture - Fast simplex noise.
com.haxademic.core.draw.textures.pgraphics
- A collection of PGraphics-based realtime textures, originally built as "VJ" clips/layers.
com.haxademic.core.draw.textures.pshader
- A collection of (over 100) realtime shader textures, both original creations (prefixed with 'cacheflowe') and shaders ported from other artists on the web. Check the GLSL source for credits.
File
-
FileUtil - File & directory methods to help with file creation, deletion & listing.
-
PrefToText - Saves & retries a float/int/String value from a text file.
-
WatchDir - Watches a directory & provides a delegate callback when files have changed.
Hardware
-
DMXWrapper - Helper to "easily" connect and send messages to an ENTTEC DMX USB Pro.
-
GamepadState - Uses JInput to receive messages from a gamepad controller.
-
MidiText - Parses a MIDI file.
-
InputTrigger - Accepts multiple inputs to trigger the same action. Keystrokes, MIDI, OSC, HTTP and more.
-
IDepthCamera - Interface for
KinectWrapperV1
andKinectWrapperV2
andRealSenseWrapper
. -
KinectAmbientActivityMonitor - Provides a general ambient activity value for a room.
-
KinectRoomScanDiff - Scans a room with the Kinect, then watches for depth differences from scan.
-
KinectDepthSilhouetteSmoothed - A hardware-accelerated smoothed silhouette image from raw depth data.
-
KinectRegionGrid - Breaks up kinect raw data into an x/z grid, with center-of-mass (joystick) and
active
readings for each quadrant. -
Mouse - Automates, moves & clicks the system mouse with a Java Robot.
-
OscState - Wraps up OSC i/o functionality.
-
PrintPageDirect - Print an image to a physical printer directly from Processing.
-
SerialDevice - Basic input/output wrapping for Arduino and similar USB serial devices.
-
WebCam - Inits a webcam via singleton or normal instances, and receives new frames by implementing
IWebCamCallback
. It stores & recalls yourCapture
configuration for the next app launch.
Math
-
DisplacementPoint - Elastic displacement from a static point, based on an influencing external point.
-
EasingBoolean - Lerps towards true or false over time. Switches when it reaches the end. Useful for dealing with noisy data.
-
EasingFloat - Lerps towards a target. Includes optional frame delay and acceleration.
-
ElasticFloat - Lerps towards a target with Hooke's law springiness. Configurable friction and acceleration.
-
FloatBuffer - A FIFO buffer of incoming float values for smoothing purposes.
-
LinearFloat - Linearly lerps towards a target. Includes optional frame delay. Works great in tandem with
Penner
equations. -
Penner - Robert Penner's easing equations.
-
MathUtil - Lots of useful math utility functions.
-
SphericalCoord - Spherical coordinate helper functions.
Media
com.haxademic.core.media
-
DemoAssets - A collection of media files (svg, obj, png, ttf, mp4) to help quickly load an asset for demo purposes. Files are pulled from
data/haxademic/
. -
MediaTimecodeTrigger - A helper object to run callbacks as audio or video playback reaches specified timecodes. Could be used for any time-tracked event triggering.
com.haxademic.core.media.audio.playback
- WavPlayer - Play a .wav file with Beads and cache for future plays.
com.haxademic.core.media.audio.input
-
NormalizeMonoWav - Normalizes a mono .wav file without any external libraries.
-
WavRecorder - Record a .wav file with Minim.
com.haxademic.core.media.audio.analysis
-
AudioIn - A singleton to initialize a given IAudioInput object and route microphone input, or audio file playback FFT into a global analysis object, easily accessed from around the codebase.
-
AudioStreamData - The common data storage object for audio analysis results.
-
IAudioInput - A common interface between several Java libraries that run FFT analysis and beat detection on an incoming audio signal. Choose between Beads, Minim, ESS or Processing Sound, via AppSettings.
com.haxademic.core.media.video
-
MovieFinishedListener - Adds a native listener for video playback completion.
-
MovieToImageSequence - Loads frames from a video into an array of PImages in realtime. Useful for fancier & faster playback/scrubbing through video frames without relying on Movie decoding once the frames are extracted.
Net
-
DashboardPoster - Post debug info & screenshots to a web-based dashboard.
-
FileDownloader - Download a file from the web to a local directory.
-
IPAddress - Get the local machine's IP address.
-
JsonRequest - Make a JSON request to a web server.
-
JsonUtil - JSON formatting utility.
-
SocketServer - Run a websocket server with Java-WebSocket.
-
WebServer - Run a web server with Jetty.
Render
-
FrameLoop - Frame-counting helper to build looping animations, trigger looping events based on
frameCount
, and provide global access to frame-based calculations. -
GifRenderer - Auto-render gifs from the app.
-
ImageSequenceRenderer - Auto-render an image sequence from the app.
-
JoonsWrapper - Render high-quality raytraced geometry with Joons.
-
VideoRenderer - Render a video directly from the app.
System
-
AppRestart - Kills & restarts the app!
-
AppUtil - Set app window properties and generate the script that was used to launch the app.
-
CrashMonitor - Launches a 2nd app window to monitor the first, in case of a crash.
-
DateUtil - Date & time helper functions.
-
JavaInfo - Tons of methods to print out Java & system properties.
-
SecondScreenViewer - Launches a 2nd, scaled-down window to monitor the main window from a 2nd monitor.
-
ScriptRunner - Cross-platform script runner - makes up for the difference between .cmd/bat and .sh scripts. Works with
IScriptCallback
delegate to callback when the script finishes. -
SystemUtil - Get a timestamp, take a screenshot, copy text to clipboard, open a web browser, check/kill system processes, run a Timer.
Text
-
FitTextSourceBuffer - Generates a tightly-cropped texture from a String with a custom PFont.
-
RandomStringUtil - Generates random Strings.
-
StringBufferLog - Generates a buffer of text for an on-screen log tail.
-
StringFormatter - Format numbers to strings.
UI
-
UISlider - A text file-backed slider UI.
-
UISlider - A text file-backed slider UI.
-
UIButton - A Button object with optional toggle mode.
-
UI - A collection of
IUIControl
objects, auto-initialized with a PAppletHax app viaP
. Press\
to toggle paneL, and add new sliders/buttons with static methods onUI
.
Run on Mac M1/M2
brew install --cask eclipse-java
- In .classpath, set
CLASSPATH_ATTR_LIBRARY_PATH_ENTRY
tomacos-aarch64
- Add native library reference to jogl-all.jar
<classpathentry kind="lib" path="lib/processing-4/core/library/jogl-all.jar"> <attributes> <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="haxademic/lib/processing-4/core/library/macos-aarch64"/> </attributes> </classpathentry>
- Remove .classpath jna.jar entires that aren't the processing/video version
Or in VSCode
"java.project.importHint": false,
"java.debug.settings.vmArgs": "-Xmx4G -Xms2G -Djava.library.path=lib/jinput/native;lib/jvsthost;lib/KinectPV2/library;lib/LeapMotionForProcessing/library/windows64;lib/processing-4/libraries/javafx/library/windows-amd64;lib/processing-4/libraries/video/library/windows-amd64;lib/spout/library",
"[java]": {
"editor.defaultFormatter": "redhat.java"
},
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "C:\\Program Files\\Eclipse Adoptium\\jdk-17.0.6-Processing",
"default": true
}
],
{
"type": "java",
"name": "Demo_VertexShader_GPUParticlesLauncher",
"request": "launch",
"mainClass": "com.haxademic.demo.draw.shapes.shader.Demo_VertexShader_GPUParticlesLauncher",
"projectName": "haxademic",
"args": "testArg arg=1 agr2=2",
"vmArgs": "-Xmx8G -Xms2G -Djava.library.path=lib/KinectPV2/library;lib/processing-4/libraries/serial/library/windows64"
},
Dependencies
Haxademic uses the following Java & Processing libraries, which I've included in this repository so you don't have to find them yourself (more on that below):
- Processing Core
- Beads
- blobDetection
- DMXP512
- ESS
- Geomerative
- He_Mesh
- Java-WebSocket
- jetty
- JInput
- jnajack
- Joons renderer
- KinectPV2
- Leap Motion for Processing
- minim
- oscP5
- Poly2Tri
- RealSenseProcessing
- sphinx4
- Spout
- Super CSV
- simple-openni
- themidibus
- toxiclibs
- UDP Processing Library
- UMovieMaker
- zxing4processing
Licensing
The Haxademic codebase is MIT licensed, so do what you want with these files. Feel free to let me know that you're using it for something cool. I've added 3rd-party .jar files and compiled Java libraries that I'm probably not actually allowed to redistribute here, so if you're the owner of one of those libraries and would like the files removed, let me know. I've included them to aid those who would like a quick start and not have to search for the many dependencies of this project. Some of these libraries have disappeared from the web entirely, so searching for them may be futile anyway. I just want people to make cool things with this library, and hope you understand.