Sg 2.9
Raster
Packages RSS
About
News
Gallery
Scripts
Tutorials
Download
Reference
Forum
Users
License
Twitter

Extends Item

The Raster item represents an image in an Illustrator document.

Constructors

Creates a raster object

    Parameters:
  • type: String ('rgb', 'cmyk', 'gray', 'bitmap', 'argb', 'acmyk', 'agray', 'abitmap') — optional
  • width: Number — optional
  • height: Number — optional

Creates a raster item from an AWT image.

    Parameters:
  • image: Image — the AWT image to be converted to a raster item

Creates a raster item from a local image file.

Sample code:

var file = new java.io.File('/folder/image.jpg');
var raster = new Raster(file);
    Parameters:
  • file: File — the image file to be loaded

Creates a raster image from a URL. This blocks until the image is loaded or an error occured.

Sample code:

var url = new java.net.URL('http://www.server.com/image.jpg');
var raster = new Raster(url);
    Parameters:
  • url: URL — the URL of the image to load
    Throws:
  • IOException

Properties

The size of the raster in pixels.

The width of the raster in pixels. Read-only.

    Returns:
  • Number

The height of the raster in pixels. Read-only.

    Returns:
  • Number
ppi

Pixels per inch of the raster at it's current size. Read-only.

The color type of the raster.

    Returns:
  • String ('rgb', 'cmyk', 'gray', 'bitmap', 'argb', 'acmyk', 'agray', 'abitmap')
    Returns:
  • BufferedImage

The average color of the raster. Read-only.

Functions

    Parameters:
  • x: Number
  • y: Number
  • width: Number
  • height: Number
    Returns:
  • BufferedImage
    Parameters:
  • image: Image
  • x: Number
  • y: Number

Traces the raster.

Average Color

Calculates the average color of the image within the given path. This can be used for creating raster image effects.

    Returns:
  • Color — the average color contained in the area covered by the specified path.

Calculates the average color of the image within the given point in the document. This can be used for creating raster image effects.

    Returns:
  • Color — the average color contained in the area described by the specified point.

Calculates the average color of the image within the given rectangle. This can be used for creating raster image effects.

    Returns:
  • Color — the average color contained in the area described by the specified rectangle.

Pixels

Gets the color of a pixel in the raster.

    Parameters:
  • x: Number
  • y: Number

Gets the color of a pixel in the raster.

Sets the color of a pixel in the raster. Sample code:

// Creates an RGB raster of 1px*1px
var raster = new Raster(Color.TYPE_RGB,1,1);
// Changes the color of the first pixel to red
var redColor = new RGBColor(1,0,0);
raster.setPixel(0,0,redColor)
    Parameters:
  • x: Number
  • y: Number
  • color: Color

Sets the color of a pixel in the raster.

Sample code:

// Creates an RGB raster of 1px*1px
var raster = new Raster(Color.TYPE_RGB,1,1);
// Changes the color of the first pixel to red
var redColor = new RGBColor(1,0,0);
var point = new Point(0,0);
raster.setPixel(point,redColor)

Inheritance

AltStyle によって変換されたページ (->オリジナル) /