xod Posted December 18, 2014 Share Posted December 18, 2014 Thank you all for your advices and help. The BoltBait's website is very useful, and I use this opportunity to thank him for all the work in developing Lab Code and his wonderful website. About translation... I use Google Translate because I don't studied English ever until now. In school I learned French and Russian, but I never was a very diligent student. My intention was to precisely drawn some guide lines to obtain a digital photo album. The template layer is only used to center the image inside selection (center both). Quote Link to comment Share on other sites More sharing options...
ReMake Posted December 18, 2014 Share Posted December 18, 2014 (edited) I am very glad that you have achieved the goal. I am sure your plugin will be useful for other users and you share it after it's final finishing. Noroc! Edited December 18, 2014 by ReMake 1 Quote Link to comment Share on other sites More sharing options...
Eli Posted December 25, 2014 Share Posted December 25, 2014 Hello, I hope we will see a final version of this plugin. Quote Link to comment Share on other sites More sharing options...
xod Posted March 25, 2016 Share Posted March 25, 2016 (edited) New version: Effects → Render → GuideLines GuideLines.zip Spoiler A brief example of use. It can be run with active selection. You can use multiple empty layers to run that plugin and then you can make that layers invisible if you want. Spoiler // Name: GuideLines // Author: xod // Submenu: Render // URL: // Title: GuideLines // CodeLab v2.12 #region UICode ListBoxControl Amount1 = 0; // Line Style and Color|Solid|Dash|Dash-Dot|Dash-Dot-Dot|Dot ColorWheelControl Amount2 = ColorBgra.FromBgr(0,0,0); // IntSliderControl Amount3 = 1; // [1,1000] Line Width ListBoxControl Amount4 = 0; // Axes|None ⁞|Vertical|Horizontal|Both ListBoxControl Amount5 = 0; // Diagonals|None ⁞|First|Second|Both ListBoxControl Amount6 = 0; // Half to corners|None ⁞|Horiz Left|Horiz Right|Horiz Both|Vert Up|Vert Down|Vert Both|H and V Both ListBoxControl Amount7 = 0; // Half to half|None ⁞|Horiz Left|Horiz Right|Both|Vert Up|Vert Down ListBoxControl Amount8 = 0; // Options|None|Move X, Y|Axes Offset = X|Borders Offset = Y|Both Offsets X, Y|VLineSpace = X|HLineSpace = Y|Grid X, Y IntSliderControl Amount9 = 20; // [0,11811] X IntSliderControl Amount10 = 20; // [0,11811] Y #endregion void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); dst.CopySurface(src,rect.Location,rect); // copy surface quicker than looping through byte penstyle = (byte)(Amount1); ColorBgra pencol = Amount2; float penW = Amount3; float sTop = selection.Top; float sBot = selection.Bottom; float sLeft = selection.Left; float sRite = selection.Right; float H = selection.Height; float midH = (H/2) - 0.5f; float W = selection.Width; float midW = (W/2) - 0.5f; byte TypeAxe = (byte)(Amount4); byte TypeDiag = (byte)(Amount5); byte TyHaCo = (byte)(Amount6); byte TyHaHa = (byte)(Amount7); byte Options = (byte)(Amount8); using (RenderArgs ra = new RenderArgs(dst)) { Graphics graf = ra.Graphics; graf.Clip = new Region(rect); graf.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; using(Pen colpen = new Pen(pencol)) { colpen.Width = penW; switch(penstyle) { case 0:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; break; case 1:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; break; case 2:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; break; case 3:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; break; case 4:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; break; } //************************************************************************* switch(TypeAxe) // Draw Axes { case 0: //none break; case 1: //vertical PointF topmid = new PointF(sLeft + midW, sTop - 1f); PointF botmid = new PointF(sLeft + midW, sBot); graf.DrawLine(colpen, topmid, botmid); break; case 2: //horizontal PointF leftmid = new PointF(sLeft - 1f, sTop + midH); PointF ritemid = new PointF(sRite, sTop + midH); graf.DrawLine(colpen, leftmid, ritemid); break; case 3: //vertical & horizontal PointF topmid1 = new PointF(sLeft + midW, sTop - 1f); //vertical & horizontal PointF botmid1 = new PointF(sLeft + midW, sBot); graf.DrawLine(colpen, topmid1, botmid1); PointF leftmid1 = new PointF(sLeft - 1f, sTop + midH); PointF ritemid1 = new PointF(sRite, sTop + midH); graf.DrawLine(colpen, leftmid1, ritemid1); break; } //************************************************************************* switch(TypeDiag) // Draw Diagonals { case 0: //none break; case 1: //1st diag. PointF topleft = new PointF(sLeft, sTop); PointF botrite = new PointF(sRite, sBot - 0.5f); graf.DrawLine(colpen, topleft, botrite); break; case 2: //2nd diag. PointF toprite = new PointF(sRite, sTop - 1f); PointF botleft = new PointF(sLeft, sBot - 1f); graf.DrawLine(colpen, botleft, toprite); break; case 3: //first & second PointF topleft1 = new PointF(sLeft, sTop); PointF botrite1 = new PointF(sRite, sBot - 0.5f); PointF toprite1 = new PointF(sRite, sTop - 1f); PointF botleft1 = new PointF(sLeft, sBot - 1f); graf.DrawLine(colpen, topleft1, botrite1); graf.DrawLine(colpen, botleft1, toprite1); break; } //********************************************************************** switch(TyHaCo) // Draw Half to corners { case 0: //none break; case 1: //Horiz Left PointF leftmid = new PointF(sLeft - 1f, sTop + midH); PointF toprite = new PointF(sRite, sTop - 1f); PointF botrite = new PointF(sRite, sBot - 0.5f); graf.DrawLine(colpen, leftmid, toprite ); graf.DrawLine(colpen, leftmid, botrite); break; case 2: //Horiz Right PointF ritemid = new PointF(sRite, sTop + midH); PointF topleft = new PointF(sLeft, sTop); PointF botleft = new PointF(sLeft, sBot - 1f); graf.DrawLine(colpen, ritemid, topleft ); graf.DrawLine(colpen, ritemid, botleft); break; case 3: //Horiz Both PointF leftmid1 = new PointF(sLeft - 1f, sTop + midH); PointF toprite1 = new PointF(sRite, sTop - 1f); PointF botrite1 = new PointF(sRite, sBot - 0.5f); graf.DrawLine(colpen, leftmid1, toprite1 ); graf.DrawLine(colpen, leftmid1, botrite1); PointF ritemid1 = new PointF(sRite, sTop + midH); PointF topleft1 = new PointF(sLeft, sTop); PointF botleft1 = new PointF(sLeft, sBot - 1f); graf.DrawLine(colpen, ritemid1, topleft1 ); graf.DrawLine(colpen, ritemid1, botleft1); break; case 4: //Vert Up PointF topmid = new PointF(sLeft + midW, sTop - 1f); PointF botleft2 = new PointF(sLeft, sBot - 1f); PointF botrite2 = new PointF(sRite, sBot - 0.5f); graf.DrawLine(colpen, topmid, botleft2); graf.DrawLine(colpen, topmid, botrite2); break; case 5: //Vert Down PointF botmid = new PointF(sLeft + midW, sBot); PointF toprite2 = new PointF(sRite, sTop - 1f); PointF topleft2 = new PointF(sLeft, sTop); graf.DrawLine(colpen, botmid, toprite2); graf.DrawLine(colpen, botmid, topleft2); break; case 6: //Vert. Both PointF topmid1 = new PointF(sLeft + midW, sTop - 1f); PointF botleft3 = new PointF(sLeft, sBot - 1f); PointF botrite3 = new PointF(sRite, sBot - 0.5f); graf.DrawLine(colpen, topmid1, botleft3); graf.DrawLine(colpen, topmid1, botrite3); PointF botmid1 = new PointF(sLeft + midW, sBot); PointF toprite3 = new PointF(sRite, sTop - 1f); PointF topleft3 = new PointF(sLeft, sTop); graf.DrawLine(colpen, botmid1, toprite3); graf.DrawLine(colpen, botmid1, topleft3); break; case 7: //Horiz. & Vert. Both PointF leftmid2 = new PointF(sLeft - 1f, sTop + midH); PointF toprite4 = new PointF(sRite, sTop - 1f); PointF botrite4 = new PointF(sRite, sBot - 0.5f); graf.DrawLine(colpen, leftmid2, toprite4); graf.DrawLine(colpen, leftmid2, botrite4); PointF ritemid2 = new PointF(sRite, sTop + midH); PointF topleft4 = new PointF(sLeft, sTop); PointF botleft4 = new PointF(sLeft, sBot - 1f); graf.DrawLine(colpen, ritemid2, topleft4); graf.DrawLine(colpen, ritemid2, botleft4); PointF topmid2 = new PointF(sLeft + midW, sTop - 1f); PointF botleft5 = new PointF(sLeft, sBot - 1f); PointF botrite5 = new PointF(sRite, sBot - 0.5f); graf.DrawLine(colpen, topmid2, botleft5); graf.DrawLine(colpen, topmid2, botrite5); PointF botmid2 = new PointF(sLeft + midW, sBot); PointF toprite5 = new PointF(sRite, sTop - 1f); PointF topleft5 = new PointF(sLeft, sTop); graf.DrawLine(colpen, botmid2, toprite5); graf.DrawLine(colpen, botmid2, topleft5); break; } //************************************************************************ switch(TyHaHa) // Draw Half to Half { case 0: //none break; case 1: // Oriz.Left PointF leftmid = new PointF(sLeft - 1f, sTop + midH); PointF topmid = new PointF(sLeft + midW, sTop - 1f); PointF botmid = new PointF(sLeft + midW, sBot); graf.DrawLine(colpen, leftmid, topmid); graf.DrawLine(colpen, leftmid, botmid); break; case 2: // Oriz.Right PointF ritemid = new PointF(sRite, sTop + midH); PointF topmid1 = new PointF(sLeft + midW, sTop - 1f); PointF botmid1 = new PointF(sLeft + midW, sBot); graf.DrawLine(colpen, ritemid, topmid1); graf.DrawLine(colpen, ritemid, botmid1); break; case 3: // Oriz.Both PointF leftmid1 = new PointF(sLeft - 1f, sTop + midH); PointF topmid2 = new PointF(sLeft + midW, sTop - 1f); PointF botmid2 = new PointF(sLeft + midW, sBot); graf.DrawLine(colpen, leftmid1, topmid2); graf.DrawLine(colpen, leftmid1, botmid2); PointF ritemid1 = new PointF(sRite, sTop + midH); PointF topmid3 = new PointF(sLeft + midW, sTop - 1f); PointF botmid3 = new PointF(sLeft + midW, sBot); graf.DrawLine(colpen, ritemid1, topmid3); graf.DrawLine(colpen, ritemid1, botmid3); break; case 4: // Vert.Up PointF topmid4 = new PointF(sLeft + midW, sTop - 1f); PointF leftmid2 = new PointF(sLeft - 1f, sTop + midH); PointF ritemid2 = new PointF(sRite, sTop + midH); graf.DrawLine(colpen, topmid4, leftmid2); graf.DrawLine(colpen, topmid4, ritemid2); break; case 5: // Vert.Down PointF botmid4 = new PointF(sLeft + midW, sBot); PointF leftmid3 = new PointF(sLeft - 1f, sTop + midH); PointF ritemid3 = new PointF(sRite, sTop + midH); graf.DrawLine(colpen, botmid4, leftmid3); graf.DrawLine(colpen, botmid4, ritemid3); break; } //*************************************************************** switch(Options) { case 0: //none break; case 1: // Move Lines PointF left = new PointF(sLeft - 1f, sTop + Amount9); PointF rite = new PointF(sRite, sTop + Amount9); PointF top = new PointF(Amount10 + sLeft, sTop - 1f); PointF bot = new PointF(Amount10 + sLeft, sBot); graf.DrawLine(colpen,top,bot); graf.DrawLine(colpen,left,rite); break; case 2: // Axes Offsets PointF topmid = new PointF(Amount9 + sLeft + midW, sTop - 1f); PointF botmid = new PointF(Amount9 + sLeft + midW, sBot); PointF leftmid = new PointF(sLeft - 1f, sTop + midH + Amount9); PointF ritemid = new PointF(sRite, sTop + midH + Amount9); graf.DrawLine(colpen,topmid,botmid); graf.DrawLine(colpen,leftmid,ritemid); PointF topmid1 = new PointF(sLeft + midW - Amount9, sTop - 1f); PointF botmid1 = new PointF(sLeft + midW - Amount9, sBot); PointF leftmid1 = new PointF(sLeft - 1f, sTop + midH - Amount9); PointF ritemid1 = new PointF(sRite, sTop + midH - Amount9); graf.DrawLine(colpen,topmid1,botmid1); graf.DrawLine(colpen,leftmid1,ritemid1); break; case 3: // Borders Offsets PointF top1 = new PointF(Amount10 + sLeft, sTop - 1f); PointF bot1 = new PointF(Amount10 + sLeft, sBot); PointF left1 = new PointF(sLeft - 1f, sTop + Amount10); PointF rite1 = new PointF(sRite, sTop + Amount10); graf.DrawLine(colpen,top1,bot1); graf.DrawLine(colpen,left1,rite1); PointF top2 = new PointF(sRite - Amount10, sTop - 1f); PointF bot2 = new PointF(sRite - Amount10, sBot); PointF left2 = new PointF(sLeft - 1f, sBot - Amount10); PointF rite2 = new PointF(sRite, sBot - Amount10); graf.DrawLine(colpen,top2,bot2); graf.DrawLine(colpen,left2,rite2); break; case 4: // Axes + Borders Offsets PointF topmid2 = new PointF(Amount9 + sLeft + midW, sTop - 1f); PointF botmid2 = new PointF(Amount9 + sLeft + midW, sBot); PointF leftmid2 = new PointF(sLeft - 1f, sTop + midH + Amount9); PointF ritemid2 = new PointF(sRite, sTop + midH + Amount9); graf.DrawLine(colpen,topmid2,botmid2); graf.DrawLine(colpen,leftmid2,ritemid2); PointF topmid3 = new PointF(sLeft + midW - Amount9, sTop - 1f); PointF botmid3 = new PointF(sLeft + midW - Amount9, sBot); PointF leftmid3 = new PointF(sLeft - 1f, sTop + midH - Amount9); PointF ritemid3 = new PointF(sRite, sTop + midH - Amount9); graf.DrawLine(colpen,topmid3,botmid3); graf.DrawLine(colpen,leftmid3,ritemid3); PointF top3 = new PointF(Amount10 + sLeft, sTop - 1f); PointF bot3 = new PointF(Amount10 + sLeft, sBot); PointF left3 = new PointF(sLeft - 1f, sTop + Amount10); PointF rite3 = new PointF(sRite, sTop + Amount10); graf.DrawLine(colpen,top3,bot3); graf.DrawLine(colpen,left3,rite3); PointF top4 = new PointF(sRite - Amount10, sTop - 1f); PointF bot4 = new PointF(sRite - Amount10, sBot); PointF left4 = new PointF(sLeft - 1f, sBot - Amount10); PointF rite4 = new PointF(sRite, sBot - Amount10); graf.DrawLine(colpen,top4,bot4); graf.DrawLine(colpen,left4,rite4); break; case 5: //Vertical lines: X = identation for ( int x = 0; x < sRite; x++) { int step = x * Amount9; graf.DrawLine(colpen, step, sTop, step, sBot); } break; case 6: //Horizontal lines: Y = identation for (int y = 0; y < sBot; y++) { int step = y * Amount10; graf.DrawLine(colpen, sLeft, step, sRite, step); } break; case 7: //GridLines: X, Y = identation for (int x = 0; x < sRite; x++) { int step = x * Amount9; graf.DrawLine(colpen, step, sTop, step, sBot); } for (int y = 0; y < sBot; y++) { int step = y * Amount10; graf.DrawLine(colpen, sLeft, step, sRite, step); } break; } } } } Edited August 12, 2016 by xod 3 Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted March 25, 2016 Share Posted March 25, 2016 New version: Effects → Render → GuideLines Why not use selection.Width and selection.Height? float H = selection.Height; It makes the code faster to read compared to 'Stop - Sbot'. I would also suggest you use camel casing on variables. Naming a variable 'Stop' made me think it was a coordinate of a stopping point. It wasn't until I saw its assignment that I realized it meant selection top. sTop or selTop would be much better. You'll want to read Rick's comment about using Graphics objects properly in effects: http://forums.getpaint.net/index.php?/topic/32489-how-to-enable-cleartype/#entry433310 Good job. 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...
xod Posted March 25, 2016 Share Posted March 25, 2016 (edited) toe_head2001 thanks for the point of reputation but I don't deserve it because actually I didn't do anything else only I took pieces of code written by the others (Red ochre and you) and to adapt this code. I'm just a beginner and I have a lot, a lot to learn. I have no age to still have the enthusiasm of youth. When I look at the young men (but not only) clever here, what wonderful things they can do! I realize that I can't catch up these ones. I thank those who have kindly to post the code here in the forum. Just so we (beginners) can learn a few things. Edited March 25, 2016 by xod 1 Quote Link to comment Share on other sites More sharing options...
ReMake Posted March 25, 2016 Share Posted March 25, 2016 ... I took pieces of code written by the others (Red ochre and you) and to adapt this code. The ability to use the works of other authors is a good method of learning also. 1 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.