public void LoadPalettes_Retrievable() { var collection = new PaletteCollection(); var palettes = new PaletteInfo[] { new PaletteInfo() { Name = "MegaMan", ImagePath = FilePath.FromRelative("a", @"C:\") }, new PaletteInfo() { Name = "Enemy", ImagePath = FilePath.FromRelative("b", @"C:\") }, new PaletteInfo() { Name = "Menu", ImagePath = FilePath.FromRelative("c", @"C:\") }, new PaletteInfo() { Name = "Scene", ImagePath = FilePath.FromRelative("d", @"C:\") } }; collection.LoadPalettes(palettes); Assert.AreEqual(4, collection.Count); Assert.AreEqual("b", collection["Enemy"].ImagePath.Relative); }
public TProcessInfo(string name, bool isAlive, TPaletteInfo paletteInfo) : this() { Name = name; IsAlive = isAlive; PaletteInfo.CopyFrom(paletteInfo); }
void ShowTints() { //build extrusions for shades and tines - visualistion of template int scaleForCylindersX = 10; int scaleForCylindersY = 1; if (showTints) { PaletteInfo pI = GetComponent <PaletteInfo>(); for (int a = 0; a < pI.palette.Count; a++) { //change this to mini stacks rotate around centre, plinth for main colour Vector3 arm = Quaternion.Euler(0, a * (360f / pI.palette.Count), 0) * Vector3.right * scaleForCylindersX * 1.33f; //for each tint in main colour's pallete //do shades first for (int i = 0; i < pI.palette[a].shades.Count; i++) { int f = i + 1; GameObject cylinder = GameObject.CreatePrimitive(PrimitiveType.Cylinder); cylinder.transform.position = transform.position + arm + (Vector3.up * i * scaleForCylindersY * 2) + (Vector3.up * (depth + scaleForCylindersY)); cylinder.transform.localScale = new Vector3(scaleForCylindersX, scaleForCylindersY, scaleForCylindersX); //show shades cylinder.GetComponent <MeshRenderer>().sharedMaterial = pI.palette[a].shades[pI.palette[a].shades.Count - i - 1]; cylinder.name = "Shade " + i.ToString(); cylinder.transform.parent = extrudedCell.transform; } //place main colour in middle GameObject cylinderM = GameObject.CreatePrimitive(PrimitiveType.Cylinder); cylinderM.transform.position = transform.position + arm + (Vector3.up * pI.palette[a].shades.Count * scaleForCylindersY * 2) + (Vector3.up * (depth + scaleForCylindersY)); cylinderM.transform.localScale = new Vector3(scaleForCylindersX, scaleForCylindersY, scaleForCylindersX); cylinderM.GetComponent <MeshRenderer>().sharedMaterial = pI.palette[a].material; cylinderM.name = "Shade Main"; cylinderM.transform.parent = extrudedCell.transform; for (int i = 0; i < pI.palette[a].tints.Count; i++) { GameObject cylinder = GameObject.CreatePrimitive(PrimitiveType.Cylinder); cylinder.transform.position = transform.position + arm + (Vector3.up * (i + pI.palette[a].shades.Count + 1) * scaleForCylindersY * 2) + (Vector3.up * (depth + scaleForCylindersY)); cylinder.transform.localScale = new Vector3(scaleForCylindersX, scaleForCylindersY, scaleForCylindersX); //show tints cylinder.GetComponent <MeshRenderer>().sharedMaterial = pI.palette[a].tints[pI.palette[a].tints.Count - i - 1]; cylinder.name = "Shade " + i.ToString(); cylinder.transform.parent = extrudedCell.transform; } } } }
public void CopyFrom(TProcessInfo alias) { if (alias.NotNull()) { Name = alias.Name; IsAlive = alias.IsAlive; IsChecked = alias.IsChecked; PaletteInfo.CopyFrom(alias.PaletteInfo); } }
public void Load(Project project, XElement node) { var palette = new PaletteInfo(); var imagePathRelative = node.RequireAttribute("image").Value; palette.ImagePath = FilePath.FromRelative(imagePathRelative, project.BaseDir); palette.Name = node.RequireAttribute("name").Value; project.AddPalette(palette); }
private PaletteInfo PaletteFromXml(XElement node, string baseDir) { var palette = new PaletteInfo(); var imagePathRelative = node.RequireAttribute("image").Value; palette.ImagePath = FilePath.FromRelative(imagePathRelative, baseDir); palette.Name = node.RequireAttribute("name").Value; return(palette); }
public void LoadPalettes_Duplicate_Exception() { var collection = new PaletteCollection(); var palettes = new PaletteInfo[] { new PaletteInfo() { Name = "MegaMan", ImagePath = FilePath.FromRelative("a", @"C:\") }, new PaletteInfo() { Name = "MegaMan", ImagePath = FilePath.FromRelative("b", @"C:\") } }; collection.LoadPalettes(palettes); }
private void CmbPalettes_SelectedIndexChanged(object sender, EventArgs e) { if (CmbPalettes.SelectedItem == null) { PslCurrent.CurrentPalette = null; BtnRemove.Enabled = BtnRename.Enabled = false; } else { PaletteInfo pi = CmbPalettes.SelectedItem as PaletteInfo; pi.NameChanged -= CurrentPalette_NameChanged; PslCurrent.CurrentPalette = CmbPalettes.SelectedItem as PaletteInfo; PslCurrent.CurrentPalette.NameChanged += new EventHandler <TEventArgs <string> >(CurrentPalette_NameChanged); BtnRemove.Enabled = BtnRename.Enabled = CmbPalettes.SelectedIndex != 0; } LblTransparent.Visible = CmbPalettes.SelectedIndex == 0; }
public Palette(PaletteInfo info) { this._info = info; Initialize(); }
void SetPalletes() { //choose a starting main colour randomly float hue = 0f; bool strictColours = false;//** if (strictColours) { float hueChooser = 30 * UnityEngine.Random.Range(0, 12); hue = (1f / 360) * hueChooser; } else if (!strictColours) { //or use this to create non standard palettes - can movd away from main colours hue = 1f / 360 * (UnityEngine.Random.Range(0f, 360f)); } //randomly choose saturation - will aplly to all cells float satChooser = UnityEngine.Random.Range(.5f, .8f);//still playin with these//and whether top put inside loop or not -- keeping outside of loop, tints and shades are there to get different tones float saturation = satChooser; //changing value makes it look darker or light-almost liekthe lighting engine does. keeping static float value = 1f;// UnityEngine.Random.Range(.5f, 1f);// 0.5f; //steal the main material froma primitive GameObject tempCube = GameObject.CreatePrimitive(PrimitiveType.Cube); Material standardMaterial = tempCube.GetComponent <MeshRenderer>().material; standardMaterial.SetFloat("_Metallic", 0.5f); Destroy(tempCube); int tintsAndShades = UnityEngine.Random.Range(3, 7);//randomimse? //run through cells for (int i = 0; i < cells.Count; i++) { if (cells[i].GetComponent <PaletteInfo>() == null) { //we havent set any colours for this cell PaletteInfo pI = cells[i].AddComponent <PaletteInfo>(); //make a pallete for this cell //randomly choose hwat type of step is used to create the harmonies(degres on colour wheel) int harmonyStep = 30 * UnityEngine.Random.Range(1, 5); List <PaletteInfo.MaterialAndShades> palette = PaletteInfo.Palette(hue, saturation, value, harmonyStep, tintsAndShades, standardMaterial); pI.palette = palette; //now for each adjacent, create a pallete from one of the harmonious materials List <GameObject> adjacents = cells[i].GetComponent <AdjacentCells>().adjacentCells; for (int j = 0; j < adjacents.Count; j++) { //loads of palletts this cell? PaletteInfo adjacentPI = adjacents[j].AddComponent <PaletteInfo>(); //choose random harmony - or cluster colours by clamping to one - or cluster to adjacent colours in the pallet (0,1,2) //or always contrast - last half of pallete int randomHarmonyIndex = UnityEngine.Random.Range(0, palette.Count / 2);//1;// UnityEngine.Random.Range(1, palette.Count);//start at 1 because 0 is main colour//UnityEngine.Random.Range(palette.Count/2, palette.Count ) int randomTintIndex = UnityEngine.Random.Range(0, tintsAndShades); Color harmonyColour = palette[randomHarmonyIndex].material.color; //get hue from this Color.RGBToHSV(harmonyColour, out hue, out saturation, out value); //now make a palette harmonyStep = 30 * UnityEngine.Random.Range(1, 5); adjacentPI.palette = PaletteInfo.Palette(hue, saturation, value, harmonyStep, tintsAndShades, standardMaterial); } } } }