Package net.paulhertz.pixelaudio
Class BoustropheGen
java.lang.Object
net.paulhertz.pixelaudio.PixelMapGen
net.paulhertz.pixelaudio.BoustropheGen
BoustropheGen generates a signal path that starts at (0,0) and reads left-to-right to (width-1, 0).
The path steps down to (width-1, 1) and reads right-to-left back to (0, 1). The path alternates
reading direction until it reaches the last pixel at (width-1, height-1) or (0, height-1). The name
is derived from the Greek "boustrophedon," a system of writing that makes an "ox turn" from one line
to the next. The boustrophedon signal path has better spatial coherence than the row major scanning
in general use for bitmaps.
BoustropheGen is also a good example of how easy it can be to implement a PixelMapGen child class.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBoustropheGen(int width, int height) BoustropheGen(int width, int height, AffineTransformType type) -
Method Summary
Modifier and TypeMethodDescriptionstatic MultiGenboustrophRowRandom(int cols, int rows, int genW, int genH) Creates a MultiGen with rows * cols BoustropheGens.describe()int[]generate()Initializes this.coords, this.pixelMap, this.sampleMap: this is handled by a call to PixelMapGen's setMapsFromCoords() method.private ArrayList<int[]>generateBouCoordinates(int width, int height) The specific coordinate generation method for this class.private ArrayList<int[]>Generically-named method that calls the custom coordinate generation method for a particular PixelMapGen child class.booleanvalidate(int width, int height) Methods inherited from class net.paulhertz.pixelaudio.PixelMapGen
findNearestPowerOfTwoLessThan, findPowerOfTwo, getCoordinates, getCoordinatesCopy, getHeight, getInversMapFromPixelArray, getPixelMap, getPixelMapCopy, getPixelMapFromCoordinates, getSampleMap, getSampleMapCopy, getSize, getTransformType, getWidth, isPowerOfTwo, loadIndexMaps, randomTransform, setMapsFromCoords, setTransformType, transformCoords
-
Field Details
-
description
- See Also:
-
-
Constructor Details
-
BoustropheGen
public BoustropheGen(int width, int height) -
BoustropheGen
-
-
Method Details
-
describe
- Specified by:
describein classPixelMapGen- Returns:
- A String describing the mapping generated by your class and any initialization requirements.
-
validate
public boolean validate(int width, int height) - Specified by:
validatein classPixelMapGen- Returns:
- true if the width and height parameters are valid for creating a mapping with this generator, otherwise, false.
-
generate
public int[] generate()Initializes this.coords, this.pixelMap, this.sampleMap: this is handled by a call to PixelMapGen's setMapsFromCoords() method.- Specified by:
generatein classPixelMapGen- Returns:
- this.pixelMap, the value for PixelAudioMapper.signalToImageLUT.
-
generateCoordinates
Generically-named method that calls the custom coordinate generation method for a particular PixelMapGen child class. Here the method is generateBouCoordinates(). Additional initializations belong here, if required by your coordinate generation method, rather than in the generate() method.- Returns:
- An ArrayList<int[]> of bitmap coordinates in the order the signal mapping would visit them.
-
generateBouCoordinates
The specific coordinate generation method for this class.- Parameters:
width- width of the 2D bitmap pixel arrayheight- height of the 2D bitmap pixel array- Returns:
- an array of coordinate pairs
-
boustrophRowRandom
Creates a MultiGen with rows * cols BoustropheGens. Note that you should set values for such that: (rows * genW) == width and (cols * genH) == height.- Parameters:
cols- number of vertical columns, same as number of gens widerows- number of horizontal rows, same as number of gens highgenW- width of an individual PixelMapGengenH- height of an indvidual PixelMapGen- Returns:
- a MultiGen created from rows * cols PixelMapGens
-