artofillusion.image
Class ImageOrValue

java.lang.Object
  extended by artofillusion.image.ImageOrValue

public class ImageOrValue
extends java.lang.Object

ImageOrValue represents a float value between 0 and 1, which can potentially vary with position. It provides a Widget with which the user can edit it. They can choose either a single value, or a component of an ImageMap which can be multiplied by a user specified value.


Constructor Summary
ImageOrValue(java.io.DataInputStream in, Scene theScene)
          The following two methods are used for reading and writing files.
ImageOrValue(float val)
           
ImageOrValue(float scale, ImageMap theMap, int whichComponent)
           
 
Method Summary
 void copy(ImageOrValue obj)
          Make this object identical to another one.
 ImageOrValue duplicate()
          Create a duplicate of this object.
 float getAverageValue()
          Return the average value over the entire image.
 int getComponent()
          Get which component of the image to use.
 Widget getEditingPanel(BFrame parent, Scene theScene)
          Get a Widget with which the user can edit the value.
 void getGradient(Vec2 grad, boolean wrapx, boolean wrapy, double x, double y, double xsize, double ysize)
          Given a texture coordinate, get the gradient of the image.
 ImageMap getImage()
          Get the image, or null if it is a single value.
 float getValue()
          Get the value by which the image is scaled.
 float getValue(boolean wrapx, boolean wrapy, double x, double y, double xsize, double ysize)
          Given a texture coordinate (x and y each between 0 and 1), return the average value of a region of width (xsize, ysize) centered at that location.
 void writeToFile(java.io.DataOutputStream out, Scene theScene)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageOrValue

public ImageOrValue(float val)

ImageOrValue

public ImageOrValue(float scale,
                    ImageMap theMap,
                    int whichComponent)

ImageOrValue

public ImageOrValue(java.io.DataInputStream in,
                    Scene theScene)
             throws java.io.IOException
The following two methods are used for reading and writing files. The first is a constructor which reads the necessary data from an input stream. The other writes the object's representation to an output stream.

Throws:
java.io.IOException
Method Detail

getImage

public ImageMap getImage()
Get the image, or null if it is a single value.


getComponent

public int getComponent()
Get which component of the image to use.


getValue

public float getValue()
Get the value by which the image is scaled.


getValue

public float getValue(boolean wrapx,
                      boolean wrapy,
                      double x,
                      double y,
                      double xsize,
                      double ysize)
Given a texture coordinate (x and y each between 0 and 1), return the average value of a region of width (xsize, ysize) centered at that location. wrapx and wrapy specify whether, for purposes of interpolation, the image should be treated as wrapping around so that opposite edges touch each other.


getGradient

public void getGradient(Vec2 grad,
                        boolean wrapx,
                        boolean wrapy,
                        double x,
                        double y,
                        double xsize,
                        double ysize)
Given a texture coordinate, get the gradient of the image.


getAverageValue

public float getAverageValue()
Return the average value over the entire image.


duplicate

public ImageOrValue duplicate()
Create a duplicate of this object.


copy

public void copy(ImageOrValue obj)
Make this object identical to another one.


writeToFile

public void writeToFile(java.io.DataOutputStream out,
                        Scene theScene)
                 throws java.io.IOException
Throws:
java.io.IOException

getEditingPanel

public Widget getEditingPanel(BFrame parent,
                              Scene theScene)
Get a Widget with which the user can edit the value. This Widget will send out ValueChangedEvents whenever the value changes.

Parameters:
parent - a parent BFrame which can be used for displaying dialogs
theScene - the Scene from which to get images


Copyright © 1999-2011 by Peter Eastman.