Jump to content

Frostyfrog

Newbies
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Frostyfrog

  1. So, anyways, I'm trying to make a gradient from 0% alpha to 100% alpha and allow my self to choose the size of the gradient and the distance from the edge of the photo/selection. In it's current state, I can get it to go from 195 alpha to 255, which isn't what I want :(.

    Thank you for all your help! :D

    #region UICode
    int Amount1=60;	//[0,255]Length
    int Amount2=50;	//[0,255]Distance from Edge
    #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 temp = 0;
       long LeftX = (long)(selection.Left + Amount1);
       long LeftMath, RightMath;
       long RightX = (long)(((selection.Right - selection.Left))+selection.Left - Amount1);
       //long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top);
       ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
    
       ColorBgra CurrentPixel;
       for(int y = rect.Top; y < rect.Bottom; y++)
       {
           for (int x = rect.Left; x < rect.Right; x++)
           {
               CurrentPixel = src[x,y];
               // TODO: Add pixel processing code here
               if ((x <= LeftX))
               {
                   temp = x;
                   LeftMath = temp / LeftX;
               // Access RGBA values this way, for example:
                   CurrentPixel.R = (byte)CurrentPixel.R;
                   CurrentPixel.G = (byte)CurrentPixel.G;
                   CurrentPixel.B = (byte)CurrentPixel.B;
                   //temp = temp-LeftX-LeftMath;
                   //temp=x;
                   temp=LeftX-temp-LeftMath;
                   if(temp>255)temp=255;else if(temp<0)temp=100;
                   CurrentPixel.A = (byte)(-temp);
               }
               else if ((x >= RightX))
               {
                   RightMath = x / RightX;
               // Access RGBA values this way, for example:
                   CurrentPixel.R = (byte)CurrentPixel.R;
                   CurrentPixel.G = (byte)CurrentPixel.G;
                   CurrentPixel.B = (byte)CurrentPixel.B;
                   temp = x-RightX+RightMath;
                   CurrentPixel.A = (byte)(temp*255);
               }
               dst[x,y] = CurrentPixel;
           }
       }
    }
    

×
×
  • Create New...