
|
|
 |
hannelControl (Version 1.1)
ChannelControl
is a Canvas subclass that can be used to program animated transformations of the
red, blue, and green channels of a GIF or JPEG image. In addition, the class can
perform vertical and horizontal sinus wave distortions on all image channels
simultaneously. |
|
 |
peration
The following documentation describes how the
ChannelControl class is used. Also available is ChannelsApplet
which can be used to plug the animation directly into a web page. ChannelsApplet
is documented separately.
During initialization, ChannelControl loads the GIF or JPEG image that will be
animated, and an (optional) transparent GIF file that is overlaid after each
frame of the animation has been rendered.
In order to animate
individual channels of an image, the class requires that you pass it a String
array of animation instructions, hereafter referred to as a program.
Each String in the animation program String array represents the
transformation instructions that should be carried out for a single frame of
animation. There are seven different commands available: move red channel (MR),
move green channel (MG), move blue channel (MB), move all channels (MA),
horizontal wave (H), vertical wave (V), and reset image (R). Each command is
detailed below.
CHANNEL MOVE COMMANDS
MR
(Move Red), MG (Move Green), MB (Move Blue), MA (Move All Channels)
Format:
[MR | MG | MB | MA] [X Delta (-999 to +999)] [Y Delta (-999 to +999)]
Example:
"MB-010-010 MG+010+010 MR-010+010 MA+000+010"
Explanation:
For this frame, a) Move blue channel up 10 and left 10, then b) Move green
channel down 10 and right 10, then c) Move red channel up 10 and right 10, then
d) Move all channels down 10.
NOTE: The X and Y offsets
are always from the position of the original image, NOT from the
position of the image in the preceding frame!
IMAGE
RESET COMMAND
Format: [R] [Percent (000 -
100)]
Example: "MA+50-35 R050"
Explanation:
For this frame, a) Move all channels (i.e., move image) down 50 and left 35,
then b) Reset image for next frame's transformation to 50% of this frame after
transformation and 50% of original image.
NOTE: R100
would reset the image for the next frame to the original image. This is the
default behavior if no reset command is specified, so R100 would be redundant.
Also, remember that the Reset command ONLY EFFECTS THE NEXT FRAME, not the
current frame.
IMAGE WAVE COMMANDS
V
(Vertical Wave), H (Horizontal Wave)
Format: [V | H]
[Number of Waves (1 - 9)] [Percent (000 - 100)] [Offset Degrees (000 - 360)]
Example: "MG+010-010 V1004000 H1002000 R080"
Explanation:
For this frame, a) Move green channel down 10 and left 10, then b) Perform a
vertical wave transformation on the image with one sinus wave having a maximum
modulation of 4% of the image height and with the waveform beginning at an
offset of 0 degrees, then c) Perform a horizontal wave transformation on the
image with one sinus wave having a maximum modulation of 2% of the image height
and with the waveform beginning at an offset of 0 degrees, then d) Reset image
for next frame's transformation to 20% of this frame after transformation and
80% of original image.
|
Note that if you wish to repeat a frame
without applying any transformations, you may enter a null value String in the
String array. This will cause the previously rendered frame to be repeated in
the animation sequence.
|
| |
 |
ample
|
|
 |
onstructors
There are two constructors available for the
class. The only difference between the two is that one has a parameter for a
GIF89a masking image, and the other does not.
If you wish to
use a GIF89a masking image as an overlay, use the following constructor
when instantiating the class:
public ChannelControl(
URL base, String imageFile, String maskFile,
boolean initImage, String[] program,
int direction, int frameDelay,
int loopDelay, Color background
) throws MalformedURLException
|
The following constructor is the same, except it does not
provide for a GIF89a masking image:
public ChannelControl(
URL base, String imageFile,
boolean initImage, String[] program,
int direction, int frameDelay,
int loopDelay, Color background
) throws MalformedURLException
|
The constructor parameters are defined as follows:
| URL |
base |
The base directory for locating the image files. |
| String |
imageFile |
The file name of the GIF or JPEG image that is to be
animated.
The file path is based starting with the base
directory. |
| String |
maskFile |
The file name of a transparent GIF (GIF89a
format) image that will be drawn on top of each rendered frame. (The animated
image is overlaid with the non-animated mask image.)
The
file path is based starting with the base directory. |
| boolean |
initImage |
If set to "true", then the Canvas
will draw the original imageFile and then the maskFile overlay
(if specified) before the frame rendering process begins. This prevents having a
blank "hole" while the rendering process is executing.
If set
to "false", then only a progress bar at the bottom of the
Canvas will be displayed. |
| String[] |
program |
A String array that contains transformation
instructions for rendering the frames of animation.
There is one String
for each frame to be rendered.
See the Operation section of
this document (above) for details on the format of the Strings in this array. |
| int |
direction |
Direction that the animation should be performed.
ChannelControl.FORWARD
(0) will perform the animation beginning with the first frame, proceed to the
last frame, then start over with the first frame again.
ChannelControl.BACKWARD
(1) will perform the animation beginning with the last frame, proceed to the
first frame, then start over with the last frame again.
ChannelControl.YOYO
(2) will perform the animation beginning with the first frame, proceed to the
last frame, then work its way back to the first frame, alternating between ChannelControl.FORWARD
& ChannelControl.BACKWARD motion. |
| int |
frameDelay |
The number of milliseconds to delay between each
frame of animation |
| int |
loopDelay |
The number of milliseconds to delay between each
animation loop. |
| Color |
background |
The background color used during the rendering
process.
The color specified for this parameter can have a substantial
affect on a rendered frame. | |
|
 |
ublic
Methods
This section lists the
methods that can be called from a Java program to control or alter the
animation.

Starts the animation.

Stops the animation.

|
public boolean setFrames(String[] program)
|
Causes the animation to be re-rendered using the
instructions contained in the program String array. There is one string
array entry in the program array for each frame.

|
public void setBackground(Color background)
|
Causes the animation to be re-rendered using the specified
background color.

|
public void setDelay(int frameDelay)
|
Causes the delay between each frame of animation to be
changed to frameDelay milliseconds.

|
public void setLoopDelay(int loopDelay)
|
Causes the delay between each loop of animation to be
changed to loopDelay milliseconds.

|
public void setDirection(int direction)
|
Changes the direction of the animation. The value for direction
must be:
ChannelControl.FORWARD (0), or ChannelControl.BACKWARD (1), or
ChannelControl.YOYO (2).
|
|
 |
ownload
The class file for ChannelControl,
along with a copy of this documentation, is available for
download
as a standard zip file, as a self-extracting file (for Windows95/NT users), or as
a self-installing Java class file.
|
|
 |
opyright
This documentation and the object code for ChannelsApplet
and ChannelControl may be copied and distributed freely for
non-commercial purposes so long as neither the code nor the documentation is
altered in any way. If the object code is distributed with any documentation
whatsoever, then this unaltered document must accompany the code.
Copyright © 1997, 1998 by Modern Minds, Inc.
|