JScript Blender

Log-in or register.

JScript Blender

Blender is a global object accessible in the JScript document operation to simplify the work with raster images.

Methods and properties

  • int <composition_mode> (get) - returns a constant identifying a composition mode. The supported modes are listed below.
  • void CreateCanvas(int sizeX, int sizeY, int fill) - creates a temporary canvas filled with given color. The canvas can be used in places where a raster image would be accepted.
  • object Compose(object dst, int dstX1, int dstY1, int dstX2, int dstY2, object src, int srcX1, int srcY1, int outFill, int compositionMode, object parameter (optional)) - combine two raster images. Only the dst image is affected and only in the rectangle [dstX1,dstY1]-[dstX2,dstY2]. The source pixels are taken from src image if it is specified. The srcX1 and srcY1 specify an offset in the source image. If the source image is not big enough or if it is not specified, outFill color is used instead. The two images are combined using compositionMode.
  • object CanvasFromMask(object context, string maskID) - create a canvas from mask stored in the Context object under specified ID.
  • void CanvasToMask(object context, string maskID, object canvas) - creates a new mask from the given canvas and puts it into the context under given ID. Size of the canvas must be the same as the size of the current image, otherwise the mask will be ignored by the editor. Only the green channel from the canvas is considered (higher green value -> higher selectness of a pixel).
  • int MapChannels(int src1, int src2, int src3, int src4, int dst1, int dst2, int dst3, int dst4) - prepares the parameter for OpMapChannel blending operation. Src1-4 specify channels in the source canvas and dst1-4 specify desired channel layout in the destination canvas after the operation. Source and destination canvases may reference the same object for in-place conversion.
  • int GetActiveColor(object context, string colorID) - retrieve color stored in context under colorID as 32bit RGBA value;
  • int DesktopSizeX, DesktopSizeY - retrieve resolution of the primary monitor. This properties can be used for example to automatically adjust images to user's display size.

Composition modes

OpClear = 0
OpColorBurn = 1
OpColorDodge = 2
OpContrast = 3
OpDarken = 4
OpDifference = 5
OpDst = 6
OpDstAtop = 7
OpDstIn = 8
OpDstOut = 9
OpDstOver = 10
OpExclusion = 11
OpHardLight = 12
OpInvert = 13
OpInvertRGB = 14
OpLighten = 15
OpMinus = 16
OpMultiply = 17
OpOverlay = 18
OpPlus = 19
OpScreen = 20
OpSoftLight = 21
OpSrc = 22
OpSrcAtop = 23
OpSrcIn = 24
OpSrcOut = 25
OpSrcOver = 26
OpXor = 27
OpRGBAPlus = 28
OpRGBAMinus = 29
OpRGBAMultiply = 30
OpRGBAMultiply2x = 31
OpNormalBumpmap = 32
OpHeightBumpmap = 33
OpMapChannels = 34

// new modes in version 2009.1
OpNormalDisplace = 35
OpHeightDisplace = 36
OpHeightToNormal = 37
OpRGBAMaximum = 38
OpRGBAMinimum = 39

Channels

ChEmpty = 0
ChR = 1
ChG = 2
ChB = 3
ChA = 4
ChY = 5
ChCb = 6
ChCr = 7
ChH = 8
ChL = 9
ChS = 10

Example

// create semitransparent gray canvas (20x20 pixels)
var canvas = Blender.CreateCanvas(20, 20, 0xc0808080);
// paint it three times over the original image
Blender.Compose(Document, 10, 10, 30, 30, canvas, 0, 0, 0, Blender.OpSrcOver);
Blender.Compose(Document, 15, 15, 35, 35, canvas, 0, 0, 0, Blender.OpSrcOver);
Blender.Compose(Document, 20, 20, 40, 40, canvas, 0, 0, 0, Blender.OpSrcOver);

Recent comments

user icon Anonymous
Select background
Vista & Win 7 icons