public static void TestToSVGString() { float[] testData = new float[] { -1.0f, 0.0f, 1.0f, 0.5f, -0.5f, 2.0f }; for (int t = 0; t < testData.Count(); t++) { int ir = t; int ig = (t * 2) % testData.Count(); int ib = (t * 3) % testData.Count(); float r = testData[ir]; float g = testData[ig]; float b = testData[ib]; Colour c = new Colour(r, g, b); Console.WriteLine("Testing colour with R:{0:0.0}, G:{1:0.0}, B:{2:0.0}", r, g, b); Console.WriteLine("Result: {0}", c.ToSVGString()); } }
private void DefineColourPrimes() { this.colour = new Colour(); this.colour.SetHSV(this.hue, 1.0f, 0.5f); this.colourLeft = new Colour(); this.colourLeft.SetHSV(this.hueLeft, 1.0f, 0.5f); this.colourRight = new Colour(); this.colourRight.SetHSV(this.hueRight, 1.0f, 0.5f); }
public Colour GetColour() { Colour newCol; float choice = this.genes.Next() * 3000.0f; //choose which colour to make a variant from if (choice < 1000) { newCol = new Colour(); newCol.SetHSV(this.colour.H, this.colour.S, this.colour.V); } else if (choice > 2000) { newCol = new Colour(); newCol.SetHSV(this.colourLeft.H, this.colourLeft.S, this.colourLeft.V); } else { newCol = new Colour(); newCol.SetHSV(this.colourRight.H, this.colourRight.S, this.colourRight.V); } float newHue = newCol.H + (this.genes.Next() * this.variation.hue) - (this.variation.hue / 2.0f); float newSat = newCol.S + (this.genes.Next() * this.variation.saturation) - (this.variation.saturation / 2.0f); float newVal = newCol.V + (this.genes.Next() * this.variation.value) - (this.variation.value / 2.0f); //constrain sat and val to range(0-1) newSat = (float)Math.Abs(newSat - Math.Floor(newSat)); newVal = (float)Math.Abs(newSat - Math.Floor(newSat)); newCol.SetHSV(newHue, newSat, newVal); return newCol; }