Jump to content

Recommended Posts

  • 4 weeks later...

Dear Seerose, <3:cake:  thank you so much for the wonderful picture and your kind words! You're always soooooooooooo nice ;)

And you already discovered the video about Rubber Stamp on YT, although I didn't post a link here ... :monocole:

  • Upvote 1

Signature1.png.079797f32dfc0fc11934054746690174.png

Link to post
Share on other sites
  • 7 months later...

To demonstrate some of the new features of CodeLab v3, I converted my 'Rubber Stamp' Visual Studio project to a CodeLab script.

New features specifically demonstrated here are:  the PreRender method, Slider Decorations (on Amount3), and Prop Rules (on Amount6).  Previously, those three things had to be done in Visual Studio.

 

Hopefully it will be of some interest to a few people.

 

Spoiler

// Name: Rubber Stamp
// Submenu: Object
// Author: toe_head2001
// Title:
// Version: 1.0
// Desc: Rubber Stamp Effect
// Keywords: rubber|stamp
// URL: https://forums.getpaint.net/index.php?showtopic=111225
#region UICode
IntSliderControl Amount1 = 50; // [0,100] Scale
DoubleSliderControl Amount2 = 1; // [0,1] Roughness
IntSliderControl Amount3 = 85; // [0,255,4] Minimum Opacity
ReseedButtonControl Amount4 = 0; // [255] Reseed
CheckboxControl Amount5 = false; // [0,1] Use Custom Color
ColorWheelControl Amount6 = ColorBgra.FromBgr(0,0,0); // [PrimaryColor] {Amount5} 
#endregion

readonly BinaryPixelOp normalOp = LayerBlendModeUtil.CreateCompositionOp(LayerBlendMode.Normal);
CloudsEffect cloudsEffect = new CloudsEffect();
PropertyCollection cloudsProps;
Surface emptySurface;
Surface cloudSurface;

void PreRender(Surface dst, Surface src)
{
    if (emptySurface == null)
        emptySurface = new Surface(src.Size);
    if (cloudSurface == null)
        cloudSurface = new Surface(src.Size);

    cloudsProps = cloudsEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken CloudsParameters = new PropertyBasedEffectConfigToken(cloudsProps);
    CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Scale, Amount1);
    CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Power, Amount2);
    CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Seed, (int)Amount4);
    using (EffectEnvironmentParameters environParameters = new EffectEnvironmentParameters(ColorBgra.Black, Color.FromArgb(Amount3, Color.Black), 0, EnvironmentParameters.GetSelectionAsPdnRegion(), emptySurface))
        cloudsEffect.EnvironmentParameters = environParameters;
    cloudsEffect.SetRenderInfo(CloudsParameters, new RenderArgs(cloudSurface), new RenderArgs(emptySurface));
}

void Render(Surface dst, Surface src, Rectangle rect)
{
    cloudsEffect.Render(new Rectangle[1] { rect }, 0, 1);

    ColorBgra currentPixel;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            currentPixel = (Amount5) ? Amount6 : src[x, y];
            currentPixel.A = Int32Util.ClampToByte(cloudSurface[x, y].A + src[x, y].A - byte.MaxValue);

            dst[x, y] = currentPixel;
        }
    }
}


protected override void OnDispose(bool disposing)
{
    if (disposing)
    {
        // Release any surfaces or effects you've created.
        if (emptySurface != null)
        {
            emptySurface.Dispose();
            emptySurface = null;
        }

        if (cloudSurface != null)
        {
            cloudSurface.Dispose();
            cloudSurface = null;
        }

        if (cloudsEffect != null)
        {
            cloudsEffect.Dispose();
            cloudsEffect = null;
        }
    }

    base.OnDispose(disposing);
}

 

 

 

Edited by toe_head2001
  • Like 2
  • Upvote 3
Link to post
Share on other sites
  • 2 years later...
  • 3 months later...
On 7/30/2020 at 1:38 AM, toe_head2001 said:

 

It still works just fine in the current version of paint.net.

What makes you say it didn't work?

I downloaded it and installed it but it does not show up in my effects menu. I wonder if I didn't install it correctly? I am not very experienced with this stuff at all,   but I noticed there are two things to download above - the source code and the  rubberstampzip - are they both the same or do both need to be downloaded and installed in the effect folder in paint??? I watched several videos on how to unzip, copy to paint effects folder etc, but  it doesn't show up in my pull down screen with the other effects.   Do you have a method of downloading that you would be able to share, I really want this effect but I'm sure its something I'm not doing correctly. Thank you!!

Edited by Laceydesigns
Link to post
Share on other sites

Classic or MS Store version?

 

Installation instructions can be found here: https://www.getpaint.net/doc/latest/InstallPlugins.html

Link to post
Share on other sites
1 hour ago, Ego Eram Reputo said:

Classic or MS Store version?

 

Installation instructions can be found here: https://www.getpaint.net/doc/latest/InstallPlugins.html

Classic. Once I have unzipped the folder how do I open it to look at the dll folders? I am so confused, every video I watch they just double click on it and it opens, mine asks to find a program to open it??  Sorry I'm just not good at this stuff.  

Edited by Laceydesigns
Link to post
Share on other sites

Not a problem, let's see if we can walk you through it :)

 

Right click on the zipped file and see if you have an option to Extract. If so hit that and then follow the prompt to extract the files.

 

Once you've extracted them, find where they were extracted to using your file explorer. Hint: probably in your Downloads folder.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...