private void Hairy_OnUpdateCanvas() { Random rnd = new Random(); Endogine.ColorEx.ColorHsb hsb = new Endogine.ColorEx.ColorHsb(rnd.Next(360), 1 ,1); Color clr = hsb.ColorRGBA; for (int i=0; i<100000; i++) this._canvas.SetPixel(rnd.Next(this._canvas.Width), rnd.Next(this._canvas.Height), clr); }
private void Hairy_OnUpdateCanvas() { Random rnd = new Random(); Endogine.ColorEx.ColorHsb hsb = new Endogine.ColorEx.ColorHsb(rnd.Next(360), 1, 1); Color clr = hsb.ColorRGBA; for (int i = 0; i < 100000; i++) { this._canvas.SetPixel(rnd.Next(this._canvas.Width), rnd.Next(this._canvas.Height), clr); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { Endogine.ColorEx.ColorHsb colorHsb1 = new Endogine.ColorEx.ColorHsb(); Endogine.Vector4 vector41 = new Endogine.Vector4(); Endogine.Vector4 vector42 = new Endogine.Vector4(); this.comboColorSpace = new System.Windows.Forms.ComboBox(); this.comboSliderAxis = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); this.colorPickerMulti1 = new Endogine.Editors.ColorEditors.ColorPickerMulti(); this.SuspendLayout(); // // comboColorSpace // this.comboColorSpace.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboColorSpace.FormattingEnabled = true; this.comboColorSpace.Location = new System.Drawing.Point(90, 0); this.comboColorSpace.Name = "comboColorSpace"; this.comboColorSpace.Size = new System.Drawing.Size(85, 24); this.comboColorSpace.TabIndex = 1; this.comboColorSpace.SelectedIndexChanged += new System.EventHandler(this.comboColorSpace_SelectedIndexChanged); // // comboSliderAxis // this.comboSliderAxis.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboSliderAxis.FormattingEnabled = true; this.comboSliderAxis.Location = new System.Drawing.Point(263, 0); this.comboSliderAxis.Name = "comboSliderAxis"; this.comboSliderAxis.Size = new System.Drawing.Size(45, 24); this.comboSliderAxis.TabIndex = 2; this.comboSliderAxis.SelectedIndexChanged += new System.EventHandler(this.comboSliderAxis_SelectedIndexChanged); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(4, 2); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(87, 17); this.label1.TabIndex = 3; this.label1.Text = "Color space:"; // // colorPickerMulti1 // colorHsb1.A = 255; colorHsb1.B = 0F; colorHsb1.ColorRGBA = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); colorHsb1.H = 0F; colorHsb1.S = 0F; colorHsb1.Vector = vector41; colorHsb1.VectorRGBA = vector42; this.colorPickerMulti1.ColorObject = colorHsb1; this.colorPickerMulti1.Location = new System.Drawing.Point(0, 30); this.colorPickerMulti1.Name = "colorPickerMulti1"; this.colorPickerMulti1.Size = new System.Drawing.Size(321, 258); this.colorPickerMulti1.SliderRepresentsAxis = 1; this.colorPickerMulti1.TabIndex = 0; this.colorPickerMulti1.ColorChanged += new System.EventHandler(this.colorPickerMulti1_ColorChanged); // // ColorPickerMultiEx // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.comboColorSpace); this.Controls.Add(this.label1); this.Controls.Add(this.comboSliderAxis); this.Controls.Add(this.colorPickerMulti1); this.Name = "ColorPickerMultiEx"; this.Size = new System.Drawing.Size(315, 288); this.ResumeLayout(false); this.PerformLayout(); }
public override Endogine.ColorEx.Palette Load(string filename) { Serialization.BinaryReverseReader reader = new BinaryReverseReader(new System.IO.FileStream(filename, System.IO.FileMode.Open)); //Serialization.BinaryReaderEx reader = new BinaryReaderEx(new System.IO.FileStream(filename, System.IO.FileMode.Open)); ushort version = reader.ReadUInt16(); ushort numColors = reader.ReadUInt16(); if (version > 2) { throw new Exception("Can't parse .ACO palettes with version > 2: " + filename); } Endogine.ColorEx.Palette palette = new Endogine.ColorEx.Palette(); for (int colorNum = 0; colorNum < numColors; colorNum++) { ushort colorSpaceId = reader.ReadUInt16(); ushort[] vals = new ushort[4]; for (int i = 0; i < 4; i++) { vals[i] = reader.ReadUInt16(); } string name = colorNum.ToString(); if (version == 2) { reader.ReadUInt16(); //padded int nameLength = reader.ReadUInt16(); if (reader.BaseStream.Position % 2 == 1) // ? { reader.ReadUInt16(); //padded } for (int letterNum = 0; letterNum < nameLength; letterNum++) { char c = (char)reader.ReadUInt16(); name += c.ToString(); } } ColorEx.ColorBase color; //TODO; uses 16 bits per channel, but here I truncate it to 8 bits switch (colorSpaceId) { case 0: //RGB ColorEx.ColorRgb rgb = new Endogine.ColorEx.ColorRgb(); rgb.R = vals[0] / 256; rgb.G = vals[1] / 256; rgb.B = vals[2] / 256; color = rgb; break; case 1: //HSB ColorEx.ColorHsb hsb = new Endogine.ColorEx.ColorHsb(); hsb.H = (float)vals[0] / 182.04f; hsb.S = (float)vals[1] / 655.35f / 100f; hsb.B = (float)vals[2] / 655.35f / 100f; color = hsb; break; case 2: //CMYK ColorEx.ColorCmyk cmyk = new Endogine.ColorEx.ColorCmyk(); cmyk.C = (float)vals[0] / 256; cmyk.M = (float)vals[1] / 256; cmyk.Y = (float)vals[2] / 256; cmyk.K = (float)vals[3] / 256; color = cmyk; break; case 7: //Lab float[] ab = new float[2]; for (int i = 1; i < 3; i++) { if (vals[i] <= 12000) { ab[i - 1] = (float)vals[i] / 100; } else { ab[i - 1] = (float)(65536 - vals[i]) / 100; } } ColorEx.ColorLab lab = new Endogine.ColorEx.ColorLab(); lab.L = (float)vals[0] / 100; lab.a = vals[1]; lab.b = vals[2]; //Angle:2, Observer:D65 color = lab; break; case 8: //Grayscale ColorEx.ColorRgb rgbGray = new Endogine.ColorEx.ColorRgb(); int gray = (int)((float)vals[0] / 39.0625f); rgbGray.R = gray; rgbGray.G = gray; rgbGray.B = gray; color = rgbGray; break; case 9: //Wide CMYK default: throw new Exception("Can't read colorspace " + colorSpaceId + " in " + filename); } palette.Add(name, color); } return(palette); }
public override Endogine.ColorEx.Palette Load(string filename) { Serialization.BinaryReverseReader reader = new BinaryReverseReader(new System.IO.FileStream(filename, System.IO.FileMode.Open)); //Serialization.BinaryReaderEx reader = new BinaryReaderEx(new System.IO.FileStream(filename, System.IO.FileMode.Open)); ushort version = reader.ReadUInt16(); ushort numColors = reader.ReadUInt16(); if (version > 2) { throw new Exception("Can't parse .ACO palettes with version > 2: "+filename); } Endogine.ColorEx.Palette palette = new Endogine.ColorEx.Palette(); for (int colorNum = 0; colorNum < numColors; colorNum++) { ushort colorSpaceId = reader.ReadUInt16(); ushort[] vals = new ushort[4]; for (int i = 0; i < 4; i++) vals[i] = reader.ReadUInt16(); string name = colorNum.ToString(); if (version == 2) { reader.ReadUInt16(); //padded int nameLength = reader.ReadUInt16(); if (reader.BaseStream.Position % 2 == 1) // ? reader.ReadUInt16(); //padded for (int letterNum = 0; letterNum < nameLength; letterNum++) { char c = (char)reader.ReadUInt16(); name+=c.ToString(); } } ColorEx.ColorBase color; //TODO; uses 16 bits per channel, but here I truncate it to 8 bits switch (colorSpaceId) { case 0: //RGB ColorEx.ColorRgb rgb = new Endogine.ColorEx.ColorRgb(); rgb.R = vals[0] / 256; rgb.G = vals[1] / 256; rgb.B = vals[2] / 256; color = rgb; break; case 1: //HSB ColorEx.ColorHsb hsb = new Endogine.ColorEx.ColorHsb(); hsb.H = (float)vals[0] / 182.04f; hsb.S = (float)vals[1] / 655.35f / 100f; hsb.B = (float)vals[2] / 655.35f / 100f; color = hsb; break; case 2: //CMYK ColorEx.ColorCmyk cmyk = new Endogine.ColorEx.ColorCmyk(); cmyk.C = (float)vals[0] / 256; cmyk.M = (float)vals[1] / 256; cmyk.Y = (float)vals[2] / 256; cmyk.K = (float)vals[3] / 256; color = cmyk; break; case 7: //Lab float[] ab = new float[2]; for (int i = 1; i < 3; i++) { if (vals[i] <= 12000) ab[i - 1] = (float)vals[i] / 100; else ab[i - 1] = (float)(65536 - vals[i]) / 100; } ColorEx.ColorLab lab = new Endogine.ColorEx.ColorLab(); lab.L = (float)vals[0]/100; lab.a = vals[1]; lab.b = vals[2]; //Angle:2, Observer:D65 color = lab; break; case 8: //Grayscale ColorEx.ColorRgb rgbGray = new Endogine.ColorEx.ColorRgb(); int gray = (int)((float)vals[0] / 39.0625f); rgbGray.R = gray; rgbGray.G = gray; rgbGray.B = gray; color = rgbGray; break; case 9: //Wide CMYK default: throw new Exception("Can't read colorspace "+colorSpaceId+" in "+filename); } palette.Add(name, color); } return palette; }
public override void UpdateCanvas() { Endogine.ColorEx.ColorHsb clr = new Endogine.ColorEx.ColorHsb(CurrentColor); clr.H+=1f; if (clr.H > 360) clr.H-=360; CurrentColor = clr.ColorRGBA; this.Clear(Color.Black); int axvel = this.MouseLoc.X-this.MouseLastLoc.X; int ayvel = this.MouseLoc.Y-this.MouseLastLoc.Y; mouseXvel = (axvel != mouseXvel) ? axvel : 0; mouseYvel = (ayvel != mouseYvel) ? ayvel : 0; if(RandomGust.Alive) RandomGust.Update(); else { if(RandomEx.Random(0,10)==0) { RandomGust.SetLife(RandomEx.Random(1,20)); RandomGust.Loc = new EPointF(RandomEx.Random(0f,(float)this.Width), RandomEx.Random(0f,this.Height-10)); //TODO above emitter, not fixed value! float fact = 0.3f*this.Width/200; EPointF vel = new EPointF(RandomEx.Random(0f,8f)*fact, RandomEx.Random(-2f,1f)*fact); if(RandomGust.Loc.X > this.Width/2) vel.X*=-1; RandomGust.Vel = vel; RandomGust.Size = RandomEx.Random(0f,50f)*this.Width/200; } //randomGust--; } for(int i = 0; i < lwidth; i++) { for(int u = 0; u < lheight; u++) { vbuf[i][u].updatebuf(i,u); v[i][u].Refresh(); } } for(int i = 0; i < pnum-1; i++) { p[i].updatepos(); } for(int i = 0; i < lwidth; i++) { for(int u = 0; u < lheight; u++) { v[i][u].addbuffer(i, u); v[i][u].updatevels(mouseXvel, mouseYvel); v[i][u].display(i, u); } } //randomGust = 0; }
public override void UpdateCanvas() { Endogine.ColorEx.ColorHsb clr = new Endogine.ColorEx.ColorHsb(CurrentColor); clr.H += 1f; if (clr.H > 360) { clr.H -= 360; } CurrentColor = clr.ColorRGBA; this.Clear(Color.Black); int axvel = this.MouseLoc.X - this.MouseLastLoc.X; int ayvel = this.MouseLoc.Y - this.MouseLastLoc.Y; mouseXvel = (axvel != mouseXvel) ? axvel : 0; mouseYvel = (ayvel != mouseYvel) ? ayvel : 0; if (RandomGust.Alive) { RandomGust.Update(); } else { if (RandomEx.Random(0, 10) == 0) { RandomGust.SetLife(RandomEx.Random(1, 20)); RandomGust.Loc = new EPointF(RandomEx.Random(0f, (float)this.Width), RandomEx.Random(0f, this.Height - 10)); //TODO above emitter, not fixed value! float fact = 0.3f * this.Width / 200; EPointF vel = new EPointF(RandomEx.Random(0f, 8f) * fact, RandomEx.Random(-2f, 1f) * fact); if (RandomGust.Loc.X > this.Width / 2) { vel.X *= -1; } RandomGust.Vel = vel; RandomGust.Size = RandomEx.Random(0f, 50f) * this.Width / 200; } //randomGust--; } for (int i = 0; i < lwidth; i++) { for (int u = 0; u < lheight; u++) { vbuf[i][u].updatebuf(i, u); v[i][u].Refresh(); } } for (int i = 0; i < pnum - 1; i++) { p[i].updatepos(); } for (int i = 0; i < lwidth; i++) { for (int u = 0; u < lheight; u++) { v[i][u].addbuffer(i, u); v[i][u].updatevels(mouseXvel, mouseYvel); v[i][u].display(i, u); } } //randomGust = 0; }