Class Argosy
- Author:
- Paul Hertz
Argosy provides tools for shifting pixel patterns along the signal path of an image. One way to generate the pixel patterns is with the Lindenmayer class. The patterns are generated by arrays of numbers ("argosy patterns") and arrays of colors, with a gap in between each repeated pattern. The patterns could also be interpreted as rhythmic values in music, and the colors as timbre or instrumentation. Both music and visual patterns can be generated by a Lindenmayer pattern or "L-system."
The Argosy class create pixel patterns ordered by the signal path of a PixelAudioMapper. Argosy patterns consist of an array of numbers (argosyArray), an array of colors (argosyColors), a gap between patterns (unitSize * argosyGapScale) and a color for the gap (argosyGapColor). Each number in the pattern array determines the length of a run of pixels in a color specified by the color array. The Argosy pattern maker steps through the pattern, scaling it by unitSize, and assigns it the current color in the argosyColors, which it also steps through. The arrays do not have to be the same size.
TODO implement pixel offset TODO interpolating version of Argosy patterns, with floating point pattern values TODO dynamic functional version of patterns and other parameters TODO perhaps filling should permit one less gap than repetitions of pattern -- the first and last pattern will abut more precisely, we should provide conditions for partial filling (but not in version 1).
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) floatsubunit divisor for animStepstatic final int[](package private) int[]Array of color values used for animation by rotating the array left or right(package private) int[]default colors for argosy units(package private) intnumber of pixels in the gap between argosy patterns(package private) intcolor of pixels in the gap(package private) floatscaling for number of units in gap between argosies(package private) int[]array of number of pixels in each element of the expanded argosy pattern(package private) intmargin on either side of the argosy patterns(package private) intpixel count by which to shift the argosy pixels at initialization(package private) int[]current pattern to fill bigArray(package private) intthe number of pixels the array has shifted from its initial state(package private) inthow many times to repeat the pattern, 0 to fill array(package private) intcount the number of unit shifts(package private) intsum of values in argosy pattern(package private) intnumber of pixels in a shiftLeft animation Step(package private) intthe number of pixels in an argosy unit(package private) intbackground color, fills the argosy array before colors are added(package private) booleancenter the argosy patterns in the big array(package private) booleando we count the shift or not?(package private) PixelAudioMapperPixelAudioMapper that provides values for several variables and maps bigArray to bitmaps or audio signals(package private) intmaximum number of repetitions, used internally -
Constructor Summary
ConstructorsConstructorDescriptionArgosy(PixelAudioMapper mapper, int[] pattern, int unitSize, int reps, boolean isCentered, int[] colors, int gap, int gapColor, int animStep) Argosy(PixelAudioMapper mapper, int unitSize, int reps, boolean isCentered) Argosy(PixelAudioMapper mapper, int unitSize, int reps, boolean isCentered, int[] colors, int gapColor, float gapScale, int[] pattern) -
Method Summary
Modifier and TypeMethodDescriptionvoidFillsargosyArraywith colors from argosyColors following the argosy pattern stored in argosyIntervals.fibo(int depth, boolean verbose) An L-System generator for Fibonacci trees represented as a sequence of 0s and 1s.static int[]fibonacciPattern(int depth, int v1, int v2, boolean verbose) Generates an argosy pattern based on a Fibonacci tree.floatint[]int[]int[]intintfloatintintint[]intintfloat[]float[]getArgosySignal(float scale) float[]float[]getArgosySignal(PixelAudioMapper.ChannelNames chan, float scale) intintintintintvoidSets up the argosy array and fills it with colors using the argosy pattern.private voidreverseArray(int[] arr, int l, int r) Reverses an arbitrary subset of an array.voidrotateLeft(int d) Rotates bigArray left by d values.voidsetAnimStepDivisor(float animStepDivisor) voidsetArgosyArray(int[] newArgosyArray) voidsetArgosyColors(int[] argosyColors) Sets new argosyColors and triggers a call to initArgosy() to reset the pattern in argosyArray.voidsetArgosyGap(int argosyGap) Sets argosyGap and triggers a call to initArgosy() to reset the pattern in argosyArray.voidsetArgosyGapColor(int argosyGapColor) Sets argosyGapColor and triggers a call to argosyFill() to reset the pattern in bigArray.voidsetArgosyGapScale(float argosyGapScale) Sets argosyGapScale and triggers a call to initArgosy() to reset the pattern in argosyArray.voidsetArgosyOffset(int argosyOffset) voidsetArgosyPattern(int[] pattern) Sets a new argosy pattern and triggers a call to argosyFill() to reset the pattern in bigArray.voidsetArgosyPixelShift(int newShift) voidsetArgosyReps(int newReps) voidsetArgosyStep(int argoStep) Set the animStep, with no side effects (but animation calls will use the new value)voidsetBgColor(int bgColor) voidsetNewColors(int[] argosyColors, int argosyGapColor) Sets new argosy colors and argosy gap color, triggers a call to argosyFill().voidsetUnitSize(int unitSize) Sets unitSize and triggers a call to initArgosy() to reset the pattern in argosyArray.voidshift(int pixelShift, boolean isCounted) Shifts left by a specified number of pixels, summing them to argosyPixelShift if isCounted is true.voidbasic animation, rotate left by animStep pixels, increment the step counter argosyShiftStepvoidbasic animation, rotate right by animStep pixels, decrement the step counter argosyShiftStepvoid
-
Field Details
-
mapper
PixelAudioMapper mapperPixelAudioMapper that provides values for several variables and maps bigArray to bitmaps or audio signals -
argosyArray
int[] argosyArrayArray of color values used for animation by rotating the array left or right -
argosyUnitSize
int argosyUnitSizethe number of pixels in an argosy unit -
argosyStep
int argosyStepnumber of pixels in a shiftLeft animation Step -
animStepDivisor
float animStepDivisorsubunit divisor for animStep -
bgColor
int bgColorbackground color, fills the argosy array before colors are added -
argosyColors
int[] argosyColorsdefault colors for argosy units -
argosyGapScale
float argosyGapScalescaling for number of units in gap between argosies -
argosyGap
int argosyGapnumber of pixels in the gap between argosy patterns -
argosyGapColor
int argosyGapColorcolor of pixels in the gap -
argosyReps
int argosyRepshow many times to repeat the pattern, 0 to fill array -
maxReps
int maxRepsmaximum number of repetitions, used internally -
argosyMargin
int argosyMarginmargin on either side of the argosy patterns -
argosyPattern
int[] argosyPatterncurrent pattern to fill bigArray -
argosySize
int argosySizesum of values in argosy pattern -
isCentered
boolean isCenteredcenter the argosy patterns in the big array -
argosyIntervals
int[] argosyIntervalsarray of number of pixels in each element of the expanded argosy pattern -
argosyPixelShift
int argosyPixelShiftthe number of pixels the array has shifted from its initial state -
isCountShift
boolean isCountShiftdo we count the shift or not? -
argosyShiftStep
int argosyShiftStepcount the number of unit shifts -
argosyOffset
int argosyOffsetpixel count by which to shift the argosy pixels at initialization -
argosy55
public static final int[] argosy55
-
-
Constructor Details
-
Argosy
- Parameters:
mapper- PixelAudioMapperunitSize- size of a unit of the argosyreps- number of repetitions of the argosy pattern, pass in 0 for maximum that fitisCentered- true if argosy array should be centered in bigArray
-
Argosy
public Argosy(PixelAudioMapper mapper, int unitSize, int reps, boolean isCentered, int[] colors, int gapColor, float gapScale, int[] pattern) - Parameters:
mapper- PixelAudioMapperunitSize- size of a unit of the argosyreps- number of repetitions of the argosy pattern, pass in 0 for maximum that fitisCentered- true if argosy array should be centered in bigArraycolors- an array of colors for the argosy patternsgapColor- a color for the spaces between argosy patternsgapScale- scaling for number of units in gap between argosiespattern- a pattern of numbers, will be copied to argosyPattern
-
Argosy
public Argosy(PixelAudioMapper mapper, int[] pattern, int unitSize, int reps, boolean isCentered, int[] colors, int gap, int gapColor, int animStep) - Parameters:
mapper- PixelAudioMapperpattern- a pattern of numbers, will be copied to argosyPatternunitSize- size of a unit of the argosyreps- number of repetitions of the argosy pattern, pass in 0 for maximum that fitisCentered- true if argosy array should be centered in bigArraycolors- an array of colors for the argosy patternsgap- number of pixels in gap between pattern repeats (argosyGapScale * argosyUnitSize)gapColor- a color for the spaces between argosy patternsanimStep- number of pixels on each animation step, when calling shiftLeft() or shiftRight()
-
-
Method Details
-
initArgosy
public void initArgosy()Sets up the argosy array and fills it with colors using the argosy pattern. -
argosyFill
public void argosyFill()FillsargosyArraywith colors from argosyColors following the argosy pattern stored in argosyIntervals. Tbis method is generally called from initArgosy(), which fills argosyArray with the bgColor pixels. -
rotateLeft
public void rotateLeft(int d) Rotates bigArray left by d values. Uses efficient "Three Rotation" algorithm.- Parameters:
d- number of elements to shift
-
reverseArray
private void reverseArray(int[] arr, int l, int r) Reverses an arbitrary subset of an array.- Parameters:
arr- array to modifyl- left bound of subset to reverser- right bound of subset to reverse
-
shiftRight
public void shiftRight()basic animation, rotate right by animStep pixels, decrement the step counter argosyShiftStep -
shiftLeft
public void shiftLeft()basic animation, rotate left by animStep pixels, increment the step counter argosyShiftStep -
getArgosyPixelShift
public int getArgosyPixelShift()- Returns:
- the argosyPixelShift, save this if you want to reshift
-
setArgosyPixelShift
public void setArgosyPixelShift(int newShift) -
zeroArgosyPixelShift
public void zeroArgosyPixelShift() -
shift
public void shift(int pixelShift, boolean isCounted) Shifts left by a specified number of pixels, summing them to argosyPixelShift if isCounted is true. This is the most flexible animation method with animation steps set externally. The other methods, shiftLeft() and shiftRight(), use this.animStep to determine pixel shift.- Parameters:
pixelShift-isCounted-
-
getArgosyArray
public int[] getArgosyArray()- Returns:
- argosyArray, not a copy
-
getArgosyArrayCopy
public int[] getArgosyArrayCopy()- Returns:
- a copy of argosyArray
-
setArgosyArray
public void setArgosyArray(int[] newArgosyArray) - Parameters:
newArgosyArray- the int[] array to set, must be same length as this.argosyArray.
-
getArgosySignal
public float[] getArgosySignal() -
getArgosySignal
-
getArgosySignal
public float[] getArgosySignal(float scale) -
getArgosySignal
-
getArgosySize
public int getArgosySize()- Returns:
- argosySize, the number of argsoyUnits in argosyPattern
-
getUnitSize
public int getUnitSize()- Returns:
- the unitSize
-
setUnitSize
public void setUnitSize(int unitSize) Sets unitSize and triggers a call to initArgosy() to reset the pattern in argosyArray.- Parameters:
unitSize- the new unitSize
-
getArgosyStep
public int getArgosyStep()- Returns:
- the animStep, number of pixels to shift in an animation
-
setArgosyStep
public void setArgosyStep(int argoStep) Set the animStep, with no side effects (but animation calls will use the new value)- Parameters:
argoStep-
-
getArgosyColors
public int[] getArgosyColors()- Returns:
- the array of colors for the argosy pattern elements
-
setArgosyColors
public void setArgosyColors(int[] argosyColors) Sets new argosyColors and triggers a call to initArgosy() to reset the pattern in argosyArray.- Parameters:
argosyColors-
-
getArgosyGapScale
public float getArgosyGapScale()- Returns:
- the argosyGapScale
-
setArgosyGapScale
public void setArgosyGapScale(float argosyGapScale) Sets argosyGapScale and triggers a call to initArgosy() to reset the pattern in argosyArray.- Parameters:
argosyGapScale-
-
getArgosyGap
public int getArgosyGap()- Returns:
- the argosyGap, number of pixels between iterations of the argosy pattern
-
setArgosyGap
public void setArgosyGap(int argosyGap) Sets argosyGap and triggers a call to initArgosy() to reset the pattern in argosyArray. Usually it's better to set the argosyGapScale, but if you want a gap that isn't a multiple of unitSize, this is the way to do it.- Parameters:
argosyGap-
-
getArgosyGapColor
public int getArgosyGapColor()- Returns:
- the argosyGapColor
-
setArgosyGapColor
public void setArgosyGapColor(int argosyGapColor) Sets argosyGapColor and triggers a call to argosyFill() to reset the pattern in bigArray.- Parameters:
argosyGapColor-
-
getArgosyReps
public int getArgosyReps()- Returns:
- argosyReps, the number of repetitions of the argosy pattern in the array, set by argosyFill().
-
setArgosyReps
public void setArgosyReps(int newReps) -
getMapper
- Returns:
- the PixelAudioMapper associated with this Argosy
-
getArgosyMargin
public int getArgosyMargin()- Returns:
- argosyMargin, the left and right margin to argosy patterns in the array, set by argosyFill().
-
getArgosyOffset
public int getArgosyOffset() -
setArgosyOffset
public void setArgosyOffset(int argosyOffset) -
getMaxReps
public int getMaxReps() -
getArgosyPattern
public int[] getArgosyPattern()- Returns:
- the argosyPattern, an array with a numeric pattern.
-
setArgosyPattern
public void setArgosyPattern(int[] pattern) Sets a new argosy pattern and triggers a call to argosyFill() to reset the pattern in bigArray.- Parameters:
pattern-
-
setNewColors
public void setNewColors(int[] argosyColors, int argosyGapColor) Sets new argosy colors and argosy gap color, triggers a call to argosyFill().- Parameters:
argosyColors-argosyGapColor-
-
getAnimStepDivisor
public float getAnimStepDivisor() -
setAnimStepDivisor
public void setAnimStepDivisor(float animStepDivisor) -
getBgColor
public int getBgColor() -
setBgColor
public void setBgColor(int bgColor) -
fibo
An L-System generator for Fibonacci trees represented as a sequence of 0s and 1s. There are two generation rules: 0 -> 1; 1 -> 01. The initial state is 0.- Parameters:
depth- depth of iteration of the L-System. A depth of 8 gets you an ArrayList with 34 elements.verbose- Keep me informed. Or not.- Returns:
- an ArrayList of String values "1" and "0".
-
fibonacciPattern
public static int[] fibonacciPattern(int depth, int v1, int v2, boolean verbose) Generates an argosy pattern based on a Fibonacci tree. Depth 8 gets you a 34 element sequence, and so Fibonacci forth. For example: int[] testPattern = argosyGen(8, 5, 8, true);- Parameters:
depth- depth of iteration of the L-System. A depth of 8 gets you an array with 34 elements.v1- value to substitute for a "0" in the ArrayList returned by fibo()v2- value to substitute for a "1" in the ArrayList return by fibo()verbose- if true, tells the console what's up- Returns:
- an array of ints determined by a Fibonacci tree generator and your inputs v1 and v2
-