Jump to content

Pratyush

Members
  • Posts

    249
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Pratyush

  1. Hi,

    I added feature for repeating stripes. I was trying to add choice of vertical and horizontal stripes.

    In case of vertical stripes it's working fine. But when I try to create horizontal stripes it gets some problem.

    Here is code.

     

    // 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] Vertical
    #endregion
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        ColorBgra PC = Amount3;
        ColorBgra SC = Amount4;
    
        // 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;
        float divide;
        // qunatity of shade to cover the canvas
        if (Amount5 == false)
        {
    
            divide = (float)rect.Width / Amount1;
            divide = divide/Amount2;
            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 group = (int)(x / divide);
                    group = group%Amount1;
                    CurrentPixel.R = (byte)(PC.R + stepR * group);
                    CurrentPixel.G = (byte)(PC.G + stepG * group);
                    CurrentPixel.B = (byte)(PC.B + stepB * group);
                    CurrentPixel.A = (byte)(PC.A + stepA * group);
                    dst[x,y] = CurrentPixel;
                }
            }
        }
        else
        {
            divide = (float)rect.Height / Amount1;
            divide = divide/Amount2;
    
            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 group = (int)(y / divide);
                    group = group%Amount1;
                    CurrentPixel.R = (byte)(PC.R + stepR * group);
                    CurrentPixel.G = (byte)(PC.G + stepG * group);
                    CurrentPixel.B = (byte)(PC.B + stepB * group);
                    CurrentPixel.A = (byte)(PC.A + stepA * group);
                    dst[x,y] = CurrentPixel;
                }
            }
        }
    
    }

     

    78c8WBF.jpg

    But in case of horizontal i get following. 

    6KYBHJz.jpg

     

    What should we need to do get output.

  2. Hi All,

     

    This plugin makes stripes with specified number. It begins with 1st color and after changing its shade step by step it converges to secondary color. 

    Version 2.0 is entirely rewritten. Many thanks to @BoltBait for all of his effort making this effect a reality.

    New version respects the selection and doesn't gets distorted with its border. (For those who like distortion property of earlier version I have also kept previous plugin here, Both can installed together as they have different DLL version number, New plugin will has a slightly different icon.)

     

    New UI: 

    cflXelh.png

    Spoiler

    v1.0 created plugin

    v1.1 added feature for repeating 

    v1.2 added feature to invert colors

    v1.3 added feature to start from centre

    v2.0 New version entirely rewritten. It has fully freely movable nubs and it respects selection.

     

    TT6TGTB.png

     

    If it is rendered on an active selection (in case of older version), the renders depends upon the shape of selection.

    DUiyWY6.png

     

    Version 2.0 

    7i644hv.png

    Download v1.3 

    Download v2.0 

    • Like 5
    • Upvote 3
  3. Just for sake of history of reporting bugs I am quoting it here. 

    14 hours ago, Pratyush said:

    Hi @BoltBait @toe_head2001 , I am trying to write a plugin in codelab. When I run the code in Codelab, it works perfectly. but problem is When I try see see preview some error happens.

    eOhfKtC.png

     

    And I am also not able to build dll. 

    23Vm3Qu.png

     

     boltbait's reply.

     

    34 minutes ago, BoltBait said:
    6 hours ago, toe_head2001 said:

    in both cases it's failing to compile, because CodeLab is generating UI code for Amount2 and Amount3, but the fields backing that code are commented out.  We'll correct this for future versions of CodeLab.

     

    I coded a fix for this.  It will be in the next release of CodeLab.

     

    Basically, it will ignore any commented out lines.  If you use the UIBuilder, when you click OK, those lines will be deleted.

     

  4. 7 hours ago, MadJik said:

    Each stripe step size per chanel RGB is (Secondary - Primary) / (Amount1 - 1) //MJW is right

     

    Yup, you were right. after changing its value now stripes start from Primary Color and end with Secondary Color. I was feeling something is miss because both side doesn't matching to primary and secondary color.

  5. @MadJik Thanks for your help, my code is done and it run and build successfully. ( You solved it. :biggrin:)

     

    But I want the stripes left start from zero and right less 

    This value makes the last right shade equal to secondary color, while first left shade not equal to primary color. 

    g1 = (PrimaryColor.R *(n - i) + (i)*SecondaryColor.R)/

    But I prefer that first left shade to be equal to primary color, (RHS can be different) so I had used this code.

    g1 = (PrimaryColor.R *(n - i) + (i -1)*SecondaryColor.R)/n 

    That should I need to do to achieve that

  6. Hi @BoltBait @toe_head2001 , I am trying to write a plugin in codelab. When I run the code in Codelab, it works perfectly. but problem is When I try see see preview some error happens.

    eOhfKtC.png

     

    And I am also not able to build dll. 

    23Vm3Qu.png

     

    PFA below the my script and icon file for dll. 

     

    The effect is not complete but work in progress. I will be happy If you can find out what went wrong and how to build dll. I need this effect for some important work. ( I need to draw stripes on  canvas with any specified number.)

     

    // Name: Gradual Stripes
    // Submenu: Render
    // Author: Pratyush
    // Title: Gradual Stripes
    // Version: 1.0.0
    // Desc: Draws stripes with gradual change in shades
    // Keywords: Stripes|Grayscale|Lines
    // URL:
    // Help:
    #region UICode
    IntSliderControl Amount1 = 9; // [0,64] Slider 1 Description
    #endregion
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        // Delete any of these lines you don't need
        Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
        int CenterX = ((selection.Right - selection.Left) / 2) + selection.Left;
        int CenterY = ((selection.Bottom - selection.Top) / 2) + selection.Top;
        ColorBgra PrimaryColor = EnvironmentParameters.PrimaryColor;
        ColorBgra SecondaryColor = EnvironmentParameters.SecondaryColor;
        int BrushWidth = (int)EnvironmentParameters.BrushWidth;
    
        ColorBgra CurrentPixel;
        for (int y = rect.Top; y < rect.Bottom; y++)
        {
            int n = Amount1;
            int[] A = new int[n+1];
            int i;
            /* initialize elements of array n */
            A[0] = rect.Left;
            if (IsCancelRequested) return;
            for ( i = 1; i <= n; i++ )
            {
                A[ i ] = (rect.Left*(n - i) + i*rect.Right)/n;
                for (int x = A[i-1]; x < A[i]; x++)
                {
                    CurrentPixel = src[x,y];
                    //int p = PrimaryColor.R;
                    int g1,g2,g3,g4;
                    g1 = (PrimaryColor.R *(n - i) + (i -1)*SecondaryColor.R)/n;
                    g2 = (PrimaryColor.G *(n - i) + (i -1)*SecondaryColor.G)/n;
                    g3 = (PrimaryColor.B *(n - i) + (i -1)*SecondaryColor.B)/n;
                    g4 = (PrimaryColor.A *(n - i) + (i -1)*SecondaryColor.A)/n;
    
                    CurrentPixel.R = (byte)g1;
                    CurrentPixel.G = (byte)g2;
                    CurrentPixel.B = (byte)g3;
                    CurrentPixel.A = (byte)g4;
                    dst[x,y] = CurrentPixel;
    			}
            }
        }
    }

     

    gradual stripes.png

    MyScript_2.cs

  7. 14 hours ago, toe_head2001 said:

    Let's see, which of these two is faster and easier?

    A -  Typing a number into the editor.

    B -  Opening the File menu, clicking a menu item, moving a UI control around to adjust a value, clicking OK.

     

    I fail to see how one could find option B to be useful. More work and more time consuming.

     

    Yeah. I agree that's stupid. Seriously What was I thinking that time.

  8. On 1/9/2018 at 6:00 AM, Ego Eram Reputo said:

    An Alpha Mask layer is still high on my wish list :)

     

    Once support period for windows 7 (i.e. 2020) is completed will we have some chance for new new blend mode in PDN. Since all of the person will have  option to upgrade to v4.0.

  9. 15 minutes ago, BoltBait said:

     

    When running CodeLab, you can press Ctrl+P (File > Preview) to preview your effect including the UI you have designed.

     

    During the preview, you can slide around your sliders, change your colorwheel, etc. and you'll see the results immediately just like having your effect installed.

     

    HOWEVER,  once you click OK on your effect, it reverts back to how it is in the code editor.

     

    Good , that it reverts back to how it is in the code editor once preview is closed. It would be very annoying if set values changes in editor to anything arbitrary after running previews. 

     

    But one can find it useful if there is an seperate option in file menu (or whichever menu indentation option is)  to use functional UI to set or change value  variable in Editor.

  10. 20 minutes ago, BoltBait said:

    ▪ The script can now be run with a fully functional UI, while still in CodeLab. Building a DLL file is not necessary to see how your final effect will look.

     

    Hey Bolt, does that mean we can change sliders (of UI) to change values in editor dynamically while working in codelab?

     

    EDIT: Once I reach home I will test that.

×
×
  • Create New...