Jump to content
How to Install Plugins ×

triangular gradient


Enormator

Recommended Posts

triangulargradient.png

Makes a triangular gradient in selection (or on the full image when nothing is selected) from primary to secondary color (including alpha).


Here is the (quite simple) CodeLab source:

Spoiler

#region UICode
int Amount1=0;	//[0,100]Slider 1 Description
int Amount2=0;	//[0,100]Slider 2 Description
int Amount3=0;	//[0,100]Slider 3 Description
#endregion

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 SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
    int BrushWidth = (int)EnvironmentParameters.BrushWidth;
    double m,topborder;
    int locx,locy;

    ColorBgra CurrentPixel;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        locy = y-selection.Top;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            CurrentPixel = src[x,y];
            locx = x-selection.Left;
            m = (((double)selection.Bottom-selection.Top)/(selection.Right-selection.Left));
            topborder = m*locx;
            CurrentPixel.R = (byte)((PrimaryColor.R*locy+SecondaryColor.R*(topborder-locy))/topborder);
            CurrentPixel.G = (byte)((PrimaryColor.G*locy+SecondaryColor.G*(topborder-locy))/topborder);
            CurrentPixel.B = (byte)((PrimaryColor.B*locy+SecondaryColor.B*(topborder-locy))/topborder);
            CurrentPixel.A = (byte)((locy<=topborder ? ((PrimaryColor.A*locy+SecondaryColor.A*(topborder-locy))/topborder) : 0));
            dst[x,y] = CurrentPixel;
        }
    }
}

 

 

I did this because I needed it but you still may tell me what you think about it.

I use PdN 3.36 and have no clue what the recent version of PdN will say about that dll. If it doesn't work, just use codelab (if that still exists, don't know, was not here for quite a while)

 

TriangularGradient.zip

 

Edited by toe_head2001
Restored broken content
Link to comment
Share on other sites

  • 4 months later...

i downloaded this and it makes script lab crash like this:

File: C:\Archivos de programa\Paint.NET\Effects\ScriptLab.dll
     Effect Name: pyrochild.effects.scriptlab.ScriptLab
     Full error message: System.ArgumentException: An item with the same key has already been added.
  at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
  at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
  at pyrochild.effects.scriptlab.ConfigDialog..ctor()
  at pyrochild.effects.scriptlab.ScriptLab.get_Dialog()
  at pyrochild.effects.scriptlab.ScriptLab.CreateConfigDialog()
  at PaintDotNet.Menus.EffectMenuBase.RunEffectImpl(Type effectType) in D:\src\pdn\pdn_35x\src\PaintDotNet\Menus\EffectMenuBase.cs:line 799

using pdn 3.5.5

if i remove the dll scriptlab works again, any ideas? (i am using latest pyro plug pack 2010-4-01)

Link to comment
Share on other sites

I'm not an expert on the inner working of scriptlab, but see if you have two of the same *.dll file installed.

If you have two files the same, delete the earlier version & restart PDN.

Link to comment
Share on other sites

  • 7 months later...

Problems with the forum over the last day or two have led to some data loss (e.g. Avatars). Attachments may have also suffered. Hopefully this will be fixed before too long.

Link to comment
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...