Created
June 12, 2015 04:28
-
-
Save edwonedwon/1948630415ad8e2ff898 to your computer and use it in GitHub Desktop.
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
void DrawCircle(int x, int y, int r, Color color) | |
{ | |
// how many segments you want in circle | |
int num_segments = 128; | |
float radius = r; // radius of circle | |
Vector2 center_pos = new Vector2(x,y); | |
// change angle for each pos in circle | |
float delta_angle = 2.0f * Mathf.PI / (float)num_segments; | |
// points in a circle | |
for( int i = 0; i < num_segments; ++i ) | |
{ | |
// current angle | |
float curr_angle = i * delta_angle; | |
// direction from center of circle, normalized | |
Vector2 dir = new Vector2( Mathf.Cos(curr_angle), Mathf.Sin(curr_angle) ); | |
Vector2 pos = center_pos + dir * radius; | |
newTex.SetPixel((int)pos.x,(int)pos.y,color); | |
} | |
} |
even better how to do I make it glow / fade out around the edges
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do I fill in the circle