-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d72c14e
commit 6d44d73
Showing
7 changed files
with
108 additions
and
13 deletions.
There are no files selected for viewing
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
using System; | ||
using UnityEngine; | ||
|
||
public class ouchiColor : ouchiLength | ||
{ | ||
private int foregroundColor = 1; | ||
private int backgroundColor = 255; | ||
|
||
public ouchiColor() | ||
{ | ||
Debug.Log("========== Ouchi Color Start =========="); | ||
texture = GeneratePattern(); | ||
} | ||
|
||
public override Texture2D GeneratePattern() | ||
{ | ||
Color fgColor = new Color(foregroundColor, foregroundColor, foregroundColor); | ||
Color bgColor = new Color(backgroundColor, backgroundColor, backgroundColor); | ||
texture = new Texture2D(width, height); | ||
// define the background pattern | ||
for (int h = 0; h < height; h++) | ||
for (int w = 0; w < width; w++) | ||
{ | ||
texture.SetPixel(w, h, (w / InitPatternWidth % 2 == h / InitPatternHeight % 2) ? fgColor : bgColor); | ||
} | ||
// define the center circular pattern | ||
int centerX = width / 2; | ||
int centerY = height / 2; | ||
for (int h = 0; h < height; h++) | ||
for (int w = 0; w < width; w++) | ||
{ | ||
if (Mathf.Pow(w - centerX, 2) + Mathf.Pow(h - centerY, 2) < Mathf.Pow(radius, 2)) | ||
{ | ||
// texture.SetPixel(w, h, Color.red); | ||
texture.SetPixel(h, w, ((w / InitPatternWidth) % 2 == (h / InitPatternHeight) % 2) ? fgColor : bgColor); | ||
} | ||
} | ||
|
||
texture.filterMode = FilterMode.Point; | ||
texture.Apply(); | ||
return texture; | ||
} | ||
|
||
public override float GetCurrentRatio() | ||
{ | ||
return (float)backgroundColor / foregroundColor; | ||
} | ||
|
||
public override float GetInitRatio() | ||
{ | ||
return 255.0f; | ||
} | ||
|
||
public override void IncreasePatternRatio(float step) | ||
{ | ||
if (foregroundColor + step <= 255) | ||
{ | ||
foregroundColor += (int)step; | ||
backgroundColor -= (int)step; | ||
} | ||
texture = GeneratePattern(); | ||
} | ||
|
||
public override void DecreasePatternRatio(float step) | ||
{ | ||
if (backgroundColor - step >= 0) | ||
{ | ||
backgroundColor += (int)step; | ||
foregroundColor -= (int)step; | ||
} | ||
texture = GeneratePattern(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
File renamed without changes.