Jump to content

Pratyush

Members
  • Posts

    249
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Pratyush

  1. There was a plugin named something like PathTool / Drawing. It could make spirals, splines and other complex lines. I cannot find it in Plugin index. I also don't remember exact name. 

     

    I didn't noticed that PDN now has more than 1000 plugins.

  2. Use this plugin.

     

     

    Import all images as layer. and 'save as' sprite with option as 1 column. Then reopen through recent files. This will save files as vertical sprites.

     

    If you want to do that horizontally

     

    1. import all images in through layers menu.

    2. rotate 90 degree through edit menu.

    3. save as sprite-sheet with option column 1.

    4. go to file menu, and open the new file from recent files.

    5. rotate 90 in opposite direction from edit menu.

    6. save

  3. paint.net for Mac is not going to happen.

     

    Quoted from FAQ:

     

    (1) Will it ever be ported to Mac OS, Linux, or any other operating system?

    (2) What about Mono support? Wouldn't that be really easy?

    We will not be doing any work to directly support Mac OS, Linux, Mono, or any other platform. We are doing this in order to focus on the best quality and support for the platform that we develop on: Windows with .NET. Also, we simply do not have the resources or expertise to do any of this work.

  4. Hi Everyone,

     

    Being a beginner I know next to nothing about programming and I am trying to achieve something.

     

    Here, I wanted to make amendment in UI for Kill color Keeper like this. This was to include dropdown from Jotaf's original plugin.

     

    94pqGO3.png

    Previous UI was.

    Ke1os7u.png

     

    In UI region I Added,

    #region UICode
    DoubleSliderControl Amount1 = 1; // [0,20] Color tolerance:
    ColorWheelControl Amount2 = ColorBgra.FromBgr(0,0,0); // [PrimaryColor] {!Amount3} Select Color
    CheckboxControl Amount3 = false; // [0,1] Use specific Values to Select Colors
    ListBoxControl Amount4 = 0; // {Amount3} What Color?|What color?|Primary Color|Secondary Color|White|Gray|Black
    RadioButtonControl Amount5 = 0; // [1] Functions|Keep Color|Kill Color
    IntSliderControl Amount6 = 0; // [0,255] Consider transparent any alpha smaller than:
    IntSliderControl Amount7 = 255; // [0,255] {Amount5} Consider transparent any alpha greater than:
    #endregion

    And for assigning input color value I updated this line

    ColorBgra color = Amount2;

    into this block of codes.

    ColorBgra color;
        if(Amount3)
            color = Amount2;
        else
          //selecting things from dropdown
            switch(Amount4)
            {   
                case 0: // Primary color
              
                    color = (ColorBgra)EnvironmentParameters.PrimaryColor;
                    break;
                case 1: // Secondary color
                    color = (ColorBgra)EnvironmentParameters.SecondaryColor;
                    break;
                case 2: // White
                    color = ColorBgra.White;
                    break;
                case 3: // Gray
                    color = ColorBgra.Gray;
                    break;
                default: // Black
                    color = ColorBgra.Black;
                    break;
            }   

     

    So, In UI output is as expected, for the drop-down & Color-Wheel are enabled and disabled and working as expected. But somehow the selection of color is not working at all.

     

    i.e. The behavior is I am seeing.

    • When checkbox for "specific values" is checked, Dropdown is enabled as expected, I can choose color from dropdown but Output for the selected Color from dropdown doesn't reflect on Canvas.
    • When checkbox for "specific values" is uncheckedColorWheel is  enabled as expected, I can change value for color but Again output for the selected Color from ColorWheel doesn't reflect on Canvas.

     

    UI is eternally struck on Primary Color which is default value. If I comment the whole "if else and switch" block of new code,  and replace it with simply "ColorBgra color = Amount2;" every thing starts working again magically. How to make the it work?  I am at my wit's end and I can't understand what is happening here. :cry::cry::cry:.

     

    Here is the full code.:arrow-down:


    Code:

     

    Spoiler
    
    // Name:Kill Color Keeper
    // Submenu: Color
    // Author: Pratyush
    // Title: KillColorKeeper
    // Version: 1.2.0
    // Desc: Removes or Preserves a color while maintaining the alpha information
    // Keywords: Color|Transparency|Alpha|Retention|Background
    // URL:
    // Help:
    #region UICode
    DoubleSliderControl Amount1 = 1; // [0,20] Color tolerance:
    ColorWheelControl Amount2 = ColorBgra.FromBgr(0,0,0); // [PrimaryColor] {!Amount3} Select Color
    CheckboxControl Amount3 = false; // [0,1] Use specific Values to Select Colors
    ListBoxControl Amount4 = 0; // {Amount3} What Color?|What color?|Primary Color|Secondary Color|White|Gray|Black
    RadioButtonControl Amount5 = 0; // [1] Functions|Keep Color|Kill Color
    IntSliderControl Amount6 = 0; // [0,255] Consider transparent any alpha smaller than:
    IntSliderControl Amount7 = 255; // [0,255] {Amount5} Consider transparent any alpha greater than:
    #endregion
    
    //Kill Color Keeper by Pratyush
    //Based on Original Grim Color Reaper by Jotaf
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        ColorBgra color = Amount2;
        //ColorBgra color;
        //if(Amount3)
        //    color = Amount2;
        //else
        //  //selecting things from dropdown
        //    switch(Amount4)
        //    {   
        //        case 0: // Primary color
                
        //            color = (ColorBgra)EnvironmentParameters.PrimaryColor;
        //            break;
        //        case 1: // Secondary color
        //            color = (ColorBgra)EnvironmentParameters.SecondaryColor;
        //            break;
        //        case 2: // White
        //            color = ColorBgra.White;
        //            break;
        //        case 3: // Gray
        //            color = ColorBgra.Gray;
        //            break;
        //        default: // Black
        //            color = ColorBgra.Black;
        //            break;
        //    }   
    
    
        //color as double
        double R = color.R, G = color.G, B = color.B;
    
        ColorBgra pixel;
        double rdif, gdif, bdif;
        double alpha;
    
        for (int y = rect.Top; y < rect.Bottom; y++)
        {
            for (int x = rect.Left; x < rect.Right; x++)
            {
                pixel = src[x,y];
    
                //difference between this pixel's color and the color to erase
                rdif = pixel.R - R;
                gdif = pixel.G - G;
                bdif = pixel.B - B;
    
                //simple way of figuring out the alpha: the more distant the colors,
                //the larger the alpha.
                alpha = Amount1 * Math.Sqrt(rdif*rdif + gdif*gdif + bdif*bdif);
    
                if (Amount5 == 1)
                {
                    if (alpha <= Amount6)  //alpha cut-off (fully transparent)
                        pixel.A = 0;
    
                    else if (alpha < pixel.A)    //only apply change if it causes a pixel to become more
                    {                            //transparent (to blend nicely with existing alphas)
                        pixel.A = (byte) alpha;
    
                        alpha = alpha / 255;  //normalize alpha to range 0..1
    
                        //we assume that each pixel is the result of linear interpolation between an
                        //unknown foreground color, and the user selected background color, which
                        //means it obeys the equation: (for each of Red, Green and Blue)
                        //  final = foreground*alpha + background*(1-alpha)
                        //we already figured out the alpha, so we just need to invert the equation
                        //to obtain the original foreground color:
                        //  foreground = (final - background*(1-alpha)) / alpha
                        pixel.R = Int32Util.ClampToByte((int) (((double) pixel.R - R*(1-alpha)) / alpha));
                        pixel.G = Int32Util.ClampToByte((int) (((double) pixel.G - G*(1-alpha)) / alpha));
                        pixel.B = Int32Util.ClampToByte((int) (((double) pixel.B - B*(1-alpha)) / alpha));
                    }
                }
                else
                {
    
                  	if (Amount6 >= pixel.A)  //Ignore transparent pixels
                        pixel.A = 0;
    
                    else if (alpha >= Amount7)  //alpha cut-off (fully opaque)
                        pixel.A = 0;
    
                    else if (alpha > pixel.A)    //only apply change if it causes a pixel to become more
                    {
                        //transparent (to blend nicely with existing alphas)
                        pixel.A = (byte) alpha;
    
                        alpha = alpha / 255;  //normalize alpha to range 0..1
    
                        pixel.R = Int32Util.ClampToByte((int) (((double) pixel.R - R*(1-alpha)) / alpha));
                        pixel.G = Int32Util.ClampToByte((int) (((double) pixel.G - G*(1-alpha)) / alpha));
                        pixel.B = Int32Util.ClampToByte((int) (((double) pixel.B - B*(1-alpha)) / alpha));
                    }
                }
                dst[x,y] = pixel;
            }
        }
    }

     

    Thanks and Regards.

  5. Thanks @Ego Eram Reputo for all of the work. 

    Just two suggestion. :) :) 

    1) Tinker the description a bit, :)Gradual stripes can draw stripes in any direction and nubs cab be set anywhere.

    2) In Jotaf's Grim Color Reaper's discussion please mention about updated version, so that people visiting that place know that an updated version exists.

     

    Thank you so much. :beer::mrblue:

  6. 2 hours ago, Ego Eram Reputo said:

    In the documentation, I referred to these keyboard combinations like this;

     

    Tool Shortcuts

    Rectangle Select

    S

    Lasso Select

    S x 2

    Ellipse Select

    S x 3

    Magic Wand Tool

    S x 4

    Shapes

    O x 2

    Move Selected Pixels

    M

    Move Selection

    M x 2

    (of course it's laid out much better than that!)

     

    If I correctly remember.....

    Once you have selected Shapes tool by O X 2, it's 'A'. 'A' is chord to select Shapes.

    i.e.

     

    Rectangle Shape

    A

    Rounded Rectangle

    A x 2

    Ellipse Shape

    A x 3

    Rhombus

    A x 4

    Trapezoid

    A x 5

    And so on...  
×
×
  • Create New...