This library is inspired by the Cosin library version 1.1.0
- For using Cosin module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/cosin.har.
dependencies {
implementation project(':cosin')
implementation fileTree(dir: 'libs', include: ['*.har'])
testCompile 'junit:junit:4.12'
}
- For using Cosin in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.har'])
testCompile 'junit:junit:4.12'
}
- For using Cosin from a remote repository in separate application, add the below dependencies in entry/build.gradle file.
dependencies {
implementation 'dev.applibgroup:cosin:1.0.0'
testCompile 'junit:junit:4.12'
}
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 |
<com.nikitagordia.cosin.Cosin
ohos:height="130vp"
ohos:width="270px" />
- DefaultColorAdapterGb (Green -> Blue)
- ColorAdapterBg (Blue -> Green)
- ColorAdapterBr (Blue -> Red)
- ColorAdapterGr (Green -> Blue)
- ColorAdapterRb (Red -> Blue)
- ColorAdapterRg (Red -> 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.getValue();
}
@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());
}
}