TechnoRobbo Posted July 8, 2013 Share Posted July 8, 2013 (edited) TechnoRobbo's Halftone Plugin This plugin was designed to simulate Halftone printing technique used in newspapers and magazine. The plug in interprets color depth with a Dot or a Square. The larger the dot the more lights gets taken away from the background. The color option creates a pseudo CMYK Halftone Effect except the halftone screens aren't rotated. Instructions not necessary - just play around Menu: Effects->Stylize Purple Mila Color Mila Eye See Dots The Code Hidden Content: // Submenu: Stylize // Name: TR's Half Tone // Title: TR's Half Tone - v1.0 // Author: TechnoRobbo // URL: http://www.technorobbo #region UICode int Amount1 = 4; // [2,16] Cell Size bool Amount2 = false; // [0,1] Color Dither byte Amount3 = 0; // [1] Dither Shape|Dots|Boxes ColorBgra Amount4 = ColorBgra.FromBgr(0,0,0); // Two Tone Color bool Amount5 = false; // [0,1] Use Background Color ColorBgra Amount6 = ColorBgra.FromBgr(0,0,0); // Background Color #endregion void Render(Surface dst, Surface src, Rectangle rect) { Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); float CellSize = Amount1; bool BW=!Amount2; int dither = Amount3; ColorBgra custom =Amount4; bool useBG=Amount5; ColorBgra BGColor = Amount6; //test variable //BW=false; dst.CopySurface( src,rect.Location,rect); //---------------------------------- Graphics g = new RenderArgs(dst).Graphics; g.Clip =new Region(rect); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //BackGround------------------------------- System.Drawing.SolidBrush BBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White); if (useBG){BBrush = new System.Drawing.SolidBrush(BGColor);} //-------------------------- g.FillRectangle(BBrush , new Rectangle(sel.Top, sel.Left,sel.Width,sel.Height)); BBrush.Dispose(); g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; //=========================================================================================== ColorBgra CP; System.Drawing.SolidBrush CBrush = new System.Drawing.SolidBrush(custom); System.Drawing.SolidBrush NBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); System.Drawing.SolidBrush RBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Cyan); System.Drawing.SolidBrush GBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Magenta); System.Drawing.SolidBrush BLBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow); System.Drawing.SolidBrush TBrush = NBrush; float offset = 0; Rectangle Cell; int alt=0; for (float y = sel.Top; y < sel.Bottom; y += CellSize) { int altx=0; for (float x = sel.Left; x < sel.Right; x += CellSize) { CP = src.GetBilinearSampleClamped(x,y); if (BW){ float v =(float)(CP.R + CP.G + CP.B)/3/255; offset = (1-v) * CellSize ; Cell = new Rectangle((int)( x + CellSize/2 - (alt % 2 ) * CellSize/2 - offset), (int)(y + CellSize/2 - offset), (int)offset, (int)offset); TBrush=CBrush; }else{ float halfcell=CellSize/2; float[] stagger={0,0,0,0,halfcell,halfcell,halfcell,halfcell,0,0,0,0,halfcell,halfcell,halfcell,halfcell}; int[] cswitch={0,1,2,3, 2,3,0,1, 3,0,1,2, 2,3,0,1}; int toggle=(alt % 4) * 4 + (altx % 4); switch(cswitch[toggle]){ case 0: float r =(float)CP.R/255; offset = (1-r) * CellSize; TBrush=RBrush; break; case 1: float gr =(float)CP.G/255; offset = (1-gr) * CellSize ; TBrush=GBrush; break; case 2: float b =(float)CP.B/255; offset = (1- * CellSize ; TBrush=BLBrush; break; case 3: float k =(float)(CP.R + CP.G + CP.B)/3/255; offset = (1-k) * CellSize ; TBrush=NBrush; break; } Cell = new Rectangle((int)( x + CellSize/2 + stagger[toggle] - offset), (int)(y + CellSize/2 - offset), (int)offset, (int)offset); } if (dither==0){ g.FillEllipse(TBrush,Cell); }else{ g.FillRectangle(TBrush,Cell); } altx++; } alt++; } NBrush.Dispose(); RBrush.Dispose(); GBrush.Dispose(); BLBrush.Dispose(); TBrush.Dispose(); CBrush.Dispose(); } TRsHalfTone.zip Edited December 28, 2015 by TechnoRobbo 1 2 Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
mottoman Posted July 8, 2013 Share Posted July 8, 2013 This has its use as a texture also. Good plug-in. 2 Quote Link to comment Share on other sites More sharing options...
mottoman Posted July 8, 2013 Share Posted July 8, 2013 :MoveLayerUp: Happy to know I am not alone in thinking it moves Thank you Welshblue. Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted July 8, 2013 Author Share Posted July 8, 2013 Mila Kunis moves me too Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
nitenurse79 Posted July 8, 2013 Share Posted July 8, 2013 Great use mottoman and a neat sig you have too 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.