ReMake Posted February 17, 2016 Share Posted February 17, 2016 (edited) Very simple effect which simulates a sketch by color pencils. Open any image. I used a changed stock photo from FireStock. Create a copy of a background layer (or apply a combination of keys Ctrl+Shift+D).Apply to this layer Invert Colors effect (Adjustments -> Invert Colors or apply a combination of keys Ctrl+Shift+I). Open Properties of a layer (key F4) and choose a blend mode Color Dodge. The active window will be filled with white color. Depending on the image selected by you, in some places there can be dark areas, but the majority of the document will be filled by the white. Apply to the active layer Gaussian blur effect (Effects-> Blurs-> Gaussian Blur). Move a Radius control to the right before obtaining of necessary result. For this image I stopped on 3 pixels. Merge both layers (keys Ctrl+M) and we have necessary result.Try to apply to this image Brightness/Contrast effect (Adjustments -> Brightness/Contrast), thus values of brightness and contrast should have identical values, but with an opposite sign (for example, at value of contrast equal 10 brightness should be equal -10). By the way, built-in Pencil Sketch effect is built on this same algorithm.Now let's begin to create this effect. Open CodeLab (Effects-> Advanced-> CodeLab). Start CodeLab (Effects-> Advanced-> CodeLab). Choose New in the menu File. In a dialogue box Script Editor click a No button. The dialogue box New Source (Template) will be presented to you. In the drop-down list choose Gaussian Blur. From the upper drop-down list PixelOp choose Invert and in the drop-down list Blend choose ColorDodge. Click the Generate Code button. We will get the following script of effect: // Name: // Submenu: // Author: // Title: // Version: // Desc: // Keywords: // URL: // Help: #region UICode IntSliderControl Amount1=10; // [0,100] Radius #endregion // Setup for using pixel op private UnaryPixelOps.Invert invertOp = new UnaryPixelOps.Invert(); // Setup for using ColorDodge blend op private BinaryPixelOp colordodgeOp = LayerBlendModeUtil.CreateCompositionOp(LayerBlendMode.ColorDodge); // Here is the main render loop function void Render(Surface dst, Surface src, Rectangle rect) { // Setup for calling the Gaussian Blur effect GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection blurProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps); BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1); blurEffect.SetRenderInfo(BlurParameters, new RenderArgs(dst), new RenderArgs(src)); // Call the Gaussian Blur function blurEffect.Render(new Rectangle[1] {rect},0,1); // Now in the main render loop, the dst canvas has a blurred version of the src canvas for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { ColorBgra CurrentPixel = dst[x,y]; // TODO: Add additional pixel processing code here CurrentPixel = invertOp.Apply(CurrentPixel); CurrentPixel = colordodgeOp.Apply(src[x,y], CurrentPixel); dst[x,y] = CurrentPixel; } } } Save this code with name ColorSketch (File -> Save or keys Ctrl+S). Again choose New in the menu File. In the drop-down list choose Contrast. In the generated script select and copy (Ctrl+C) the following code: // Setup for calling the Brightness and Contrast Adjustment function BrightnessAndContrastAdjustment bacAdjustment = new BrightnessAndContrastAdjustment(); PropertyCollection bacProps = bacAdjustment.CreatePropertyCollection(); PropertyBasedEffectConfigToken bacParameters = new PropertyBasedEffectConfigToken(bacProps); bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, Amount1); bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, Amount2); bacAdjustment.SetRenderInfo(bacParameters, new RenderArgs(dst), new RenderArgs(src)); // Call the Brightness and Contrast Adjustment function bacAdjustment.Render(new Rectangle[1] {rect},0,1); // Now in the main render loop, the dst canvas has an adjusted version of the src canvas Load ColorSketch.cs script which was saved earlier (File -> Open or keys Ctrl+O) and paste this code before line for (int y = rect.Top; y < rect.Bottom; y++) Open the designer interface (File -> User Interface Designer or keys Ctrl+I), select in it the Radius control and rename it to Pencil tip size. Set the maximum value to 20, set the default value to 2 and the minimum value to 1. Click the Update button. Select Integer Slider in the Control type box. Type Range in the Control name box. Set the maximum value to 20, set the default value to 0 and the minimum value to -20. Click the Add button. Click button OK.In the line bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, Amount1); replace Amount1 on Amount2.In the line bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, Amount2); set the minus sign before Amount2: bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, -Amount2); In the line bacAdjustment.SetRenderInfo(bacParameters, new RenderArgs(dst), new RenderArgs(src)); replace src on dst: bacAdjustment.SetRenderInfo(bacParameters, new RenderArgs(dst), new RenderArgs(dst)); Correct the comment: // Now in the main render loop, the dst canvas has an adjusted version of the src canvas // Now in the main render loop, the dst canvas has an adjusted version Fill the commented lines at the top of the script, for example, like these: // Name: Color Sketch // Submenu: Artistic // Author: ReMake // Title: Color Sketch v1.0 ReMake 2016 // Version: 1.0 // Desc: The Paint.NET the effect which simulates a sketch by color pencils // Keywords: paint.net|effect|color|sketch // URL: http://www.getpaint.net/redirect/plugins.html // Help: Our final script should look like this: // Name: Color Sketch // Submenu: Artistic // Author: ReMake // Title: Color Sketch v1.0 ReMake 2016 // Desc: The Paint.NET the effect which simulates a sketch by color pencils // Keywords: paint.net|effect|color|sketch // URL: http://www.getpaint.net/redirect/plugins.html #region UICode int Amount1=2; // [1,20] Pencil tip size int Amount2=0; // [-20,20] Range #endregion // Setup for using pixel op private UnaryPixelOps.Invert invertOp = new UnaryPixelOps.Invert(); // Setup for using ColorDodge blend op private UserBlendOps.ColorDodgeBlendOp colordodgeOp = new UserBlendOps.ColorDodgeBlendOp(); // Here is the main render loop function void Render(Surface dst, Surface src, Rectangle rect) { // Setup for calling the Gaussian Blur effect GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection blurProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps); BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1); blurEffect.SetRenderInfo(BlurParameters, new RenderArgs(dst), new RenderArgs(src)); // Call the Gaussian Blur function blurEffect.Render(new Rectangle[1] {rect},0,1); // Now in the main render loop, the dst canvas has a blurred version of the src canvas // Setup for calling the Brightness and Contrast Adjustment function BrightnessAndContrastAdjustment bacAdjustment = new BrightnessAndContrastAdjustment(); PropertyCollection bacProps = bacAdjustment.CreatePropertyCollection(); PropertyBasedEffectConfigToken bacParameters = new PropertyBasedEffectConfigToken(bacProps); bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, Amount2); bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, -Amount2); bacAdjustment.SetRenderInfo(bacParameters, new RenderArgs(dst), new RenderArgs(dst)); // Call the Brightness and Contrast Adjustment function bacAdjustment.Render(new Rectangle[1] {rect},0,1); // Now in the main render loop, the dst canvas has an adjusted version for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { ColorBgra CurrentPixel = dst[x,y]; // TODO: Add additional pixel processing code here CurrentPixel = invertOp.Apply(CurrentPixel); CurrentPixel = colordodgeOp.Apply(src[x,y], CurrentPixel); dst[x,y] = CurrentPixel; } } } Save it with the same name (ColorSketch.cs).Create for this effect an icon in the PNG format with the size 16x16 pixels. I used the modified icon of the built-in Pencil Sketch effect: Save this effect as a DLL file (File -> Save as DLL or keys Ctrl+В). Try this effect in Paint.NET.The user interface of our new effect looks like this. I hope this has not caused difficulties for you. Edited February 17, 2016 by ReMake 2 1 Quote Link to comment Share on other sites More sharing options...
BoltBait Posted February 18, 2016 Share Posted February 18, 2016 Have you seen Scratch Art Paper? Here are the CodeLab options to make it: Here's your image after turning it into a Scratch Art: Enjoy. 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...
ReMake Posted February 18, 2016 Author Share Posted February 18, 2016 On 18.02.2016 at 3:04 AM, BoltBait said: Have you seen Scratch Art Paper? I read articles about Scratch Art - it's interesting. A good idea for the next plug-in. Thank You. See: Scratch Art Style in Paint.NET. 1 Quote Link to comment Share on other sites More sharing options...
lynxster4 Posted September 9, 2018 Share Posted September 9, 2018 I wanted to thank you, also, @ReMake, for the informative series of coding lessons. Kudos for posting all this information to us 'coding newbies'! ? 1 Quote My Art Gallery | My Shape Packs | ShapeMaker Mini Tut | Air Bubble Stained Glass Chrome Text with Reflections | Porcelain Text w/ Variegated Coloring | Realistic Knit PatternOpalescent Stained Glass | Frosted Snowman Cookie | Leather Texture | Plastic Text | Silk Embroidery Visit my Personal Website "Never, ever lose your sense of humor - you'll live longer" 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.