|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sub_arctic.output.gradient
An abstract class representing a gradient object. Gradients encapsulate a 1D sequence of colors that make up the gradient, along with a mapping from 2D space onto the 1D gradient space, and operations for drawing the gradient within a rectangular area of an image.
linear_gradient
Field Summary | |
protected int[] |
_color_values
The array of color values (stored as ints encoded aarrggbb) providing the colors we interpolate across. |
static int |
alpha_shift
Shift constant to extract alpha value from color. |
static int |
blue_shift
Shift constant to extract blue value from color. |
static int |
green_shift
Shift constant to extract green value from color. |
static int |
MASK_A_EQ
Constant for mask test MASK.alpha == reference (can be inverted for !=) |
static int |
MASK_A_GT
Constant for mask test MASK.alpha > reference (can be inverted for <=) |
static int |
MASK_A_LT
Constant for mask test MASK.alpha < reference (can be inverted for >=) |
static int |
MASK_B_EQ
Constant for mask test MASK.blue == reference (can be inverted for !=) |
static int |
MASK_B_GT
Constant for mask test MASK.blue > reference (can be inverted for <=) |
static int |
MASK_B_LT
Constant for mask test MASK.blue < reference (can be inverted for >=) |
static int |
MASK_EQ
Constant for mask test MASK == reference (can be inverted for !=) |
static int |
red_shift
Shift constant to extract red value from color. |
Constructor Summary | |
gradient(int[] colors)
Full constructor |
Method Summary | |
int |
average_of_range(float indx1,
float indx2)
Compute an averaged color value for the sequence of colors appearing between two indexes into the gradient color array. |
int |
color_for_pixel(int left,
int top)
Compute the anti-aliased gradient color for the pixel whose top-left position is given. |
int[] |
color_values()
The array of color values (stored as ints encoded aarrggbb) providing the colors we interpolate across. |
abstract float |
map_point_to_index(int ptx,
int pty)
Map the given point (expressed in the coordinate system of the gradient) to an index within the linear gradient color value array. |
loaded_image |
render_image(int x,
int y,
int w,
int h)
Produce an in-memory loaded_image containing the drawn gradient. |
loaded_image |
render_image(int x,
int y,
int w,
int h,
loaded_image mask,
int test_code,
boolean invert,
int ref_color,
int outside_mask_color)
Produce an in-memory loaded_image containing the gradient drawn through a mask. |
int[] |
render_to_data(int x,
int y,
int w,
int h)
Produce an in-memory data array (suitable for constructing an image) containing the drawn gradient. |
int[] |
render_to_data(int x,
int y,
int w,
int h,
loaded_image mask,
int test_code,
boolean invert,
int ref_color,
int outside_mask_color)
Produce an in-memory data array (suitable for constructing an image) containing the gradient drawn through a mask. |
void |
set_color_values(int[] new_vals)
Set the array of color values (stored as ints encoded aarrggbb) providing the colors we interpolate across. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected int[] _color_values
public static final int alpha_shift
public static final int red_shift
public static final int green_shift
public static final int blue_shift
public static final int MASK_EQ
public static final int MASK_A_EQ
public static final int MASK_B_EQ
public static final int MASK_A_LT
public static final int MASK_B_LT
public static final int MASK_A_GT
public static final int MASK_B_GT
Constructor Detail |
public gradient(int[] colors)
int[]
- colors array of color values encoded as integers using
the standard aarrggbb encoding (i.e., alpha value
in the high byte, red value in the next, etc.).
This array must have at least 2 values or an error
will be thrown.Method Detail |
public int[] color_values()
public void set_color_values(int[] new_vals)
int[]
- new_vals the new array of color valuespublic int average_of_range(float indx1, float indx2)
float
- indx1 index of start of range in color sequencefloat
- indx2 index of end of range in color sequencepublic abstract float map_point_to_index(int ptx, int pty)
Note that the index result here is a float because we are interested in exact mappings to the 1D gradient space for anti-aliasing purposes. This routine returns values in the interval [0..color_values().length), so fractional values beyond the last index are possible. These represent positions within the last color sample in the sequence.
int
- ptx x coordinate of the point to be mappedint
- pty y coordinate of the point to be mappedfloat
- the index position (possibly fractional) that the point
maps to.public int color_for_pixel(int left, int top)
int
- left x coordinate of top-left of pixel in questionint
- top y coordinate of top-left of pixel in questionpublic int[] render_to_data(int x, int y, int w, int h)
int
- x left of result rectangleint
- y top of result rectangleint
- w width of result rectangleint
- h height of result rectanglepublic int[] render_to_data(int x, int y, int w, int h, loaded_image mask, int test_code, boolean invert, int ref_color, int outside_mask_color)
int
- x left of result rectangleint
- y top of result rectangleint
- w width of result rectangleint
- h height of result rectangleloaded_image
- mask the mask to draw through. This must be
of size w, h, or an error will be thrown.int
- test_code test done on mask pixels. Must have one
of the values MASK_EQ, MASK_A_{EQ,LT,GT},
or MASK_B_{EQ,LT,GT}.boolean
- invert indicating if we should invert sense of testint
- ref_color reference color for mask testint
- outside_mask_color color to draw pixels that fall
outside the maskpublic loaded_image render_image(int x, int y, int w, int h)
int
- x left of result rectangleint
- y top of result rectangleint
- w width of result rectangleint
- h height of result rectanglepublic loaded_image render_image(int x, int y, int w, int h, loaded_image mask, int test_code, boolean invert, int ref_color, int outside_mask_color)
int
- x left of result rectangleint
- y top of result rectangleint
- w width of result rectangleint
- h height of result rectangleloaded_image
- mask the mask to draw through. This must be
of size w, h, or an error will be thrown.int
- test_code test done on mask pixels. Must have one
of the values MASK_EQ, MASK_A_{EQ,LT,GT},
or MASK_B_{EQ,LT,GT}.boolean
- invert indicating if we should invert sense of testint
- ref_color reference color for mask testint
- outside_mask_color color to draw pixels that fall
outside the mask
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |