sub_arctic.output
Class radial_gradient

java.lang.Object
  |
  +--sub_arctic.output.gradient
        |
        +--sub_arctic.output.radial_gradient

public class radial_gradient
extends gradient

A class to representing a radial gradient object. This gradient operates about a center point produces an image which is uniform along any vector away from that center point.


Field Summary
protected  double _angle_offset
          Angular offset of gradient (in radians).
protected  double _fxc
          Cache of X coordinate of center point as float.
protected  double _fyc
          Cache of Y coordinate of center point as float.
protected  int _xc
          X coordinate of center point.
protected  int _yc
          Y coordinate of center point.
 
Fields inherited from class sub_arctic.output.gradient
_color_values, alpha_shift, blue_shift, green_shift, MASK_A_EQ, MASK_A_GT, MASK_A_LT, MASK_B_EQ, MASK_B_GT, MASK_B_LT, MASK_EQ, red_shift
 
Constructor Summary
radial_gradient(int[] colors, int xc_loc, int yc_loc, double ang)
          Constructor with broken out coordinate values for center point.
radial_gradient(int[] colors, java.awt.Point cent, double ang)
          Constructor with Point value. The center point and angular offset given here establish a coordinate system for the gradient.
radial_gradient(radial_gradient prototype, int xc_loc, int yc_loc, double ang)
          Construct from another radial_gradient and broken out values for a new center point.
radial_gradient(radial_gradient prototype, java.awt.Point cent, double ang)
          Construct from another radial_gradient and a new center.
 
Method Summary
protected  double angle_offset()
          Angular offset of gradient (in radians).
 java.awt.Point center_point()
          Center point.
 float map_point_to_index(int ptx, int pty)
          Map the given point (expressed in the coordinate system used for the center point) to an index within the radial gradient color value array.
 loaded_image render_image(int x, int y, int w, int h, int xc, int yc, double ang)
          Produce an in-memory loaded_image containing the drawing of a gradient with the same color sequence, but using a different center line and/or angular offset.
 loaded_image render_image(int x, int y, int w, int h, int xc, int yc, double ang, loaded_image mask, int test_code, boolean invert, int ref_color, int outside_mask_color)
          Produce an in-memory loaded_image containing the drawing of a masked gradient with the same color sequence, but using a different center line and/or angular offset.
 loaded_image render_image(int x, int y, int w, int h, java.awt.Point cent, double ang)
          Produce an in-memory loaded_image containing the drawing of a gradient with the same color sequence, but using a different center point and/or angular offset.
 loaded_image render_image(int x, int y, int w, int h, java.awt.Point cent, double ang, loaded_image mask, int test_code, boolean invert, int ref_color, int outside_mask_color)
          Produce an in-memory loaded_image containing the drawing of a masked gradient with the same color sequence, but using a different center point and/or angular offset.
 int[] render_to_data(int x, int y, int w, int h, int xc, int yc, double ang)
          Produce an in-memory data array (suitable for constructing an image) containing the drawing of a gradient with the same color sequence, but using a different center point and/or angular offset.
 int[] render_to_data(int x, int y, int w, int h, int xc, int yc, double ang, 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 drawing of a masked gradient with the same color sequence, but using a different center point and/or angular offset.
 int[] render_to_data(int x, int y, int w, int h, java.awt.Point cent, double ang)
          Produce an in-memory data array (suitable for constructing an image) containing the drawing of a gradient with the same color sequence, but using a different center point and/or angular offset.
 int[] render_to_data(int x, int y, int w, int h, java.awt.Point cent, double ang, 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 drawing of a masked gradient with the same color sequence, but using a different center point and/or angular offset.
protected  void set_angle_offset(double val)
          Set the angular offset of gradient (in radians).
 void set_center_point(int xval, int yval)
          Set the center point.
 void set_center_point(java.awt.Point val)
          Set the center point.
 void set_xc(int val)
          Set the X coordinate of the center point.
 void set_y1(int val)
          Set the Y coordinate of the center point.
 int xc()
          X coordinate of center point.
 int yc()
          Y coordinate of center point.
 
Methods inherited from class sub_arctic.output.gradient
average_of_range, color_for_pixel, color_values, render_image, render_image, render_to_data, render_to_data, set_color_values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_xc

protected int _xc
X coordinate of center point.

_yc

protected int _yc
Y coordinate of center point.

_fxc

protected double _fxc
Cache of X coordinate of center point as float.

_fyc

protected double _fyc
Cache of Y coordinate of center point as float.

_angle_offset

protected double _angle_offset
Angular offset of gradient (in radians).
Constructor Detail

radial_gradient

public radial_gradient(int[] colors,
                       java.awt.Point cent,
                       double ang)
Constructor with Point value.

The center point and angular offset given here establish a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
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.
Point - cent center point
double - ang angular offset in radians

radial_gradient

public radial_gradient(int[] colors,
                       int xc_loc,
                       int yc_loc,
                       double ang)
Constructor with broken out coordinate values for center point.

The center point and angular offset given here establish a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
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.
int - xc_loc x coordinate of center point
int - yc_loc y coordinate of center point
double - ang angular offset in radians

radial_gradient

public radial_gradient(radial_gradient prototype,
                       java.awt.Point cent,
                       double ang)
Construct from another radial_gradient and a new center. This constructs a new gradient with the same color sequence, but a different orientation

The center point and angular offset given here establish a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
radial_gradient - prototype object that we get a color sequence from. Note: we share (not copy) the color sequence array.
Point - cent new center point
double - ang new angular offset in radians

radial_gradient

public radial_gradient(radial_gradient prototype,
                       int xc_loc,
                       int yc_loc,
                       double ang)
Construct from another radial_gradient and broken out values for a new center point. This constructs a new gradient with the same color sequence, but a different orientation

The center point and angular offset given here establish a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
radial_gradient - prototype object that we get a color sequence from. Note: we share (not copy) the color sequence array.
int - xc_loc x coordinate of center point
int - yc_loc y coordinate of center point
doulbe - ang angular offset in radians
Method Detail

xc

public int xc()
X coordinate of center point.
Returns:
int the coordinate value

yc

public int yc()
Y coordinate of center point.
Returns:
int the coordinate value

center_point

public java.awt.Point center_point()
Center point.
Returns:
Point the center point

set_xc

public void set_xc(int val)
Set the X coordinate of the center point.
Parameters:
int - val the new coordinate value

set_y1

public void set_y1(int val)
Set the Y coordinate of the center point.
Parameters:
int - val the new coordinate value

set_center_point

public void set_center_point(int xval,
                             int yval)
Set the center point.
Parameters:
int - xval x coordinate of the new center point value
int - yval y coordinate of the new center point value

set_center_point

public void set_center_point(java.awt.Point val)
Set the center point.
Parameters:
Point - val the new center point value

angle_offset

protected double angle_offset()
Angular offset of gradient (in radians).
Returns:
double the angular offset of the gradient.

set_angle_offset

protected void set_angle_offset(double val)
Set the angular offset of gradient (in radians).
Parameters:
double - val the new angular offset of the gradient.

map_point_to_index

public float map_point_to_index(int ptx,
                                int pty)
Map the given point (expressed in the coordinate system used for the center point) to an index within the radial gradient color value array. This finds the angle between a line segment from the center point to the given point and the y axis offset by the angle_offset. This angle is then mapped onto positions in the color array. Points coincident with the center point are mapped onto an index of 0.
Parameters:
int - ptx x coordinate of the point to be mapped
int - pty y coordinate of the point to be mapped
float - the index position (possibly fractional) that the point maps to.
Overrides:
map_point_to_index in class gradient

render_to_data

public int[] render_to_data(int x,
                            int y,
                            int w,
                            int h,
                            int xc,
                            int yc,
                            double ang)
Produce an in-memory data array (suitable for constructing an image) containing the drawing of a gradient with the same color sequence, but using a different center point and/or angular offset. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
int - xc x coordinate of center point
int - yc y coordinate of center point
double - ang angular offset in radians
Returns:
int[]

render_to_data

public int[] render_to_data(int x,
                            int y,
                            int w,
                            int h,
                            java.awt.Point cent,
                            double ang)
Produce an in-memory data array (suitable for constructing an image) containing the drawing of a gradient with the same color sequence, but using a different center point and/or angular offset.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
Point - cent center point
double - ang angular offset in radians
Returns:
int[]

render_image

public loaded_image render_image(int x,
                                 int y,
                                 int w,
                                 int h,
                                 int xc,
                                 int yc,
                                 double ang)
Produce an in-memory loaded_image containing the drawing of a gradient with the same color sequence, but using a different center line and/or angular offset. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
int - xc x coordinate of center point
int - yc y coordinate of center point
double - ang angular offset in radians
Returns:
loaded_image

render_image

public loaded_image render_image(int x,
                                 int y,
                                 int w,
                                 int h,
                                 java.awt.Point cent,
                                 double ang)
Produce an in-memory loaded_image containing the drawing of a gradient with the same color sequence, but using a different center point and/or angular offset. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
Point - cent center point
double - ang angular offset in radians
Returns:
loaded_image

render_to_data

public int[] render_to_data(int x,
                            int y,
                            int w,
                            int h,
                            int xc,
                            int yc,
                            double ang,
                            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 drawing of a masked gradient with the same color sequence, but using a different center point and/or angular offset. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
int - xc x coordinate of center point
int - yc y coordinate of center point
double - ang angular offset in radians
loaded_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 test
int - ref_color reference color for mask test
int - outside_mask_color color to draw pixels that fall outside the mask
Returns:
int[] data array holding result

render_to_data

public int[] render_to_data(int x,
                            int y,
                            int w,
                            int h,
                            java.awt.Point cent,
                            double ang,
                            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 drawing of a masked gradient with the same color sequence, but using a different center point and/or angular offset.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
Point - cent center point
double - ang angular offset in radians
loaded_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 test
int - ref_color reference color for mask test
int - outside_mask_color color to draw pixels that fall outside the mask
Returns:
int[] data array holding result

render_image

public loaded_image render_image(int x,
                                 int y,
                                 int w,
                                 int h,
                                 int xc,
                                 int yc,
                                 double ang,
                                 loaded_image mask,
                                 int test_code,
                                 boolean invert,
                                 int ref_color,
                                 int outside_mask_color)
Produce an in-memory loaded_image containing the drawing of a masked gradient with the same color sequence, but using a different center line and/or angular offset. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
int - xc x coordinate of center point
int - yc y coordinate of center point
double - ang angular offset in radians
loaded_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 test
int - ref_color reference color for mask test
int - outside_mask_color color to draw pixels that fall outside the mask
Returns:
loaded_image image holding result

render_image

public loaded_image render_image(int x,
                                 int y,
                                 int w,
                                 int h,
                                 java.awt.Point cent,
                                 double ang,
                                 loaded_image mask,
                                 int test_code,
                                 boolean invert,
                                 int ref_color,
                                 int outside_mask_color)
Produce an in-memory loaded_image containing the drawing of a masked gradient with the same color sequence, but using a different center point and/or angular offset. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
Point - cent center point
double - ang angular offset in radians
loaded_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 test
int - ref_color reference color for mask test
int - outside_mask_color color to draw pixels that fall outside the mask
Returns:
loaded_image image holding result