Java Reference
In-Depth Information
arcWidth: 10
fill: Color.BLUE
effect: ColorAdjust {
brightness: bind soundPlayer.levels[i] * 1.5 - .75;
contrast: bind soundPlayer.levels[i] * 3 + 0.25;
hue: bind soundPlayer.levels[i] * 1.5 - .75;
};
}
insert rect into content;
}
effect = Reflection{}
}
}
In Listing 9-8 we can see that this is actually a pretty simple class. The class Bars extends
AudioVisualizer from Listing 9-7, so it has a soundPlayer available and is also a Group . The init function
in the class Bars creates one Rectangle for each item in the sequence levels of class AudioPlayer . Each
Rectangle has its translateX value set so they are laid out right to left; this puts the higher frequency bars
to the right and the lower frequency bars to the left, as is common in these types of displays. The height
of each Rectangle is bound to a value of levels times 200 to make them tall enough to see. The
translateY is also bound to levels , which keeps the bottom of the Rectangles aligned as they change
size. Remember, a Rectangle 's origin is the upper-left corner. Lastly, a ColorAdjust is applied to each
rectangle; the ColorAdjust has attributes bound to levels as well, and this makes the Rectangle change
color as it gets taller. Applying a Reflection to the entire class gives it that nice reflection at the bottom.
In my opinion, the Bars class does an excellent job of showing exactly what all that work on the Java
side was for, because we can clearly see that we have successfully decomposed the audio. The next effect
is much more abstract but is still interesting because it is synced to only part of the music.
Disco
This effect produces a circular region on the screen that is filled with a multicolored “burst.” Originally
I wanted to make an effect that was more like a star with solar flares coming off it; however, my first
attempt didn't look quite right. It reminded me of disco lights, and I thought that was more appropriate
anyway, so I ran with it. Figure 9-4 shows the effect by itself.
Search WWH ::




Custom Search