build.gradle (Project)
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
build.gradle (Module)
implementation 'com.github.NikitaGordia:Cosin:1.1.0'
<com.nikitagordia.cosin.Cosin
android:layout_width="170dp"
android:layout_height="140dp" />
Property | Description |
---|---|
speed | Angle speed |
isLoading | If 'true' shows symbols on rectangle |
setEnd | Shows end animation (optionally you may pass onEnd(OnEnd)) |
rectWidth | Width each of rectangle |
period | Determine period of cosinusoidal function |
colorAdapter | Define color changes by two parameters (position count, height percent) for each rectagle |
offset | Moving bottom offset |
directionRight | Determine movement side |
textAdapter | Define text changes by position count for each rectangle |
- DefaultColorAdapterGB (Green -> Blue)
- ColorAdapterBG (Blue -> Green)
- ColorAdapterBR (Blue -> Red)
- ColorAdapterGR (Green -> Blue)
- ColorAdapterRB (Red -> Blue)
- ColorAdapterRG (Red -> Green)
- ColorAdapterBG (Blue -> Green)
- DefaultBinaryTextAdapter (shows random [0, 1] symbols in each rectagle)
- WordTextAdapter (shows specified cycle String)
public class ColorAdapterBR implements Cosin.ColorAdapter {
@Override
public int getBackgroundColor() {
return Color.TRANSPARENT;
}
@Override
public int calcColor(int numOfRect, double percentOfHeight) {
return Color.argb(150, (int)(255 * (1d - percentOfHeight)), 0, (int)(255 * percentOfHeight));
}
}
public class WordTextAdapter implements Cosin.TextAdapter {
private String word;
public WordTextAdapter(String word) {
this.word = word;
}
@Override
public char getString(int numOfRect) {
if (word.isEmpty()) return ' ';
return word.charAt(numOfRect % word.length());
}
}