public static void RenderGradient(Endogine.Interpolation.InterpolatorColor interpol, Endogine.BitmapHelpers.Canvas canvas) { canvas.Locked = true; for (int x = 0; x < canvas.Width; x++) { Color clr = interpol.GetValueAtTime((double)x / canvas.Width); canvas.SetPixel(x, 0, clr); } canvas.Locked = false; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Drawing.Drawing2D.ColorBlend colorBlend1 = new System.Drawing.Drawing2D.ColorBlend(); Endogine.Interpolation.InterpolatorColor interpolatorColor1 = new Endogine.Interpolation.InterpolatorColor(); System.Drawing.Drawing2D.ColorBlend colorBlend2 = new System.Drawing.Drawing2D.ColorBlend(); this.colorGradient1 = new Endogine.Editors.ColorEditors.ColorGradient(); this.SuspendLayout(); // // colorGradient1 // colorBlend1.Colors = new System.Drawing.Color[] { System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))), System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))), System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))) }; colorBlend1.Positions = new float[] { 0F, 0.5F, 1F }; this.colorGradient1.ColorBlend = colorBlend1; colorBlend2.Colors = new System.Drawing.Color[] { System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))), System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))), System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))) }; colorBlend2.Positions = new float[] { 0F, 0.5F, 1F }; interpolatorColor1.ColorBlend = colorBlend2; this.colorGradient1.InterpolatorColor = interpolatorColor1; this.colorGradient1.Location = new System.Drawing.Point(0, 0); this.colorGradient1.Margin = new System.Windows.Forms.Padding(2); this.colorGradient1.Name = "colorGradient1"; this.colorGradient1.Size = new System.Drawing.Size(261, 68); this.colorGradient1.TabIndex = 0; this.colorGradient1.UseSeparateAlpha = true; // // ColorGradientForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(280, 78); this.Controls.Add(this.colorGradient1); this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.Name = "ColorGradientForm"; this.Text = "ColorGradientForm"; this.Resize += new System.EventHandler(this.ColorGradientForm_Resize); this.Load += new System.EventHandler(this.ColorGradientForm_Load); this.ResumeLayout(false); }
public static void RenderGradientOnPattern(Endogine.Interpolation.InterpolatorColor interpol, Endogine.BitmapHelpers.Canvas canvas) { Graphics g = canvas.GetGraphics(); BackgroundPattern.Fill(g); Bitmap bmp = new Bitmap(255, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Endogine.BitmapHelpers.Canvas c2 = Endogine.BitmapHelpers.Canvas.Create(bmp); RenderGradient(interpol, c2); g.InterpolationMode = InterpolationMode.NearestNeighbor; g.DrawImage(bmp, new Rectangle(0, 0, canvas.Width, canvas.Height * 2)); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Drawing.Drawing2D.ColorBlend colorBlend1 = new System.Drawing.Drawing2D.ColorBlend(); Endogine.Interpolation.InterpolatorColor interpolatorColor1 = new Endogine.Interpolation.InterpolatorColor(); System.Drawing.Drawing2D.ColorBlend colorBlend2 = new System.Drawing.Drawing2D.ColorBlend(); this.colorGradient1 = new Endogine.Editors.ColorEditors.ColorGradient(); this.SuspendLayout(); // // colorGradient1 // colorBlend1.Colors = new System.Drawing.Color[] { System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))), System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))), System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))))}; colorBlend1.Positions = new float[] { 0F, 0.5F, 1F}; this.colorGradient1.ColorBlend = colorBlend1; colorBlend2.Colors = new System.Drawing.Color[] { System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))), System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))), System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))))}; colorBlend2.Positions = new float[] { 0F, 0.5F, 1F}; interpolatorColor1.ColorBlend = colorBlend2; this.colorGradient1.InterpolatorColor = interpolatorColor1; this.colorGradient1.Location = new System.Drawing.Point(0, 0); this.colorGradient1.Margin = new System.Windows.Forms.Padding(2); this.colorGradient1.Name = "colorGradient1"; this.colorGradient1.Size = new System.Drawing.Size(261, 68); this.colorGradient1.TabIndex = 0; this.colorGradient1.UseSeparateAlpha = true; // // ColorGradientForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(280, 78); this.Controls.Add(this.colorGradient1); this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.Name = "ColorGradientForm"; this.Text = "ColorGradientForm"; this.Resize += new System.EventHandler(this.ColorGradientForm_Resize); this.Load += new System.EventHandler(this.ColorGradientForm_Load); this.ResumeLayout(false); }
private void ColorGradient_MouseDown(object sender, MouseEventArgs e) { float position = (float)(e.X - this.panel1.Left) / (this.panel1.Right - this.panel1.Left); if (position < 0 || position > 1) { return; } Endogine.Interpolation.InterpolatorColor interpol = GetInterpolator(); Color clr = interpol.GetValueAtTime(position); if (e.Y > this.panel1.Bottom) { this.CreateChip(new ColorRgb(clr), position); this.RenderGradient(); } else if (e.Y < this.panel1.Top) { } }
private Endogine.Interpolation.InterpolatorColor GetInterpolator() { Endogine.Interpolation.InterpolatorColor interpol = new Endogine.Interpolation.InterpolatorColor(); float pos = 0; foreach (ColorGradientChip chip in this._colorChips) { if (!chip.Visible) { continue; } if (chip.Position == pos) { pos += 0.001f; } else { pos = chip.Position; } interpol.Add(pos, chip.ColorObject.ColorRGBA); } return(interpol); }
private void RenderGradient() { Bitmap bmp = new Bitmap(255, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Endogine.BitmapHelpers.Canvas canvas = Endogine.BitmapHelpers.Canvas.Create(bmp); Endogine.Interpolation.InterpolatorColor interpol = GetInterpolator(); RenderGradient(interpol, canvas); if (this._bmpBg == null) { this._bmpBg = new Bitmap(this.panel1.Width, this.panel1.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); this.panel1.BackgroundImage = this._bmpBg; } Graphics g = Graphics.FromImage(this._bmpBg); BackgroundPattern.Fill(g); g.InterpolationMode = InterpolationMode.NearestNeighbor; g.DrawImage(bmp, new Rectangle(0, 0, this._bmpBg.Width, this._bmpBg.Height * 2)); //ColorBlend blend = this.ColorBlend; //GraphicsPath path = new GraphicsPath(); ////path.AddRectangle(new RectangleF(0, 0, bmp.Width, bmp.Height)); //path.AddLine(0, 0, bmp.Width, 0); //PathGradientBrush pthGrBrush = new PathGradientBrush(path); //pthGrBrush.InterpolationColors = blend; //g.FillRectangle(pthGrBrush, 0, 0, bmp.Width, bmp.Height); this.panel1.Invalidate(); if (this.GradientChanged != null) { GradientChanged(this, null); } }
private Endogine.Interpolation.InterpolatorColor GetInterpolator() { Endogine.Interpolation.InterpolatorColor interpol = new Endogine.Interpolation.InterpolatorColor(); float pos = 0; foreach (ColorGradientChip chip in this._colorChips) { if (!chip.Visible) continue; if (chip.Position == pos) pos += 0.001f; else pos = chip.Position; interpol.Add(pos, chip.ColorObject.ColorRGBA); } return interpol; }
public void SetColors(System.Collections.SortedList a_aColorsToInterpolate) { Endogine.Interpolation.InterpolatorColor clrIp= new Endogine.Interpolation.InterpolatorColor(a_aColorsToInterpolate); m_aColorTable = clrIp.GenerateList(0,1, 256); }
public void SetColors(System.Collections.SortedList a_aColorsToInterpolate) { Endogine.Interpolation.InterpolatorColor clrIp = new Endogine.Interpolation.InterpolatorColor(a_aColorsToInterpolate); m_aColorTable = clrIp.GenerateList(0, 1, 256); }