Jump to content

Help with Stripe Plugin


Pratyush
 Share

Recommended Posts

I don't understand what is happening here, I want declare a method  and call it. How to make it work?

ynOJDi8.png

 

Spoiler

// Name: Gradual Stripes
// Submenu: Render
// Author: Pratyush
// Title: Gradual Stripes
// Version: 1.2.0
// Desc: Draws stripes with gradual change in shades
// Keywords: Stripes|Grayscale|Lines
// URL:
// Help:
#region UICode
IntSliderControl Amount1 = 5; // [2,64] Quantity of Gradual Stripes
IntSliderControl Amount2 = 1; // [1,10] No. of repeatation
ColorWheelControl Amount3 = ColorBgra.FromBgr(0,0,0); // [PrimaryColor] Primary Color
ColorWheelControl Amount4 = ColorBgra.FromBgr(255,255,255); // [SecondaryColor] Secondary color
CheckboxControl Amount5 = false; // [0,1] Invert
CheckboxControl Amount6 = false; // [0,1] Center
CheckboxControl Amount7 = true; // [0,1] Smoothen
#endregion



void Render(Surface dst, Surface src, Rectangle rect)
{
    ColorBgra PC = Amount3;
    ColorBgra SC = Amount4;

    //Invert color in plugin
    if ( Amount5 == true)
    {
        ColorBgra k = PC;
        PC = SC;
        SC = k;
    }

    // Step 0 is the first step, how much left to do: Amount - 1
    int Maxgroup = Amount1 - 1;
    //Maxgroup = Maxgroup;
    // Define the size of step per Channel
    // assuming PC is the start and SC is the end
    int stepR = (SC.R - PC.R) / Maxgroup;
    int stepG = (SC.G - PC.G) / Maxgroup;
    int stepB = (SC.B - PC.B) / Maxgroup;
    int stepA = 0; //(PC.A + SC.A) / Maxgroup;


    ColorBgra CurrentPixel;

    // qunatity of shade to cover the canvas
    float divide = (float)rect.Width / Amount1;
    divide = divide/Amount2;
    int sf1,sf2,sf3;
    
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            CurrentPixel = src[x,y];
            int k,group;
            k=x;
            if(Amount6 == true){k=(k+(rect.Width/2))%rect.Width;}
            group = (int)(k / divide);
            group = (group)%Amount1;
            k = (int)(k% divide);
            
            sf1 = SmoothingFactor(int k, int StepR);
            sf2 = SmoothingFactor(int k, int StepG);
            sf3 = SmoothingFactor(int k, int StepB);
            sf4 = SmoothingFactor(int k, int StepA);
            
            CurrentPixel.R = (byte)(PC.R + stepR * group + sf1);
            CurrentPixel.G = (byte)(PC.G + stepG * group + sf2);
            CurrentPixel.B = (byte)(PC.B + stepB * group + sf3);
            CurrentPixel.A = (byte)(PC.A + stepA * group + sf4);
            dst[x,y] = CurrentPixel;
        }
    }

}

public int SmoothingFactor(int ki, int Step)
    {

        double c = (double)ki/Step;
        c= (10-9*c)*Math.Pow(c,9);
        return (int)c;
    }

 

 

 

Edited by Pratyush

Rl7un0O.png

Link to comment
Share on other sites

    ColorBgra PC = Amount3;
    ColorBgra SC = Amount4;

    //Invert color in plugin
    if ( Amount5 == true)
    {
        ColorBgra k = PC;
        PC = SC;
        SC = k;
    } 

Tidier... (edited thanks to MadJik's tip)

    ColorBgra PC, SC;
    
    //reverse colors if Amount5 is true
    if (Amount5) // you can optionally omit "== true" here
    {
       PC = Amount4;
       SC = Amount3; 
    }
    else
    { 
       PC = Amount3;
       SC = Amount4;
    }

 

  • Like 1
Link to comment
Share on other sites

I really should check my code before posting :lol:

 

Edit: fixed.

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.

 Share

×
×
  • Create New...