public virtual void colorTransform(Rectangle rect, ColorTransform colorTransform) { for (var x = (int)rect.x; x < rect.x + rect.width; x++) { for (var y = (int)rect.y; y < rect.y + rect.height; y++) { setPixel32(x, y, colorTransform.transformColor(getPixel32(x, y))); } } }
public virtual void drawWithQuality(IBitmapDrawable source, Matrix matrix = null, ColorTransform colorTransform = null, string blendMode = null, Rectangle clipRect = null, bool smoothing = false, string quality = null) { draw(source, matrix, colorTransform, blendMode, clipRect, smoothing); }
public virtual void draw(IBitmapDrawable source, Matrix matrix = null, ColorTransform colorTransform = null, string blendMode = null, Rectangle clipRect = null, bool smoothing = false) { var sourceDisplayObject = source as DisplayObject; if (sourceDisplayObject != null) { if (clipRect != null) { this.width = (int)clipRect.width; this.height = (int)clipRect.height; } else { this.width = (int)sourceDisplayObject.width; this.height = (int)sourceDisplayObject.height; } if (matrix != null) { sourceDisplayObject.transform.matrix = matrix; } if (colorTransform != null) { sourceDisplayObject.transform.colorTransform = colorTransform; } RenderingContext2D ctx; CanvasRenderingContext2D result; if (_internalImage.FastAs <CanvasRenderingContext2D>() != null) { ctx = new RenderingContext2D((CanvasRenderingContext2D)_internalImage); result = (CanvasRenderingContext2D)_internalImage; } else { var canvas = new HTMLCanvasElement(); canvas.Width = this.width; canvas.Height = this.height; var context2d = canvas.GetContext(CanvasTypes.CanvasContext2DType.CanvasRenderingContext2D); ctx = new RenderingContext2D(context2d); this.drawSelf(context2d, 0, 0, this.width, this.height); result = context2d; } ctx.ctx.Save(); if (clipRect != null) { ctx.ctx.Rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height); ctx.ctx.Clip(); } if (matrix != null) { ctx.SetTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); } if (blendMode != null) { ctx.blendMode = blendMode; } sourceDisplayObject.draw(ctx); internalImage = result; ctx.ctx.Restore(); } }