public void PasteBitmapToSpritesheetAlpha(RagePixelTexel position, Rect spriteUV, RagePixelBitmap bitmap) { for (int y = Mathf.Max(position.Y, 0); y < position.Y + bitmap.Height() && y < (int)(spriteUV.height * spritesheetTexture.height); y++) { for (int x = Mathf.Max(position.X, 0); x < position.X + bitmap.Width() && x < (int)(spriteUV.width * spritesheetTexture.width); x++) { Color src = bitmap.GetPixel(x - position.X, y - position.Y); Color trg = spritesheetTexture.GetPixel((int)(spriteUV.x * spritesheetTexture.width) + x, (int)(spriteUV.y * spritesheetTexture.height) + y); spritesheetTexture.SetPixel( (int)(spriteUV.x * spritesheetTexture.width) + x, (int)(spriteUV.y * spritesheetTexture.height) + y, src + (1f-src.a) * trg ); } } }
public void PasteBitmapToSpritesheet(RagePixelTexel position, Rect spriteUV, RagePixelBitmap bitmap) { for (int y = Mathf.Max(position.Y, 0); y < position.Y + bitmap.Height() && y < (int)(spriteUV.height * spritesheetTexture.height); y++) { for (int x = Mathf.Max(position.X, 0); x < position.X + bitmap.Width() && x < (int)(spriteUV.width * spritesheetTexture.width); x++) { spritesheetTexture.SetPixel( (int)(spriteUV.x * spritesheetTexture.width) + x, (int)(spriteUV.y * spritesheetTexture.height) + y, bitmap.GetPixel(x - position.X, y - position.Y) ); } } }