Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Name: PlayerSheetMirror
- // Submenu: SMBX
- // Author: Enjl
- // Title: PlayerSheetMirror
- // Version: 1.0
- // Desc: Mirrors the right half of a player sprite sheet onto the left half.
- // Keywords:
- // URL:
- // Help:
- void Render(Surface dst, Surface src, Rectangle rect)
- {
- // Delete any of these lines you don't need
- Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
- int CenterX = ((selection.Right - selection.Left) / 2) + selection.Left;
- int CenterY = ((selection.Bottom - selection.Top) / 2) + selection.Top;
- ColorBgra PrimaryColor = EnvironmentParameters.PrimaryColor;
- ColorBgra SecondaryColor = EnvironmentParameters.SecondaryColor;
- int BrushWidth = (int)EnvironmentParameters.BrushWidth;
- int w = src.Width;
- int h = src.Height;
- double cX = w * 0.5;
- int cellWidth = (int) (w * 0.1);
- int cellHeight = (int) (h * 0.1);
- int rightBound = (int) Math.Min(cX, rect.Right);
- ColorBgra CurrentPixel;
- for (int y = rect.Top; y < rect.Bottom; y++)
- {
- if (IsCancelRequested) return;
- for (int x = rect.Left; x < rect.Right; x++)
- {
- int currentCellX = (int) Math.Floor((double) (x / cellWidth));
- int currentCellY = (int) Math.Floor((double) (y / cellHeight));
- int frame = currentCellX * 10 + currentCellY + 2 - 50;
- if (frame <= 0) {
- int xOffset = x - currentCellX * cellWidth;
- int yOffset = y - currentCellY * cellHeight;
- int targetCellX = (int) (Math.Floor((-frame) * 0.1d) * cellWidth) + cellWidth;
- int targetCellY = (int) ((((-frame) % 10)) * cellHeight);
- int newX = (int) (cX - 1 + targetCellX - xOffset);
- int newY = (int) (targetCellY + yOffset);
- newX = Math.Min(Math.Max(newX, 0), w - 1);
- newY = Math.Min(Math.Max(newY, 0), h - 1);
- CurrentPixel = src[newX,newY];
- dst[x,y] = CurrentPixel;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement