Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DMD4545-Tool_Project-Eric_Laputka/ToolProject/Assets/_Scripts/ColorChanger.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
141 lines (129 sloc)
4.94 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class ColorChanger : MonoBehaviour | |
{ | |
public GameObject ogCube, secondCube, thirdCube, fourthCube, fifthCube; | |
public Color ogColor, secondColor, thirdColor, fourthColor, fifthColor; | |
private Renderer ogR, sR, tR, foR, fiR; | |
public void Start() | |
{ | |
// Gets render components of cube | |
ogR = ogCube.GetComponent<Renderer>(); | |
sR = secondCube.GetComponent<Renderer>(); | |
tR = thirdCube.GetComponent<Renderer>(); | |
foR = fourthCube.GetComponent<Renderer>(); | |
fiR = fifthCube.GetComponent<Renderer>(); | |
} | |
void ColorSet() | |
{ | |
//changes the color of cubes | |
ogR.sharedMaterial.SetColor("_Color", ogColor); | |
sR.sharedMaterial.SetColor("_Color", secondColor); | |
tR.sharedMaterial.SetColor("_Color", thirdColor); | |
foR.sharedMaterial.SetColor("_Color", fourthColor); | |
fiR.sharedMaterial.SetColor("_Color", fifthColor); | |
} | |
public void Complementary() | |
{ | |
//makes the second and third color different shades of the first | |
secondColor = ogColor * 1.5f; | |
thirdColor = ogColor * .5f; | |
//makes the fourth color the complementary of the first | |
fourthColor = (Color.white - ogColor) * .5f; | |
//makes the fifth color a different shade of the fourth | |
fifthColor = fourthColor * 2; | |
//calls colorSet to change color | |
ColorSet(); | |
} | |
public void Monochromatic() | |
{ | |
//makes all the other colors different, monochromatic versions of the first | |
secondColor = ogColor * 1.5f; | |
thirdColor = ogColor * 2; | |
fourthColor = ogColor * .5f; | |
fifthColor = ogColor * .25f; | |
ColorSet(); | |
} | |
public void Analogous() | |
{ | |
float H, S, V; | |
Color.RGBToHSV(ogColor, out H, out S, out V); | |
//Get Hue of the color we pick and store it into H | |
float sH = H; | |
float foH = H; | |
float tH = H; | |
float fiH = H; | |
sH = (H + (1f / 12f)) % 1f; | |
foH = (H + (-1f / 12f)) % 1f; | |
tH = (H + (1f / 6f)) % 1f; | |
fiH = (H + (-1f / 6f)) % 1f; | |
//makes each hue value 1/6 the color wheel apart | |
// and put them in sH, foH, tH, fiH | |
secondColor = Color.HSVToRGB(sH, S, V); | |
fourthColor = Color.HSVToRGB(foH, S, V); | |
thirdColor = Color.HSVToRGB(tH, S, V); | |
fifthColor = Color.HSVToRGB(fiH, S, V); | |
//applies the new calculated color to each of the blocks color | |
ColorSet(); | |
} | |
public void Triad() | |
{ | |
float H, S, V; | |
Color.RGBToHSV(ogColor, out H, out S, out V); | |
//Get Hue of the color we pick and store it into H | |
float sH = H; | |
float foH = H; | |
sH = (H + (120f/360f)) % 1f; | |
foH = (H + (240f/360f)) % 1f; | |
//add the Hue by 1/3 the color wheel in both directions | |
//and then use the modulo function to get their triad locations | |
// and put them in sH and foH | |
secondColor = Color.HSVToRGB(sH, S, V); | |
fourthColor = Color.HSVToRGB(foH, S, V); | |
//change the second and fourth colors, and due to the calculations, they are in triad locations | |
// makes the third and fith colors monochromatic to the second and fourth colors | |
thirdColor = secondColor * .5f; | |
fifthColor = fourthColor * .5f; | |
ColorSet(); | |
} | |
public void Square() | |
{ | |
float H, S, V; | |
Color.RGBToHSV(ogColor, out H, out S, out V); | |
//Get Hue of the color we pick and store it into H | |
float sH = H; | |
float foH = H; | |
float fiH = H; | |
sH = (H + .25f) % 1; | |
foH = (H + .5f) % 1; | |
fiH = (H + .75f) % 1; | |
//puts the hue 1/4 apart in each direction to get their square locations | |
//and put them in sH, fiH, and foH | |
secondColor = Color.HSVToRGB(sH, S, V); | |
fourthColor = Color.HSVToRGB(foH, S, V); | |
fifthColor = Color.HSVToRGB(fiH, S, V); | |
//change the second, fifth and fourth colors, and due to the calculations, they are in square locations | |
thirdColor = ogColor * .5f; | |
ColorSet(); | |
} | |
public void SplitComp() | |
{ | |
float H, S, V; | |
Color.RGBToHSV(ogColor, out H, out S, out V); | |
//Get Hue of the color we pick and store it into H | |
float sH = H; | |
float foH = H; | |
sH = (H + (150f / 360f)) % 1f; | |
foH = (H + (210f /360f)) % 1f; | |
//puts the hue at the proper distance so that they are in the proper split comp locations | |
//and put them in sH ans foH | |
secondColor = Color.HSVToRGB(sH, S, V); | |
fourthColor = Color.HSVToRGB(foH, S, V); | |
//change the second and fourth colors, and due to the calculations, they are in the right spot | |
thirdColor = secondColor * .5f; | |
fifthColor = fourthColor * .5f; | |
// makes the third and fifth colors different shades of the second and fourth colors | |
ColorSet(); | |
} | |
} |