Ego Eram Reputo Posted 4 hours ago Share Posted 4 hours ago I've created this little French Tiling plugin. Can someone please tell me why it is rendering a 2px thick lines? (I expected a single pixel). Something to do with AA maybe? // Name: // Submenu: // Author: // Title: // Version: // Desc: // Keywords: // URL: // Help: // For help writing a GPU Drawing plugin: https://boltbait.com/pdn/CodeLab/help/tutorial/drawing/ #region UICode IntSliderControl tileSize = 10; // [8,100] Tile size IntSliderControl numberOfRows = 100; // [2,100] Number of Rows IntSliderControl numberOfColumns = 100; // [2,100] Number of Columns IntSliderControl hOffset = 0; // [0,5] Left to Right offset IntSliderControl vOffset = 0; // [0,5] Top to Bottom offset #endregion protected override unsafe void OnDraw(IDeviceContext deviceContext) { // TODO: replace this DrawImage statement with your GPU Drawing statements deviceContext.DrawImage(Environment.SourceImage); // define the pattern int[,] tilePattern = { {3,3,1,3,2,0}, {1,2,0,3,1,3}, {0,3,3,2,0,2}, {0,2,3,1,1,2}, {3,1,2,0,0,3}, {2,0,3,1,3,1} }; ISolidColorBrush outlineBrush = deviceContext.CreateSolidColorBrush(LinearColors.Black); for (int row = 0; row < numberOfRows; row++) { for (int col = 0; col < numberOfColumns; col++) { int x = col * tileSize; int y = row * tileSize; switch (tilePattern[(row+vOffset) % 6, (col+hOffset) % 6]) { case 0: // No borders on this cell break; case 1: // North border only deviceContext.DrawLine(x,y,x+tileSize,y,outlineBrush); break; case 2: // West border only deviceContext.DrawLine(x,y,x,y+tileSize,outlineBrush); break; case 3: // Both North and West borders deviceContext.DrawLine(x,y,x+tileSize,y,outlineBrush); deviceContext.DrawLine(x,y,x,y+tileSize,outlineBrush); break; } } } } Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
Rick Brewster Posted 3 hours ago Share Posted 3 hours ago I'll refer you to an old Stack Overflow answer I did back in 2012: https://stackoverflow.com/a/10773729/1191082 Let me know if you still have questions! 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted 2 hours ago Author Share Posted 2 hours ago Thanks Rick!! Alright. I have something that is.......workable // Name: // Submenu: // Author: // Title: // Version: // Desc: // Keywords: // URL: // Help: // For help writing a GPU Drawing plugin: https://boltbait.com/pdn/CodeLab/help/tutorial/drawing/ #region UICode IntSliderControl tileSize = 10; // [8,100] Tile size IntSliderControl numberOfRows = 100; // [2,100] Number of Rows IntSliderControl numberOfColumns = 100; // [2,100] Number of Columns IntSliderControl hOffset = 0; // [0,5] Left to Right offset IntSliderControl vOffset = 0; // [0,5] Top to Bottom offset #endregion protected override unsafe void OnDraw(IDeviceContext deviceContext) { // TODO: replace this DrawImage statement with your GPU Drawing statements deviceContext.DrawImage(Environment.SourceImage); // define the pattern int[,] tilePattern = { {3,3,1,3,2,0}, {1,2,0,3,1,3}, {0,3,3,2,0,2}, {0,2,3,1,1,2}, {3,1,2,0,0,3}, {2,0,3,1,3,1} }; ISolidColorBrush outlineBrush = deviceContext.CreateSolidColorBrush(LinearColors.Black); for (int row = 0; row < numberOfRows; row++) { for (int col = 0; col < numberOfColumns; col++) { float x = col * tileSize+0.5f; float y = row * tileSize+0.5f; Point2Float start = new Point2Float(x, y); Point2Float endX = new Point2Float(x+tileSize+0.5f, y); Point2Float endY = new Point2Float(x,y+tileSize+0.5f); switch (tilePattern[(row+vOffset) % 6, (col+hOffset) % 6]) { case 0: // No borders on this cell break; case 1: // North border only deviceContext.DrawLine(start,endX,outlineBrush); break; case 2: // West border only deviceContext.DrawLine(start,endY,outlineBrush); break; case 3: // Both North and West borders deviceContext.DrawLine(start,endX,outlineBrush); deviceContext.DrawLine(start,endY,outlineBrush); break; } } } } Feels a bit hacky, but it 's not like I'm going to release it 1 Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
toe_head2001 Posted 2 hours ago Share Posted 2 hours ago 16 minutes ago, Ego Eram Reputo said: Feels a bit hacky Indeed. You don't need to offset each point. You can set the offset once with UseTranslateTransform. https://forums.getpaint.net/topic/131297-gpu-drawing-lines-not-1px-wide/ 1 Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted 1 hour ago Author Share Posted 1 hour ago 59 minutes ago, toe_head2001 said: Indeed. You don't need to offset each point. You can set the offset once with UseTranslateTransform. https://forums.getpaint.net/topic/131297-gpu-drawing-lines-not-1px-wide/ Thanks for that. Can't believe that thread has exactly the same title - and yet I missed it Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
toe_head2001 Posted 49 minutes ago Share Posted 49 minutes ago 30 minutes ago, Ego Eram Reputo said: Can't believe that thread has exactly the same title - and yet I missed it It didn't... those posts were deeply buried in another forum topic, and I split them out. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.