Class BoustropheGen

java.lang.Object
net.paulhertz.pixelaudio.PixelMapGen
net.paulhertz.pixelaudio.BoustropheGen

public class BoustropheGen extends PixelMapGen
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 Details

  • Constructor Details

    • BoustropheGen

      public BoustropheGen(int width, int height)
    • BoustropheGen

      public BoustropheGen(int width, int height, AffineTransformType type)
  • Method Details

    • describe

      public String describe()
      Specified by:
      describe in class PixelMapGen
      Returns:
      A String describing the mapping generated by your class and any initialization requirements.
    • validate

      public boolean validate(int width, int height)
      Specified by:
      validate in class PixelMapGen
      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:
      generate in class PixelMapGen
      Returns:
      this.pixelMap, the value for PixelAudioMapper.signalToImageLUT.
    • generateCoordinates

      private ArrayList<int[]> 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

      private ArrayList<int[]> generateBouCoordinates(int width, int height)
      The specific coordinate generation method for this class.
      Parameters:
      width - width of the 2D bitmap pixel array
      height - height of the 2D bitmap pixel array
      Returns:
      an array of coordinate pairs
    • boustrophRowRandom

      public static MultiGen boustrophRowRandom(int cols, int rows, int genW, int genH)
      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 wide
      rows - number of horizontal rows, same as number of gens high
      genW - width of an individual PixelMapGen
      genH - height of an indvidual PixelMapGen
      Returns:
      a MultiGen created from rows * cols PixelMapGens