public virtual ByteArray getPixels(Rectangle rect) { var data = new ByteArray(); copyPixelsToByteArray(rect, data); return(data); }
public NumberBlit(BitmapData spriteSheet, Rectangle rect, int digits = 1, double step = 0.25, int dx = 0, int dy = 0, int spacing = 0, int stepY = 0) : base(spriteSheet, rect, dx, dy) { this.height = height; this.digits = digits; this.step = step; if (stepY > 0) { this.stepY = stepY; } else { this.stepY = (int)rect.width; } if (spacing > 0) { this.spacing = spacing; } else { this.spacing = (int)rect.width; } sourceY = (int)rect.y; drums = new Array <double>(new double [digits]); this.rect = new Rectangle(rect.x, rect.y, spacing, spacing + 1); }
public GlitchMap() { rows = new Array <Point>(); cols = new Array <Point>(); p = new Point(); rect = new Rectangle(); glitchIndex = 0; }
public TitleMenu() { uiManager = new UIManager(); uiManager.selectSoundCallback = game.selectSound; levelButtonRect = new Rectangle(0, 0, renderer.numberButtonBlit.width - 1, renderer.numberButtonBlit.height - 1); mapCopyBuffer = Room.create2DArray(Level.ROOM_WIDTH, Level.ROOM_HEIGHT); // puzzle, adventure, editor puzzleButton = uiManager.addButton(Game.WIDTH * 0.5 - renderer.puzzleButtonBlit.width * 2, Game.HEIGHT * 0.5 - renderer.puzzleButtonBlit.height * 0.5, renderer.puzzleButtonBlit, puzzlePressed); adventureButton = uiManager.addButton(Game.WIDTH * 0.5 - renderer.adventureButtonBlit.width * 0.5, Game.HEIGHT * 0.5 - renderer.adventureButtonBlit.height * 0.5, renderer.adventureButtonBlit, adventurePressed); editorButton = uiManager.addButton(Game.WIDTH * 0.5 + renderer.editorButtonBlit.width, Game.HEIGHT * 0.5 - renderer.editorButtonBlit.height * 0.5, renderer.editorButtonBlit, puzzlePressed); // level button grid uiManager.addGroup(); uiManager.changeGroup(1); levelButtons = new Array <BlitButton>(); double buttonX = Game.WIDTH * 0.5 - ((LEVEL_BUTTONS_WIDE - 1) * LEVEL_BUTTON_GAP + levelButtonRect.width * LEVEL_BUTTONS_WIDE) * 0.5; double buttonY = Game.HEIGHT * 0.5 - ((LEVEL_BUTTONS_HIGH - 1) * LEVEL_BUTTON_GAP + levelButtonRect.height * LEVEL_BUTTONS_HIGH) * 0.5; BlitButton levelButton; for (r = 0; r < LEVEL_BUTTONS_HIGH; r++) { for (c = 0; c < LEVEL_BUTTONS_WIDE; c++) { levelButton = uiManager.addButton( buttonX + c * (levelButtonRect.width + LEVEL_BUTTON_GAP), buttonY + r * (levelButtonRect.height + LEVEL_BUTTON_GAP), renderer.numberButtonBlit, levelPressed, levelButtonRect ); levelButton.releaseCallback = levelReleased; levelButton.id = c + r * LEVEL_BUTTONS_WIDE; levelButton.targetId = 1; levelButtons.push(levelButton); } } int border = 2; var buttonRect = new Rectangle(0, 0, renderer.cancelButtonBlit.width, renderer.cancelButtonBlit.height); leftButton = uiManager.addButton(Game.WIDTH * 0.5 - 3 * Game.SCALE + border, Game.HEIGHT - Game.SCALE * 2 + border, renderer.leftButtonBlit, directionPressed, buttonRect); leftButton.visible = false; backButton = uiManager.addButton(Game.WIDTH * 0.5 - 1 * Game.SCALE + border, Game.HEIGHT - Game.SCALE * 2 + border, renderer.cancelButtonBlit, backPressed, buttonRect); rightButton = uiManager.addButton(Game.WIDTH * 0.5 + 1 * Game.SCALE + border, Game.HEIGHT - Game.SCALE * 2 + border, renderer.rightButtonBlit, directionPressed, buttonRect); if (!Game.MOBILE) { loadFromDesktopButton = uiManager.addButton(Game.WIDTH * 0.5 - 5 * Game.SCALE + border, Game.HEIGHT - Game.SCALE * 2 + border, renderer.loadButtonBlit, loadFromDesktop, buttonRect); loadFromDesktopButton.feedCallbackToEvent = true; saveToDesktopButton = uiManager.addButton(Game.WIDTH * 0.5 + 3 * Game.SCALE + border, Game.HEIGHT - Game.SCALE * 2 + border, renderer.saveButtonBlit, saveToDesktop, buttonRect); saveToDesktopButton.feedCallbackToEvent = true; } scoreTextBox = new TextBox(Game.WIDTH, 8, 0x0, 0x0); scoreTextBox.align = "center"; if (UserData.settings.best != null) { setScore((int)UserData.settings.best); } uiManager.changeGroup(0); }
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 setPixels(Rectangle rect, ByteArray inputByteArray) { 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, inputByteArray.readUnsignedInt()); } } }
public virtual void fillRect(Rectangle rect, uint color) { 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, color); } } }
public BlitRect(int dx = 0, int dy = 0, int width = 1, int height = 1, uint col = 0xFF000000) { x = y = 0; this.dx = dx; this.dy = dy; this.width = width; this.height = height; this.col = col; totalFrames = 1; rect = new Rectangle(0, 0, width, height); }
//[Version("10")] public virtual void setVector(Rectangle rect, Vector <uint> inputVector) { var i = 0; 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, inputVector[i++]); } } }
public void renderNumbers(BitmapData bitmapData) { double yTemp = y; Rectangle rectTemp = rect.clone(); for (i = 0; i < digits; i++) { rect.y = sourceY + drums[i] * stepY; render(bitmapData); x += spacing; } rect = rectTemp; }
//[Version("10")] public virtual Vector <uint> getVector(Rectangle rect) { var i = 0; var result = new Vector <uint>((int)rect.width * (int)rect.height); for (var x = (int)rect.x; x < rect.x + rect.width; x++) { for (var y = (int)rect.y; y < rect.y + rect.height; y++) { result[i++] = getPixel32(x, y); } } return(result); }
public BlitButton(double x, double y, BlitRect blit, Action callback, Rectangle area = null, Boolean states = true) { this.x = x; this.y = y; this.blit = blit; this.states = states; this.callback = callback; if (area == null) { area = new Rectangle(0, 0, blit.width, blit.height); } this.area = area; visible = true; active = false; focusLock = true; }
//[API("682")] public virtual void copyPixelsToByteArray(Rectangle rect, ByteArray data) { for (var x = (uint)rect.x; x < (rect.x + rect.width); x++) { for (var y = (uint)rect.y; y < (rect.y + rect.height); y++) { var i = x + y * imageData.Width; data.writeByte(imageData.Data[i]); data.writeByte(imageData.Data[i + 1]); data.writeByte(imageData.Data[i + 2]); if (transparent) { data.writeByte(imageData.Data[i + 3]); } } } }
public static void copyRectTo(Array <Array <int> > source, Rectangle rect, Array <Array <int> > target, int tx, int ty, Array <Array <int> > buffer) { int r, c; // buffering to account for any overlap for (r = 0; r < rect.height; r++) { for (c = 0; c < rect.width; c++) { buffer[r][c] = source[(int)rect.y + r][(int)rect.x + c]; } } for (r = 0; r < rect.height; r++) { for (c = 0; c < rect.width; c++) { target[ty + r][tx + c] = buffer[r][c]; } } }
extern public virtual Rectangle generateFilterRect(Rectangle sourceRect, BitmapFilter filter);
//[API("680")] extern public virtual ByteArray encode(Rectangle rect, Object compressor, ByteArray byteArray = null);
public BlitSprite(BitmapData spriteSheet, Rectangle rect, int dx = 0, int dy = 0) : base(dx, dy, (int)rect.width, (int)rect.height) { this.spriteSheet = spriteSheet; this.rect = rect; }
extern public virtual void unlock(Rectangle changeRect = null);
//[Version("10")] extern public virtual Vector <Vector <double> > histogram(Rectangle hRect = null);
extern public virtual void startDrag(bool lockCenter = false, Rectangle bounds = null);
extern public virtual uint threshold(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, string operation, uint threshold, uint color = 0, uint mask = 0xffffffff, bool copySource = false);
extern public virtual int pixelDissolve(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, int randomSeed = 0, int numPixels = 0, uint fillColor = 0);
//[API("667")] public virtual void startTouchDrag(int touchPointID, bool lockCenter = false, Rectangle bounds = null) { throw new NotImplementedException(); }
extern public virtual void merge(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, uint redMultiplier, uint greenMultiplier, uint blueMultiplier, uint alphaMultiplier);
extern public virtual void paletteMap(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, Array redArray = null, Array greenArray = null, Array blueArray = null, Array alphaArray = null);
public virtual void applyFilter(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, BitmapFilter filter) { filter.apply(sourceBitmapData, sourceRect, this, destPoint); }
extern public virtual void copyChannel(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, uint sourceChannel, uint destChannel);
extern public virtual void copyPixels(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, BitmapData alphaBitmapData = null, Point alphaPoint = null, bool mergeAlpha = false);
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(); } }
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); }