Class MultiGenDemo

java.lang.Object
processing.core.PApplet
net.paulhertz.pixelaudio.example.MultiGenDemo
All Implemented Interfaces:
processing.core.PConstants

public class MultiGenDemo extends processing.core.PApplet

MultiGenDemo: How to Combine Gens into a MultiGen

MultiGen is child class of PixelMapGen that allows you to combine multiple PixelMapGens into a single PixelMapGen, with a single signal path through all the gens. There are four different constructors that you can use. The first two, MultiGen(int width, int height) and MultiGen(int width, int height, AffineTransformType type), create two DiagonalZigzagGens to fill whatever width and height you provide. Things get interesting with the two custom constructors, MultiGen(int width, int height, int rows, int columns, ArrayList genList) and MultiGen(int width, int height, ArrayList<int[]> offsetList, ArrayList genList).

Both custom constructors require an ArrayList of PixelMapGens. The dimensions of the gens should be tailored for the width and height of the application window, so that width == rows * genWidth and height == columns * genHeight. In the first custom constructor, the number of rows and columns is used to calculate the dimensions of the gens. It's easy to use.

The second custom constructor is the more flexible of the two. In the second constructor, you can specify the location of the top left corner of each gen in offsetList, an ArrayList of int[] arrays that specify x and y offsets for each gen in the genList. With some planning of the spatial location and the AffineTransformType applied to each gen in the genlist, you can often create a continuous signal path through the final image. This application demonstrates how to do that with HilbertGens.

The PixelMapGen subclasses HilbertGen, DiagonalZigzagGen, and BoustropheGen include various static methods to generate MultiGen objects. Check them out.

