JScript Blender
From RealWorld Wiki
RealWorld scripting reference
Blender is a global object accessible in the JScript document operation to simplify the work with raster images.
Contents |
[edit] 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 with in place of any raster image document.
- 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) - currently not implemented.
- 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;
[edit] 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
[edit] Channels
ChEmpty = 0 ChR = 1 ChG = 2 ChB = 3 ChA = 4 ChY = 5 ChCb = 6 ChCr = 7 ChH = 8 ChL = 9 ChS = 10
[edit] 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);