RefreshedMango Posted February 21, 2020 Share Posted February 21, 2020 (edited) Hey People, I have question, how would I make the following script copy the rectangle and put it on "named layer"? Basically copying the 6 rectangles and putting them onto a new layer which I need to be automatically created. All 6 rectangles should be copied onto a new layer (all on same layer). void Render(Surface dst, Surface src, Rectangle rect) { //torso Rectangle fromRect = Rectangle.FromLTRB(231, 74, 359, 202); Rectangle toRect1 = Rectangle.FromLTRB(229, 125, 357, 353); //left arm Rectangle fromRect2 = Rectangle.FromLTRB(308, 355, 372, 483); Rectangle toRect2 = Rectangle.FromLTRB(357, 125, 421, 253); //right arm Rectangle fromRect3 = Rectangle.FromLTRB(217, 355, 281, 483); Rectangle toRect3 = Rectangle.FromLTRB(165, 125, 229, 253); //back Rectangle fromRect4 = Rectangle.FromLTRB(427, 74, 555, 202); Rectangle toRect4 = Rectangle.FromLTRB(229, 305, 357, 433); //back left arm Rectangle fromRect5 = Rectangle.FromLTRB(85, 355, 149, 483); Rectangle toRect5 = Rectangle.FromLTRB(357, 305, 421, 433); //back right arm Rectangle fromRect6 = Rectangle.FromLTRB(440, 355, 504, 483); Rectangle toRect6 = Rectangle.FromLTRB(165, 305, 229, 433); ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; if (toRect1.Contains(x, y)) { int offSetX = x - toRect1.Left + fromRect.Left; int offSetY = y - toRect1.Top + fromRect.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect2.Contains(x, y)) { int offSetX = fromRect2.Right - toRect2.Right + x; int offSetY = y - toRect2.Top + fromRect2.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect3.Contains(x, y)) { int offSetX = fromRect3.Right - toRect3.Right + x; int offSetY = y - toRect3.Top + fromRect3.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect4.Contains(x, y)) { int offSetX = fromRect4.Right - toRect4.Right + x; int offSetY = y - toRect4.Top + fromRect4.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect5.Contains(x, y)) { int offSetX = fromRect5.Right - toRect5.Right + x; int offSetY = y - toRect5.Top + fromRect5.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect6.Contains(x, y)) { int offSetX = fromRect6.Right - toRect6.Right + x; int offSetY = y - toRect6.Top + fromRect6.Top; CurrentPixel = src[offSetX, offSetY]; } dst[x,y] = CurrentPixel; } } } Edited February 21, 2020 by RefreshedMango Quote Link to comment Share on other sites More sharing options...
BoltBait Posted February 21, 2020 Share Posted February 21, 2020 You should probably read this list: Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted February 22, 2020 Share Posted February 22, 2020 ^ ...so a new layer isn't going to be possible. You could create a new blank layer prior to running your plugin and have it write to that. Would that work for you? Oh and a big WELCOME to the paint.net fourm RefreshedMango 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...
Reptillian Posted February 22, 2020 Share Posted February 22, 2020 (edited) Two options 1) What @Ego Eram Reputo said. 2) ImageMagick/G'MIC-QT (This can work with multiple layer). In addition to what @Ego Eram Reputo said, I think individual colors could be used to get around the needs of multiple layers. If 1 and this workaround isn't viable, then I can help. It doesn't look hard to replicate. In C# and PDN, multiple for loop is the solution for multiple color workaround. Also, this seems like roblox template. Edited February 22, 2020 by Reptillian Quote G'MIC Filter Developer Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted February 22, 2020 Share Posted February 22, 2020 EDIT: oh I see - you want to copy bits to another location. Try this on a duplicate of the source layer void Render(Surface dst, Surface src, Rectangle rect) { //torso Rectangle fromRect = Rectangle.FromLTRB(231, 74, 359, 202); Rectangle toRect1 = Rectangle.FromLTRB(229, 125, 357, 353); //left arm Rectangle fromRect2 = Rectangle.FromLTRB(308, 355, 372, 483); Rectangle toRect2 = Rectangle.FromLTRB(357, 125, 421, 253); //right arm Rectangle fromRect3 = Rectangle.FromLTRB(217, 355, 281, 483); Rectangle toRect3 = Rectangle.FromLTRB(165, 125, 229, 253); //back Rectangle fromRect4 = Rectangle.FromLTRB(427, 74, 555, 202); Rectangle toRect4 = Rectangle.FromLTRB(229, 305, 357, 433); //back left arm Rectangle fromRect5 = Rectangle.FromLTRB(85, 355, 149, 483); Rectangle toRect5 = Rectangle.FromLTRB(357, 305, 421, 433); //back right arm Rectangle fromRect6 = Rectangle.FromLTRB(440, 355, 504, 483); Rectangle toRect6 = Rectangle.FromLTRB(165, 305, 229, 433); ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = ColorBgra.Transparent; if (toRect1.Contains(x, y)) { int offSetX = x - toRect1.Left + fromRect.Left; int offSetY = y - toRect1.Top + fromRect.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect2.Contains(x, y)) { int offSetX = fromRect2.Right - toRect2.Right + x; int offSetY = y - toRect2.Top + fromRect2.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect3.Contains(x, y)) { int offSetX = fromRect3.Right - toRect3.Right + x; int offSetY = y - toRect3.Top + fromRect3.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect4.Contains(x, y)) { int offSetX = fromRect4.Right - toRect4.Right + x; int offSetY = y - toRect4.Top + fromRect4.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect5.Contains(x, y)) { int offSetX = fromRect5.Right - toRect5.Right + x; int offSetY = y - toRect5.Top + fromRect5.Top; CurrentPixel = src[offSetX, offSetY]; } if (toRect6.Contains(x, y)) { int offSetX = fromRect6.Right - toRect6.Right + x; int offSetY = y - toRect6.Top + fromRect6.Top; CurrentPixel = src[offSetX, offSetY]; } dst[x,y] = CurrentPixel; } } } 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...
RefreshedMango Posted February 22, 2020 Author Share Posted February 22, 2020 Thank you, Thank you for the warm welcome @Ego Eram Reputo and thank you for the help however I have two more questions I'm hoping you could answer. How would insert an image using code, and what file would I put it in? How would make the image start from lets say "Top Left Point (0,0)"? How would I cut out a rectangle so it is transparent (no background)? How would I make a rectangle with 1 thickness and start from (0,0 top left) to (0,0 bottom right)? I have looked everywhere and I cant find an answer. I am using c# language and codelab. Your help will be very much appreciated. Quote 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.