arc() - Media Method

The arc() method draws and positions an arc on the image based on the specified parameters. This method accepts all composite() - Media Method parameters except HandleX and HandleY.

The foreground color may vary with this function, depending on the original Media object. If the object has a set foreground color, or it is set with the setColor() - Media Method function, MediaRich uses the set color.

However, if the object has no set foreground color, MediaRich does the following:

» For objects with 256 colors or less, MediaRich uses the last color index

» For objects with 15-bit or greater resolution, MediaRich uses white

Note:  Using arc() to mask frames within a JavaScript for loop can result in initially poor anti-aliasing. To maintain optimal anti-aliasing, place the masking arc outside the loop.

Syntax

arc(

X @ <pixel>,

Y @ <pixel>,

Rx @ <value>,

Ry @ <value>,

Startangle @ <value -360..360>,

Endangle @ <value -360..360>,

[Opacity @ <value 0..255>]

[Unlock @ <true, false>]

[Color @ <color in hexadecimal, rgb, or cymk>]

[Index @ <value 0..16777215>]

[Saturation @ <value 0..255>]

[PreserveAlpha @ <true, false>]

[Blend @ <"blend-type">]

[Width @ <value>]

[Smooth @ <true, false>]

[Fill @ <true, false>]

[Warpangles @ <true, false>]

);

Parameters

The arc is created as a portion of a defined ellipse:

X - specifies (in pixels) the x-axis coordinate for the center point of the ellipse from which the arc is derived. This parameter is required and has no default value.

Y - specifies (in pixels) the y-axis coordinate for the center point of the ellipse from which the arc is derived. This parameter is required and has no default value.

Rx - specifies (in pixels) the radius of the ellipse (from which the arc is derived) on the x-axis. This parameter is required and has no default value.

Ry - specifies (in pixels) the radius of the ellipse (from which the arc is derived) on the y-axis. This parameter is required and has no default value.

Startangle - indicates the point of the ellipse (from which the arc is derived) where the arc begins. This parameter is required. There is no default value.

Endangle - indicates the point of the ellipse (from which the arc is derived) where the arc ends. This parameter is required. There is no default value.

Opacity - specifies opacity of the drawn object. The default value is 255 (completely solid).

Unlock - when set to true, causes the arc to display only where the specified color value appears in the current (background) image. The default is false.

Color - sets the color of the ellipse. This parameter supports a hexidecimal, RGB, or CMYK color specification:

» hexidecimal - color value expressed as a value from 0x000000 to 0xFFFFFF (RGB colorspace) or from 0x00000000 to 0xFFFFFFFF (CMYK colorspace)

» RGB - color value expressed as a value from 0 to 16,777,215

» CMYK - color value expressed as a value from 0 to 4,294,967,295

Colorspace

Always pass a color value appropriate to the colorspace. You can ensure this using the getPixelFormat() function in your script and then using different hexadecimal values for the RGB and the CMYK colorspaces in an IF/THEN construction. If getPixelFormat() returns "CMYK," use the CMYK value (0x plus eight more digits), and otherwise use the RGB value (0x plus six more digits).

Index - if a color palette exists for the source image, use this parameter to set the color of the arc (as an alternative to the Color parameter).

Note:  You cannot specify values in both the Color and Index fields.

Saturation - specifies a value for the weighting for the change in saturation for destination pixels. A value of 255 changes the saturation of pixels to the specified color. A value of 128 changes the saturation of a pixel to a mid-value between the pixel’s current color and the specified color.

Note:  The Saturation parameter only functions when the Blend parameter is set to colorize.

PreserveAlpha - when set to true, preserves the alpha channel of the target image as the alpha channel of the resulting image. The default value is false.

Blend - specifies the type of blending used to combine the drawn object with the images. Blend options are: Normal, Darken, Lighten, Hue, Saturation, Color, Luminosity, Multiply, Screen, Dissolve, Overlay, HardLight, SoftLight, Difference, Exclusion, Dodge, ColorBurn, Under, Colorize (causes only the hue component of the source to be stamped down on the image), and Prenormal.

Note:  The Burn option is deprecated. ColorBurn results in the same blend.

Width - specifies the thickness (in pixels) of the line that describes the arc. The default value is 1. However, if the Fill parameter is set to true, the Width parameter is ignored.

Smooth - when set to true, makes the edges of the arc smooth, preventing a pixellated effect. The default is false.

Important:  If you are using smoothing for media that contains an alpha channel and you plan to save it to a format that does not support alpha channels, it is necessary to use convert() to remove the alpha channel before using this operation. Or, as an alternative, you can composite the modified image onto an opaque background before saving the image. Without this additional handling, the media will not look correct in a non-alpha file format.

Fill - when set to true, fills in the arc with the color specified by the Color or Index parameter. The default value is false.

Warpangles - when set to true, warps the angles to match the ellipse. The default value is false.

Example

var image = new Media();

image.load(name @ "logobg.tga");

image.arc(X @ 185, Y @ 121, Rx @ 175, Ry @ 111, StartAngle @ -120, EndAngle @ 60, Width @ 2, Smooth @ true, WarpAngles @ true);

image.save(type @ "jpeg");