Dalssoft.DiagramNet.RectangleElement.GetBrush C# (CSharp) Method

GetBrush() protected method

protected GetBrush ( Rectangle r ) : Brush
r System.Drawing.Rectangle
return System.Drawing.Brush
		protected virtual Brush GetBrush(Rectangle r)
		{
			//Fill rectangle
			Color fill1;
			Color fill2;
			Brush b;
			if (opacity == 100)
			{
				fill1 = fillColor1;
				fill2 = fillColor2;
			}
			else
			{
				fill1 = Color.FromArgb((int) (255.0f * (opacity / 100.0f)), fillColor1);
				fill2 = Color.FromArgb((int) (255.0f * (opacity / 100.0f)), fillColor2);
			}
			
			if (fillColor2 == Color.Empty)
				b = new SolidBrush(fill1);
			else
			{
				Rectangle rb = new Rectangle(r.X, r.Y, r.Width + 1, r.Height + 1);
				b = new LinearGradientBrush(
					rb,
					fill1, 
					fill2, 
					LinearGradientMode.Horizontal);
			}

			return b;
		}