-
Posts
10 -
Joined
-
Last visited
-
Days Won
1
Posts posted by Mallaboro
-
-
- Popular Post
- Popular Post
Turns orthogonal images into isometric spritesheets.
As of this release (v1.0) it is limited only to size 128x, 64y tiles.
Download: IsometricTiled.zip
Source: Pastebin (IsometricTiled.cs)
Generic on-use UI
✔️ Render Background, ❌Arrange Tiles by Orthogonal Position
Having 'Arrange tiles by orthogonal position' unchecked makes tiles arrange in columns, having it checked however, it tries to keep some semblance of its original position. This makes reassembling the image much easier.
✔️ Render Background, ✔️ Arrange Tiles by Orthogonal Position
I made this because I'm working on a project that uses isometric tiles, and this way I can paint trees normally, then slice them into tiles and import them into Tiled for making game maps.
Issues
There is an issue I've not been able to resolve. If the canvas is not large enough to fit all the tiles they will not be added to the canvas.
Furthermore, while this isn't an issue it should be noted that if the background is not transparent, the plugin will recognise the background as a tile and copy it as one.
Lastly...
This is my first plugin for paint.net, and the first thing I've ever published.
It was made just for me, so it's missing a few features that I can live without, like the option to change tile dimensions and the background colour.
I'll add the option to change tile dimensions sometime later but for now I really want to get back to working on my project.
CodeLab SourceSpoiler// Name: Isometric Tiled // Submenu: Stylize // Author: Anthony "Mallaboro" // Title: Isometric Builder // Version: 1.0 // Desc: Turns orthogonal images into an array of isometric tiles // Keywords: Orthogonal, Isometric // URL: https://litematrix.blogspot.com/ // Help: anthonyeboothroyd@gmail.com #region UICode bool Amount1 = true;//Render background (black) bool Amount2 = true;//Arrange tiles by orthogonal position #endregion class Tile { //tile width and height public static int Width = 128; public static int Height = 64; //these indexes are used when arranging tiles by orthogonal position public int x = 0; public int y = 0; //the array of pixel data public ColorBgra[,] pixels; public Tile(int x, int y, bool checkers) { pixels = new ColorBgra[ Tile.Width, Tile.Height ]; this.x = x; this.y = y; if(checkers) { //outside for( int _y = 0; _y < Tile.Height; _y++ ) for( int _x = 0; _x < Tile.Width; _x++ ) { if( _y < Tile.Height / 2 ) if( _x <= ( Tile.Width / 2 ) - ( 2 * _y ) || _x >= Tile.Width / 2 + ( 2 * _y ) ) { pixels[ _x, _y ].R = 0; pixels[ _x, _y ].G = 0; pixels[ _x, _y ].B = 0; pixels[ _x, _y ].A = 255; } if( _y >= Tile.Height / 2 ) if( _x <= ( Tile.Width / 2 ) - ( Tile.Width / 2 ) + ( _y - ( Tile.Height / 2 ) ) * 2 || _x >= ( Tile.Width / 2 ) + ( Tile.Width / 2 ) - ( _y - ( Tile.Height / 2 ) ) * 2 ) { pixels[ _x, _y ].R = 0; pixels[ _x, _y ].G = 0; pixels[ _x, _y ].B = 0; pixels[ _x, _y ].A = 255; } } } } //"Input" the incoming pixel data //"x", "y", the pixel index of this tiles pixel array public void Set( ColorBgra input, int x, int y ) { //temporary restriction, we do not accept black pixels //if( pixels[ x, y ] == ColorBgra.Black ) // return; //if the incoming pixel being set is within these parameters, //it is within this tiles shape and will be stored. bool left = x <= Tile.Width / 2; bool right = x >= Tile.Width / 2; bool top = y <= Tile.Height / 2; bool topRight = x < ( Tile.Width / 2 ) + ( y * 2 ); bool topLeft = x > ( Tile.Width / 2 ) - ( y * 2 ); bool bot = y > Tile.Height / 2; bool botLeft = x > ( 2 * ( y - Tile.Height / 2 ) ); bool botRight = x < ( Tile.Width ) - ( 2 * ( y - Tile.Height / 2 ) ); //tiles are seporated into 4 quadrants. If the incoming pixel overlaps one of these 4 quadrants it is stored. if( top ) if( left && topLeft ) { pixels[ x, y ] = input; } if( top ) if( right && topRight ) { pixels[ x, y ] = input; } if( bot ) if( left && botLeft ) { pixels[ x, y ] = input; } if( bot ) if( right && botRight ) { pixels[ x, y ] = input; } } //returns whether or not this tile contains any pixel of color (excluding pure black and pure white) public bool IsOccupied() { for( int y = 0; y < Height; y++ ) for( int x = 0; x < Width; x++ ) { if( pixels[ x, y ].R > 0 && pixels[ x, y ].R < 255 || pixels[ x, y ].G > 0 && pixels[ x, y ].G < 255 || pixels[ x, y ].B > 0 && pixels[ x, y ].B < 255 ) return true; } return false; } //returns the specified pixel at the x, y index. public ColorBgra Get( int x, int y ) { return pixels[ x, y ]; } } void Render( Surface dst, Surface src, Rectangle rect ) { //clear the canvas for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) dst[x,y] = ColorBgra.Transparent; } //NOTE TO SELF: top-left is 0, 0 //a list of occupied tiles containing data List<Tile> tiles = new List<Tile>( ); //sample tile to check whether it has any data Tile sample; //toggle changes every Y iteration. It keeps the x-axis in the correct position for isometric images //(toggle == true == pixel_x = 0), (else pixel_x = -( Tile.Width / 2 );) bool toggle = false; //pixelX and Y are the top-left corners of the tile being analyzed. These values change. int pixel_x = -( Tile.Width / 2 ); int pixel_y = -( Tile.Height / 2 ); //easy-access int width = src.Bounds.Width; int height = src.Bounds.Height; //tiles wide and tiles tall are incrimented by 1 to capture the image along the edges //to elaborate: tiles[0,0] position is -(Tile.Width / 2, -(Tile.Height / 2 //tiles tall is doubled to account for Tile.Height being half of Tile.Width int tilesWide = (width / Tile.Width) + 1; int tilesTall = (height / Tile.Height) * 2 + 1; //assign each tile their location for (int y = 0; y < tilesTall; y++) { for (int x = 0; x < tilesWide; x++) { sample = new Tile(x, y, Amount1); for (int Y = 0; Y < Tile.Height; Y++) { for (int X = 0; X < Tile.Width; X++) { if ((pixel_x + X < 1) || (pixel_y + Y < 1)) continue; if ((pixel_x + X > width-2) || (pixel_y + Y > height-2)) continue; sample.Set(src[pixel_x + X, pixel_y + Y], X, Y); } } if(sample.IsOccupied()) tiles.Add(sample); pixel_x += Tile.Width; } toggle = !toggle; pixel_x = toggle == true ? 0 : -( Tile.Width / 2); pixel_y += Tile.Height / 2; } int _x = 0; int _y = 0; if(Amount2 == false) { for(int i = 0; i < tiles.Count; i++) { for (pixel_y = 0; pixel_y < Tile.Height; pixel_y++) for (pixel_x = 0; pixel_x < Tile.Width; pixel_x++) { //prevent crashes if screen width or height isn't great enough //to fit the tiles if((_x * Tile.Width) + pixel_x >= width) break; if((_y * Tile.Height) + pixel_y >= height) break; dst[ (_x * Tile.Width) + pixel_x , ( _y * Tile.Height) + pixel_y] = tiles[i].pixels[pixel_x, pixel_y]; } _x++; if(_x >= tilesWide-1) { _x = 0; _y ++; } } } else { for(int i = 0; i < tiles.Count; i++) { for (pixel_y = 0; pixel_y < Tile.Height; pixel_y++) for (pixel_x = 0; pixel_x < Tile.Width; pixel_x++) { //prevent crashes if screen width or height isn't great enough //to fit the tiles if((tiles[i].x * Tile.Width) + pixel_x >= width) break; if((tiles[i].y * Tile.Height) + pixel_y >= height) break; dst[ (tiles[i].x * Tile.Width) + pixel_x , ( tiles[i].y * Tile.Height) + pixel_y] = tiles[i].pixels[pixel_x, pixel_y]; } } } }
- 5
- 5
-
Ah, cheers Rick.
-
That is really quite phenomenal. So many applications ?
-
Hello there, quick question. how can I change the canvas size in a script?
-
Nearly finished my plugin. ? As a long-time user of paint.net I must say I'm quite proud.
- 1
-
Thought I'd share my WiP. It turns images into an array of isometric tiles that fit into a mesh. Sooo, it's not great. But... it's a start, I guess.
becomes
becomes
-
Thanks, I'll take a look into that. I've just found Ego's forum post which shows all plugins and it looks like you're right.
-
I've never had to troubleshoot paint(dot)net before but the installation could be stalling. If you try alt+ctrl+delete -> task manager -> details, then look for anything resembling the paint(dot)net installer and end its task, then try and install again, that could work.
You could also try installing it as administrator.
Hope it helps.
- 1
-
Hello, I'm new to this forum so if this isn't the appropriate topic for this post I apologise.
From what I can tell there's a large number of plugins made by users, and I'm looking for one that converts orthogonal images into an array of isometric tiles.
To help demonstrate what I mean I made this image
If no such plugin has been made I might consider making one myself.
Parallel Lines and Patterns
in Plugins - Publishing ONLY!
Posted
I love this plugin Been printing out A3 sheets of graph paper for D&D games. Cheers Martin.
If I could make a suggestion it would be to add dimetric ( 1 : 2 ) lines, ( opposed to Isometric 1 : 1 ). Don't know if anyone but me would use it though.
Anyhoo, thanks again.