Animation helps to visualize the orientation of PixelMapGen objects. Press 'a' to toggle animation that shifts pixels along the signal path.

 KEY COMMANDS
 
 Press 'a' to toggle animation.
 Press 'd' to show default MultiGen.
 Press 't' to step through transformed MultiGen objects.
 Press 'r' to show random mix of HilbertGen and DiagonalZigzagGen objects with a discontinuous signal path.
 Press 'c' to show a MultiGen made of HilbertGen objects with a continuous signal path.
 Press 'C' to show a MultiGen made with a mix of HilbertGen and DiagonalZigzagGen objects with a continuous path.
 Press 'h' to show help message in Console.
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) processing.core.PImage
     
    (package private) int
     
    (package private) AffineTransformType[]
     
     
     
     
     
    (package private) PixelMapGen
     
    (package private) int
     
    (package private) int
     
    (package private) HilbertGen
     
    (package private) boolean
     
    (package private) processing.core.PImage
     
    (package private) PixelAudioMapper
     
    (package private) MultiGen
     
     
    (package private) PixelAudio
     
     
     
     
    (package private) Random
     
    (package private) int
     
    (package private) int
     
    (package private) int[]
     
    (package private) int
     
    (package private) int
     

    Fields inherited from class processing.core.PApplet

    args, ARGS_BGCOLOR, ARGS_DISABLE_AWT, ARGS_DISPLAY, ARGS_EDITOR_LOCATION, ARGS_EXTERNAL, ARGS_FULL_SCREEN, ARGS_HIDE_STOP, ARGS_LOCATION, ARGS_PRESENT, ARGS_SKETCH_FOLDER, ARGS_STOP_COLOR, ARGS_UI_SCALE, ARGS_WINDOW_COLOR, DEFAULT_HEIGHT, DEFAULT_WIDTH, disableAWT, displayHeight, displayWidth, dmouseX, dmouseY, emouseX, emouseY, exitCalled, EXTERNAL_MOVE, EXTERNAL_STOP, finished, firstMouse, focused, frameCount, frameRate, frameRateLastNanos, g, height, insideDraw, javaPlatform, javaVersion, javaVersionName, key, keyCode, keyEvent, keyPressed, keyRepeatEnabled, looping, matchPatterns, mouseButton, mouseEvent, mousePressed, mouseX, mouseY, pixelDensity, pixelHeight, pixels, pixelWidth, platform, pmouseX, pmouseY, ratioLeft, ratioScale, ratioTop, recorder, redraw, rheight, rmouseX, rmouseY, rwidth, surface, useNativeSelect, width, windowX, windowY

    Fields inherited from interface processing.core.PConstants

    ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ASYNC_SAVEFRAME, DISABLE_BUFFER_READING, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_KEY_REPEAT, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ASYNC_SAVEFRAME, ENABLE_BUFFER_READING, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_KEY_REPEAT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, FX2D, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOS, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPAN, SPHERE, SPOT, SQUARE, SUBTRACT, SVG, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
     
    void
     
    int[]
     
    hilbertLoop3x2(int genW, int genH)
    Generates a looping fractal signal path consisting of 6 HilbertGens, arranged 3 across and 2 down, to fit a 3 * genW by 2 * genH image.
    hilbertZigzagLoop6x4(int genW, int genH)
    Shows how to create a MultiGen object using arrays of locations, transforms, and cues.
    void
     
    static void
    main(String[] args)
     
     
     
     
    void
     
    void
     
    void
     
    void
     
     

    Methods inherited from class processing.core.PApplet

    abs, abs, acos, alpha, ambient, ambient, ambient, ambientLight, ambientLight, append, append, append, append, append, append, applyMatrix, applyMatrix, applyMatrix, applyMatrix, applyMatrix, arc, arc, arraycopy, arraycopy, arraycopy, arrayCopy, arrayCopy, arrayCopy, asin, atan, atan2, attrib, attrib, attrib, attribColor, attribNormal, attribPosition, background, background, background, background, background, background, background, beginCamera, beginContour, beginPGL, beginRaw, beginRaw, beginRecord, beginRecord, beginShape, beginShape, bezier, bezier, bezierDetail, bezierPoint, bezierTangent, bezierVertex, bezierVertex, binary, binary, binary, binary, blend, blend, blendColor, blendMode, blue, box, box, brightness, calcSketchPath, camera, camera, ceil, checkAlpha, checkExtension, choice, choice, circle, clear, clip, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, concat, concat, concat, concat, concat, concat, concat, constrain, constrain, copy, copy, copy, cos, createFont, createFont, createFont, createGraphics, createGraphics, createGraphics, createImage, createInput, createInput, createInputRaw, createOutput, createOutput, createPath, createPath, createPrimaryGraphics, createReader, createReader, createReader, createShape, createShape, createShape, createWriter, createWriter, createWriter, cursor, cursor, cursor, cursor, curve, curve, curveDetail, curvePoint, curveTangent, curveTightness, curveVertex, curveVertex, dataFile, dataPath, day, debug, degrees, delay, dequeueEvents, desktopFile, desktopPath, die, die, directionalLight, displayDensity, displayDensity, dispose, dist, dist, edge, ellipse, ellipseMode, emissive, emissive, emissive, endCamera, endContour, endPGL, endRaw, endRecord, endShape, endShape, exec, exec, exit, exitActual, exitCalled, exp, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, fill, fill, fill, fill, fill, fill, filter, filter, filter, floor, flush, focusGained, focusLost, frameMoved, frameRate, frustum, fullScreen, fullScreen, fullScreen, fullScreen, get, get, get, getExtension, getGraphics, getMatrix, getMatrix, getMatrix, getSurface, green, handleDraw, handleKeyEvent, handleMethods, handleMouseEvent, hex, hex, hex, hex, hideMenuBar, hint, hour, hue, image, image, image, imageMode, initSurface, insertFrame, isLooping, join, join, keyPressed, keyReleased, keyReleased, keyTyped, keyTyped, launch, lerp, lerpColor, lerpColor, lightFalloff, lights, lightSpecular, line, line, link, listFiles, listFiles, listPaths, loadBytes, loadBytes, loadBytes, loadFont, loadImage, loadImage, loadJSONArray, loadJSONArray, loadJSONObject, loadJSONObject, loadPixels, loadShader, loadShader, loadShape, loadShape, loadStrings, loadStrings, loadStrings, loadStrings, loadTable, loadTable, loadXML, loadXML, log, loop, mag, mag, main, main, main, makeGraphics, map, mask, match, matchAll, max, max, max, max, max, max, method, millis, min, min, min, min, min, min, minute, modelX, modelY, modelZ, month, mouseClicked, mouseClicked, mouseDragged, mouseDragged, mouseEntered, mouseEntered, mouseExited, mouseExited, mouseMoved, mouseMoved, mousePressed, mousePressed, mouseReleased, mouseReleased, mouseWheel, mouseWheel, nf, nf, nf, nf, nf, nf, nfc, nfc, nfc, nfc, nfp, nfp, nfp, nfp, nfs, nfs, nfs, nfs, noClip, noCursor, noFill, noise, noise, noise, noiseDetail, noiseDetail, noiseSeed, noLights, noLoop, norm, normal, noSmooth, noStroke, noTexture, noTint, orientation, ortho, ortho, ortho, parseBoolean, parseBoolean, parseBoolean, parseBoolean, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseChar, parseChar, parseChar, parseChar, parseFloat, parseFloat, parseFloat, parseFloat, parseFloat, parseFloat, parseFloat, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseJSONArray, parseJSONObject, parseXML, parseXML, pause, perspective, perspective, pixelDensity, point, point, pointLight, pop, popMatrix, popStyle, postEvent, postWindowMoved, postWindowResized, pow, print, print, print, print, print, print, print, print, print, printArray, printCamera, println, println, println, println, println, println, println, println, println, println, println, printMatrix, printProjection, printStackTrace, push, pushMatrix, pushStyle, quad, quadraticVertex, quadraticVertex, radians, random, random, randomGaussian, randomSeed, rect, rect, rect, rectMode, red, redraw, registerMethod, requestImage, requestImage, resetMatrix, resetShader, resetShader, resume, reverse, reverse, reverse, reverse, reverse, reverse, reverse, rotate, rotate, rotateX, rotateY, rotateZ, round, runSketch, runSketch, runSketch, saturation, save, saveBytes, saveBytes, saveBytes, saveFile, saveFrame, saveFrame, saveJSONArray, saveJSONArray, saveJSONObject, saveJSONObject, savePath, saveStream, saveStream, saveStream, saveStream, saveStream, saveStrings, saveStrings, saveStrings, saveTable, saveTable, saveXML, saveXML, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, second, selectCallback, selectFolder, selectFolder, selectFolder, selectInput, selectInput, selectInput, selectOutput, selectOutput, selectOutput, set, set, setMatrix, setMatrix, setMatrix, setSize, shader, shader, shape, shape, shape, shapeMode, shearX, shearY, shell, shininess, shorten, shorten, shorten, shorten, shorten, shorten, shorten, showDepthWarning, showDepthWarningXYZ, showMethodWarning, showMissingWarning, showSurface, showVariationWarning, sin, size, size, size, sketchDisplay, sketchFile, sketchFullScreen, sketchHeight, sketchOutputPath, sketchOutputStream, sketchPath, sketchPath, sketchPixelDensity, sketchRenderer, sketchSmooth, sketchWidth, sketchWindowColor, smooth, smooth, sort, sort, sort, sort, sort, sort, sort, sort, sort, sort, specular, specular, specular, sphere, sphereDetail, sphereDetail, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, split, split, splitTokens, splitTokens, spotLight, sq, sqrt, square, start, startSurface, stop, str, str, str, str, str, str, str, str, str, str, stroke, stroke, stroke, stroke, stroke, stroke, strokeCap, strokeJoin, strokeWeight, style, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, tan, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textAscent, textDescent, textFont, textFont, textLeading, textMode, textSize, texture, textureMode, textureWrap, textWidth, textWidth, textWidth, thread, tint, tint, tint, tint, tint, tint, translate, translate, triangle, trim, trim, unbinary, unhex, unregisterMethod, updatePixels, updatePixels, urlDecode, urlEncode, vertex, vertex, vertex, vertex, vertex, windowMove, windowMoved, windowRatio, windowResizable, windowResize, windowResized, windowTitle, year

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • MultiGenDemo

      public MultiGenDemo()
  • Method Details

    • main

      public static void main(String[] args)
    • settings

      public void settings()
      Overrides:
      settings in class processing.core.PApplet
    • setup

      public void setup()
      Overrides:
      setup in class processing.core.PApplet
    • defaultMultiGen

      public MultiGen defaultMultiGen()
    • transformMultiGen

      public MultiGen transformMultiGen()
    • multiGenFromGenList

      public MultiGen multiGenFromGenList()
    • multiGenFromGenAndOffsetLists

      public MultiGen multiGenFromGenAndOffsetLists()
    • hilbertLoop3x2

      public MultiGen hilbertLoop3x2(int genW, int genH)
      Generates a looping fractal signal path consisting of 6 HilbertGens, arranged 3 across and 2 down, to fit a 3 * genW by 2 * genH image. Shows how to create custom a MultiGen with a genList and an offsetList. This method creates a MultiGen instance from a list of PixelMapGen objects (genList) and a list of coordinate points (offsetList) where they will be displayed. The MultiGen class creates a single signal path over all its PixelMapGen objects. The path may be *continuous*, which is to say that the path through each PixelMapGen object ("gen" for short) only has to step one pixel up, down, left, or right to connect to the next gen. It may even create a *loop*, where the last pixel in the path is one step away from the first pixel. This method creates a MultiGen that is both continuous and looped. This method may be called as factory method of the HilbertGen class: public static MultiGen hilbertLoop3x2(int genW, int genH) example: MultiGen multigen = HilbertGen.hilbertLoop3x2(genWidth, genHeight); Note that genH must equal genW and both must be powers of 2. For the image size we're using in this example, genW = image width / 3 and genH = image height / 2.
      Parameters:
      genW - width of each HilbertGen
      genH - height of each HilbertGen
      Returns:
      a MultiGen consisting of 6 HilbertGens linked together by one signal path
    • hilbertZigzagLoop6x4

      public MultiGen hilbertZigzagLoop6x4(int genW, int genH)
      Shows how to create a MultiGen object using arrays of locations, transforms, and cues. The cues are used to select a PixelMapGen subclass. This method creates a MultiGen consisting of a mix of zigzag and Hilbert curves in 6 columns and 4 rows arranged to provide a continuous loop. The resulting MultiGen will be 6 * genW wide by 4 * genH high, where genW == genH and genW is a power of 2 (required for Hilbert gens). Copied from a static method in MultiGen.
      Parameters:
      genW - width of each gen, must be a power of 2 and equal to genW
      genH - height of each gen, must be a power of 2 and equal to genW
      Returns:
    • getColors

      public int[] getColors()
    • draw

      public void draw()
      Overrides:
      draw in class processing.core.PApplet
    • keyPressed

      public void keyPressed()
      Overrides:
      keyPressed in class processing.core.PApplet
    • showHelp

      public void showHelp()
    • animate

      public void animate()
    • refreshImages

      public void refreshImages()
    • nextTransform

      public AffineTransformType nextTransform()