-
Notifications
You must be signed in to change notification settings - Fork 93
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
1635085
commit f53c9f3
Showing
6 changed files
with
147 additions
and
12 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
33 changes: 33 additions & 0 deletions
33
library/src/main/java/com/intrusoft/library/GradientGenerator.java
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,33 @@ | ||
package com.intrusoft.library; | ||
|
||
import android.graphics.LinearGradient; | ||
import android.graphics.RadialGradient; | ||
import android.graphics.Shader; | ||
|
||
/** | ||
* Created by Intruder Shanky on 12/16/2016. | ||
*/ | ||
|
||
public class GradientGenerator { | ||
|
||
public static Shader getRadialGradient(float width, float height, int startColor, int endColor) { | ||
float radius = Math.max(width, height) / 2; | ||
return new RadialGradient(width / 2, height / 2, radius, startColor, endColor, Shader.TileMode.CLAMP); | ||
} | ||
|
||
public static Shader getLinearGradient(int angle, float width, float height, int startColor, int endColor) { | ||
float x1 = 0, y1 = 0, y2 = 0; | ||
float x2 = (float) (height / Math.tan(angle)); | ||
if (angle <= 180) { | ||
y1 = height; | ||
if (angle > 90) | ||
x1 = width; | ||
} else if (angle <= 360) { | ||
y2 = height; | ||
if (angle <= 270) | ||
x1 = width; | ||
} | ||
return new LinearGradient(x1, y1, x2, y2, startColor, endColor, Shader.TileMode.CLAMP); | ||
} | ||
|
||
} |
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