Panhead Posted January 19, 2008 Share Posted January 19, 2008 hello, its Panhead (no duh) ive been messing around with codelab trying to make a plugin that creates a simple X on the canvas, so far i can only create an X on a square even dimensioned canvas, i know its simple void Render(Surface dst, Surface src, Rectangle rect) { // Delete any of these lines you don't need Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { long middleX = CenterX; long middleY = CenterY; long oddIdentifierY = (middleY % 2); long oddIdentifierX = (middleX % 2); CurrentPixel = src[x,y]; // TODO: Add pixel processing code here if ((oddIdentifierY == 1) && (oddIdentifierX == 1)) { if ((x == y - (y - x)) && (y == (( CenterY * 2) - x))) { // Access RGBA values this way, for example: CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } if (x == y) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } } if ((oddIdentifierY == 0) && (oddIdentifierX == 0)) { if ((x == y - (y - x)) && (y == (( CenterY * 2) - (x + 1)))) { // Access RGBA values this way, for example: CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } if (x == y) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } } dst[x,y] = CurrentPixel; } } } ok the first if statement isnt running, because when i run it on an odd canvas it still runs only the forth if statement, did i code the first one right? im not sure, if i can get this done, i will work on being able to do it on a rectangular canvas. any help would be appreciated Quote My deviantART iGraphix ~96% of teens won't stand up for God. Put this on your page if you're one of the 4% who will. skilletism (n.) - The abnormal liking of the band "Skillet". (see PANHEAD) panhead n. - an individual who shows extreme enthusiasm for the band Skillet. Generally driving for hours to concerts with frying pans riding shotgun. Link to comment Share on other sites More sharing options...
MadJik Posted January 19, 2008 Share Posted January 19, 2008 For a rectangle you need the ratio between height and width... I didn't get the odd stuff... And you could simplify it (if you want it centered): void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; if ((Math.Abs(x - CenterX)) == (Math.Abs(y - CenterY))) { CurrentPixel = PrimaryColor; } dst[x,y] = CurrentPixel; } } } Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal Link to comment Share on other sites More sharing options...
Panhead Posted January 19, 2008 Author Share Posted January 19, 2008 the odd thing has to do with the top right corner, the code i tried was to figure out a different equation for when the canvas has dimensions like 801x801, and then run it only when the canvas had odd dimensions, which i know is rare to have a canvas like that, but still i would like to be efficient, i think i just need to learn the different resources that are available in the PDN program, like Math.Abs....i dont know what that is, i knew i had to know a ratio, but i just didnt know what the variables name was. ill try this code out in a little, i got to go do something Quote My deviantART iGraphix ~96% of teens won't stand up for God. Put this on your page if you're one of the 4% who will. skilletism (n.) - The abnormal liking of the band "Skillet". (see PANHEAD) panhead n. - an individual who shows extreme enthusiasm for the band Skillet. Generally driving for hours to concerts with frying pans riding shotgun. Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted January 24, 2008 Share Posted January 24, 2008 the odd thing has to do with the top right corner, the code i tried was to figure out a different equation for when the canvas has dimensions like 801x801, and then run it only when the canvas had odd dimensions, which i know is rare to have a canvas like that, but still i would like to be efficient Why run two equations based on odd/even canvas size? Why not run the same code on both with the rider that the odd sized canvas will be perfect and the even sized canvas will have a 1 pixel column (or row) unused at the right edge (or bottom edge)? (I haven't tried your code so I'm only guessing to the effect you're after.) 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...
Panhead Posted January 25, 2008 Author Share Posted January 25, 2008 i dont know, i dont have much experience with C# so i think i am going to hold off on the plugins, but thanks for the help Quote My deviantART iGraphix ~96% of teens won't stand up for God. Put this on your page if you're one of the 4% who will. skilletism (n.) - The abnormal liking of the band "Skillet". (see PANHEAD) panhead n. - an individual who shows extreme enthusiasm for the band Skillet. Generally driving for hours to concerts with frying pans riding shotgun. 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.