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
FieldsFields inherited from class net.paulhertz.pixelaudio.PixelMapGen
coords, flipx, flipy, fx270, fx90, h, nada, pixelMap, r180, r270, r90, sampleMap, size, transArray, transformType, uniformTransArray, w -
Constructor Summary
ConstructorsConstructorDescriptionBoustropheGen(int width, int height) BoustropheGen(int width, int height, AffineTransformType type) -
Method Summary
Modifier and TypeMethodDescriptionstatic MultiGenboustrophRowOriented(int cols, int rows, int genW, int genH, AffineTransformType transform) Creates a MultiGen with rows * cols BoustropheGens oriented as specified bytransform.static MultiGenboustrophRowRandom(int cols, int rows, int genW, int genH) Creates a MultiGen with rows * cols randomly oriented BoustropheGens.describe()Returns a description of the mapping and initialization requirements of a PixelMapGen class.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) Validates parameters to a constructor.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, randomUniformTransform, setMapsFromCoords, setTransformType, transformCoords
-
Field Details
-
description
- See Also:
-
-
Constructor Details
-
BoustropheGen
public BoustropheGen(int width, int height) -
BoustropheGen
-
-
Method Details
-
describe
Description copied from class:PixelMapGenReturns a description of the mapping and initialization requirements of a PixelMapGen class.- Specified by:
describein classPixelMapGen- Returns:
- A String describing this class's mapping and initialization requirements
-
validate
public boolean validate(int width, int height) Description copied from class:PixelMapGenValidates parameters to a constructor.- 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 of int[], 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 randomly oriented BoustropheGens. The resulting Multigen will have dimensions width == (rows * genW) and height == (cols * genH).- 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 randomly oriented BoustropheGens
-
boustrophRowOriented
public static MultiGen boustrophRowOriented(int cols, int rows, int genW, int genH, AffineTransformType transform) Creates a MultiGen with rows * cols BoustropheGens oriented as specified bytransform. The resulting Multigen will have dimensions width == (rows * genW) and height == (cols * genH).- 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 PixelMapGentransform- an AffineTransformType applied to all BoustropheGens- Returns:
- a MultiGen created from rows * cols identically oriented BoustropheGens
-