nycos62

Members
  • Content Count

    21
  • Joined

  • Last visited

Community Reputation

4

About nycos62

  • Birthday 08/31/1981

Profile Information

  • Gender
    Male
  • Location
    France
  • Interests
    Game Dev / Web Design / C#

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. nycos62

    SpriteSheet Grid Modifier

    wow... colors are really complicated to classify : what is the limit between a brown, a grey, a black, and an orange, a yellow, a green color ?.. need to add trackbars to adjust palette color range detection depending on the picture palette...
  2. nycos62

    Reptorian's G'MIC Code Workshop

    Hello Reptillian, the purpose of reducing color palette could be applied like this : you get a photo of an existing place or object, you scale carrefully image to your game scale, then you reduce colors to obtain a starting point to draw over a sprite, yes , why not !! for your B ) point, if you can "magically" scale this into this, you are the man !! Bitmap Brothers Tank in Z game (artwork from Dan Malone I guess) original scale VS reworked X2 : If you really want to dig into the sprite scaling, here you will find a very efficient technique : https://imgur.com/a/gRXPJ (for what I understood, it use spline and pixel neighbour's comparison + edge detection to correct splines trajectories to guess the hidden details, it's not a simple filter applied on a picture) *I'm not a professional pixel artist, I'm making 2D games in my spare time, so take my opinions with moderation.. I work as developper for business applications, not always fun 😱🤯
  3. nycos62

    SpriteSheet Grid Modifier

    new plugin : Pixel Art Palette Reverse (dll=> ReversePalette.zip) (spritesheet unpacker plugin is paused...) *remember it's for pixel Art so if you use huge picture with huge amount of different color it going to be slow as hell purpose : extract and manipulate palette you want to apply shadow modification on sprite, you want to invert palette of sprite First check box shows palette grabbed in the selection, if no selection, full picture is processed Future : Add Reverse "By Color Family", TODO.. (need to code how to sort palette by color HUE range and reverse it) with "User Choice", you draw on the third line of pixels your custom palette to change colors directly on the result (if your canvas width is smaller than palette and you are using "User Choice" option, colors out of canvas are replaced with transparent // Name: Pixel Art Reverse Palette // Submenu: PixelArt // Author: Nycos62 // Title: Reverse palette in selected area(s) // Version: 0.1 // Desc: reversing the palette in selected zone // Keywords: // URL: // Help: #region UICode bool Amount1 = true; // [0,1] Show Palette and Reversed Palette bool Amount2 = false; // [0,1] Apply modified Palette byte Amount3 = 0; // Reversion Method|Full palette Sort|Full Intensity|By Grabbing Order|By Color Family(TODO...)|User choice(Draw Your custom Palette on 3rd line) bool Amount4 = true; //[0,1] Ignore transparent Color (0,0,0,0) bool Amount5 = true; //[0,1] Ignore semi transparent Colors #endregion void Render(Surface dst, Surface src, Rectangle rect) { //Getting selected Pixels System.Drawing.Drawing2D.RegionData selection = EnvironmentParameters.GetSelection(src.Bounds).GetRegionData(); Region reg = new Region(selection); RectangleF[] rects = reg.GetRegionScans(new Matrix()); //Grabbing Palette List<ColorBgra> colorsInSelection = new List<ColorBgra>(); foreach(RectangleF r in rects) { for (int y = (int)r.Top; y < r.Bottom; y++) { if (IsCancelRequested) return; if (y > 2)//Ignore top 3 lines to grab palette for (int x = (int)r.Left; x < r.Right; x++) { if (!colorsInSelection.Contains(src[x,y])) { if ((Amount5 && src[x,y].A == 255) || !Amount5) if ((Amount4 && src[x,y] != ColorBgra.Transparent) || !Amount4) colorsInSelection.Add(src[x,y]); } } } } //Copy into Result Palette System.Collections.ArrayList sortedColors = new System.Collections.ArrayList(); for (int i = 0; i < colorsInSelection.Count; i++) { ColorBgra col = new ColorBgra(); col.A = colorsInSelection[i].A; col.B = colorsInSelection[i].B; col.G = colorsInSelection[i].G; col.Bgra = colorsInSelection[i].Bgra; sortedColors.Add(col); } //ApplySort if (Amount3 == 0 || Amount3 == 4) sortedColors.Sort(new _ColorSorter()); if (Amount3 == 1) sortedColors.Sort(new _IntensitySorter()); //Copy Sorted Palette To Original palette colorsInSelection = new List<ColorBgra>(); for (int i = 0; i < sortedColors.Count; i++) { ColorBgra col = new ColorBgra(); col.A = ((ColorBgra)sortedColors[i]).A; col.B = ((ColorBgra)sortedColors[i]).B; col.G = ((ColorBgra)sortedColors[i]).G; col.Bgra = ((ColorBgra)sortedColors[i]).Bgra; colorsInSelection.Add(col); } if (IsCancelRequested) return; //Reverse Palette if (Amount3 == 4) { sortedColors = new System.Collections.ArrayList(); for (int x = 0; x < colorsInSelection.Count; x++) { if (x < dst.Bounds.Width) { sortedColors.Add(dst[x,2]); } else { sortedColors.Add(ColorBgra.Transparent); } } } else sortedColors.Reverse(); //Show palette on upperLeft image corner for (int i = 0; i < dst.Bounds.Width; i++) { if (Amount1 && i<colorsInSelection.Count) { dst[i,0] = colorsInSelection[i]; dst[i,1] = (ColorBgra)sortedColors[i]; } else { dst[i,0] = src[i,0]; dst[i,1] = src[i,1]; } } if (IsCancelRequested) return; //Apply change foreach(RectangleF r in rects) { for (int y = (int)r.Top; y < r.Bottom; y++) { if (IsCancelRequested) return; for (int x = (int)r.Left; x < r.Right; x++) { //avoid draw on palette if (!(x < colorsInSelection.Count && y < 3)) { if (Amount2) { if (colorsInSelection.Contains(src[x,y])) dst[x,y] = (ColorBgra)sortedColors[colorsInSelection.IndexOf(src[x,y])]; } else { dst[x,y] = src[x,y]; } } } } } } internal class _ColorSorter: System.Collections.IComparer { public int Compare (object x, object y) { // local variables Color cx, cy; float hx, hy, sx, sy, bx, by; // get Color values cx = ((ColorBgra) x).ToColor(); cy = ((ColorBgra) y).ToColor(); // get saturation values sx = cx.GetSaturation (); sy = cy.GetSaturation (); // get hue values hx = cx.GetHue (); hy = cy.GetHue (); // get brightness values bx = cx.GetBrightness (); by = cy.GetBrightness (); // determine order // 1 : hue if (hx < hy) return -1; else if (hx > hy) return 1; else { // 2 : saturation if (sx < sy) return -1; else if (sx > sy) return 1; else { // 3 : brightness if (bx < by) return -1; else if (bx > by) return 1; else return 0; } } } } internal class _IntensitySorter: System.Collections.IComparer { public int Compare (object x, object y) { return ((ColorBgra)x).GetIntensity().CompareTo(((ColorBgra)y).GetIntensity()); } } cheers ! Sorting Colors "By Family" : public string Classify(Color c) { float hue = c.GetHue(); float sat = c.GetSaturation(); float lgt = c.GetLightness(); if (lgt < 0.2) return "Blacks"; if (lgt > 0.8) return "Whites"; if (sat < 0.25) return "Grays"; if (hue < 30) return "Reds"; if (hue < 90) return "Yellows"; if (hue < 150) return "Greens"; if (hue < 210) return "Cyans"; if (hue < 270) return "Blues"; if (hue < 330) return "Magentas"; return "Reds"; }
  4. nycos62

    SpriteSheet Grid Modifier

    challenge accepted thank you for the tests I never thought to decrease cellSize , toe_head2001 was right // Name: SpriteSheet Grid Modifier // Submenu: PixelArt // Author: Nycos62 // Title: SpriteSheet Grid Modifier // Version: 0.1 // Desc: Modify Cell Grid Size in all layers // Keywords: // URL: // Help: #region UICode IntSliderControl Amount1 = 6; // [0,2000] X Cell number IntSliderControl Amount2 = 6; // [0,2000] Y Cell number IntSliderControl Amount3 = 14; // [0,2000] Original Cell width (X) IntSliderControl Amount4 = 14; // [0,2000] Original Cell height (Y) IntSliderControl Amount5 = 20; // [0,2000] Desired Cell width (New X) IntSliderControl Amount6 = 20; // [0,2000] Desired Cell height (New Y) #endregion void Render(Surface dst, Surface src, Rectangle rect) { //clear dest dst.Clear(rect, ColorBgra.Transparent); int XOffset = 0; int YOffset = 0; int XDiff = Amount5 - Amount3; int YDiff = Amount6 - Amount4; if (XDiff %2 == 0) XOffset = XDiff / 2; else XOffset = (int)(XDiff / 2); //TODO verify if (YDiff %2 == 0) YOffset = YDiff / 2; else YOffset = (int)(YDiff / 2); //TODO verify int XOffsetAfter = XDiff - XOffset; int YOffsetAfter = YDiff - YOffset; for (int cx = 0; cx < Amount1; cx++) { int XDecay = Math.Max(cx,0) * XOffsetAfter; for (int cy = 0; cy < Amount2; cy++) { int YDecay = Math.Max(cy,0) * YOffsetAfter; if (IsCancelRequested) return; //Copy cell with Offset for (int cell_posX = 0; cell_posX < Amount3; cell_posX++) { for (int cell_posY = 0; cell_posY < Amount4; cell_posY++) { int Xdest = cx * Amount3 + cell_posX + (cx+1) * XOffset + XDecay; int Ydest = cy * Amount4 + cell_posY + (cy+1) * YOffset + YDecay; int XSource = cx * Amount3 + cell_posX; int YSource = cy * Amount4 + cell_posY; //avoid drawing out of bounds dst/src [x,y] if (Xdest < dst.Bounds.Width && Ydest < dst.Bounds.Height && XSource < dst.Bounds.Width && YSource < dst.Bounds.Height && Xdest > 0 && Ydest > 0 && Xdest < Amount1 * Amount5 && Ydest < Amount2 * Amount6) dst[Xdest, Ydest] = src[XSource, YSource]; } } } } }
  5. nycos62

    SpriteSheet Grid Modifier

    I love challenges
  6. nycos62

    SpriteSheet Grid Modifier

    Unfortunatly, I can't use floodFill because Sprites are touching themselves in some spritesheets, there is not always a pixel between 2 sprites I'm trying technoRobbo basic edge detection with a mix of other edge detection to extract pixel blobs (in blue rectangles, the original sprite sheet has no transparent space between the sprites) For sprite with 2 or 3 objects, I'm thinking of an optional parameter 'Sprite MinX MinY Size'
  7. nycos62

    SpriteSheet Grid Modifier

    new plugin : SpriteSheet Unpacker Hello, is there a recommended approach to identify points clusters or shape center ? (K-means clustering .. ? https://towardsdatascience.com/the-5-clustering-algorithms-data-scientists-need-to-know-a36d136ef68 ) I want to identify each sprite of a packed spritesheet to tile them on a grid step 0 : put transparent color on background, expand canvas size OK step 1 : edge detection => get list of points (inner shape points / outer shape points) OK step 2 : identify clusters / get center point clusters ? with point list ? How to step 3: copy each cluster in center of same size grid cells OK
  8. nycos62

    SpriteSheet Grid Modifier

    sorry to disturb , okay..
  9. nycos62

    SpriteSheet Grid Modifier

    nice !! could you share code ?
  10. nycos62

    SpriteSheet Grid Modifier

    with this plugin you can guess the sprite dimensions when you start to work with pixel art materials found in google pictures, and you must know dimensions to import sprite sheets in game engine. For my personnal use I find them pretty effective. SpriteSheets are often packed, and in order to use AnimationHelper plugin from Pixelbyte Studio, you must center your sprite on tiles with same dimension
  11. nycos62

    SpriteSheet Grid Modifier

    good news ! I could not find these plugins, searched about 1 hour, and found codeLab, cost less time to code than search 😃
  12. nycos62

    SpriteSheet Grid Modifier

    maybe only at the first build ?
  13. nycos62

    SpriteSheet Grid Modifier

    PixelArt plugin Files DrawGrid.zip DrawCenterCell.zip SpriteSheetGridModifier.zip It could be great to add a OpenFileLocation Button after CodeLab generate a dll
  14. nycos62

    SpriteSheet Grid Modifier

    DrawCenterCell to draw a line on the center of the cell (line has 2 pixel width if cell dimension is even to see the real center of the cell) // Name: DrawCenterCell // Submenu: PixelArt // Author: Nycos62 // Title: Draw Center Cell Indicator // Version: 0.1 // Desc: Draw a line in center of cell for a given width and height // Keywords: // URL: // Help: #region UICode IntSliderControl Amount1 = 32; // [0,1000] Grid cell width (X) IntSliderControl Amount2 = 32; // [0,1000] Grid cell height (Y) #endregion void Render(Surface dst, Surface src, Rectangle rect) { //clear dest dst.Clear(rect, ColorBgra.Transparent); ColorBgra LineColor = ColorBgra.White; int CellCenterX = Amount1 / 2; int CellCenterY = Amount2 / 2; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { if ((x + CellCenterX)%Amount1 == 0 && y%2 == 0) dst[x,y] = LineColor; if ((y + CellCenterY)%Amount2 == 0 && x%2 == 0) dst[x,y] = LineColor; if (Amount1 % 2 == 0) if ((x + CellCenterX - 1)%Amount1 == 0 && y%2 == 1) dst[x,y] = LineColor; if (Amount2 % 2 == 0) if ((y + CellCenterY - 1)%Amount2 == 0 && x%2 == 1) dst[x,y] = LineColor; } } }