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()
      Description copied from class: PixelMapGen
      Returns a description of the mapping and initialization requirements of a PixelMapGen class.
      Specified by:
      describe in class PixelMapGen
      Returns:
      A String describing this class's mapping and initialization requirements
    • validate

      public boolean validate(int width, int height)
      Description copied from class: PixelMapGen
      Validates parameters to a constructor.
      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 of int[], 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 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 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 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 by transform. The resulting Multigen will have dimensions width == (rows * genW) and height == (cols * genH).
      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
      transform - an AffineTransformType applied to all BoustropheGens
      Returns:
      a MultiGen created from rows * cols identically oriented BoustropheGens