Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.DS_Store
/build
/captures
/.idea
3 changes: 2 additions & 1 deletion cslibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ android {
}

dependencies {

compile 'com.android.support:support-annotations:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
}
15 changes: 15 additions & 0 deletions cslibrary/src/main/java/com/hitomi/cslibrary/CrazyShadow.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public static class Builder {
*/
private String impl;

/**
* Alpha to the shadow
*/
private float shadowAlpha = 1.0f;

/**
* 阴影的基本色
*/
Expand Down Expand Up @@ -153,6 +158,15 @@ public Builder setImpl(String impl) {
return this;
}

/**
* Add alpha to the shadow.
* Value between 0 and 1
*/
public Builder setShadowAlpha(float shadowAlpha) {
this.shadowAlpha = Math.max(Math.min(shadowAlpha, 1), 0);
return this;
}

/**
* 阴影的基本颜色,即最深的颜色, {@link CrazyShadowAttr#setBaseShadowColor(int)}
* 方法会自动计算出绘制阴影时需要的 {@link #colors}
Expand Down Expand Up @@ -223,6 +237,7 @@ private CrazyShadow create() {
colors = new int[]{0x63000000, 0x32000000, 0x00000000};
CrazyShadowAttr attr = new CrazyShadowAttr();
attr.setImpl(impl);
attr.setShadowAlpha(shadowAlpha);
attr.setBaseShadowColor(baseShadowColor);
attr.setBackground(background);
attr.setColors(colors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public class CrazyShadowAttr {
*/
private String impl;

/**
* Add alpha to the shadow.
* Value between 0 and 1
*/
private float shadowAlpha = 1.0f;

/**
* 阴影的基本颜色,即最深的颜色, {@link #setBaseShadowColor(int)} 方法会自动计算出
* 绘制阴影时需要的 {@link #colors}
Expand Down Expand Up @@ -50,6 +56,9 @@ public class CrazyShadowAttr {
@CrazyShadowDirection
private int direction;

public CrazyShadowAttr() {
}

public String getImpl() {
return impl;
}
Expand All @@ -58,12 +67,17 @@ public void setImpl(String impl) {
this.impl = impl;
}

public void setShadowAlpha(float shadowAlpha) {
this.shadowAlpha = Math.max(Math.min(shadowAlpha, 1), 0);
this.shadowAlpha = shadowAlpha;
}

public void setBaseShadowColor(int baseShadowColor) {
this.baseShadowColor = baseShadowColor;
if (colors == null) {
colors = new int[3];
colors[0] = ColorUtils.setAlphaComponent(baseShadowColor, 255);
colors[1] = ColorUtils.setAlphaComponent(baseShadowColor, 128);
colors[0] = ColorUtils.setAlphaComponent(baseShadowColor, (int)(255 * shadowAlpha));
colors[1] = ColorUtils.setAlphaComponent(baseShadowColor, (int)(128 * shadowAlpha));
colors[2] = ColorUtils.setAlphaComponent(baseShadowColor, 0);
}
}
Expand Down