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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class ParticleTextViewConfig {
private String[] particleColorArray = null;
private MovingStrategy movingStrategy = new RandomMovingStrategy();
private long delay = 1000;
private int xPosition = 50;
private int yPosition = 50;

private ParticleTextViewConfig(){}

Expand Down Expand Up @@ -107,6 +109,22 @@ public Builder setDelay(Long delay){
return this;
}

public Builder setXPosition(int xPosition){
if (xPosition <= 0){
xPosition = 1;
}
particleTextViewConfig.xPosition = xPosition;
return this;
}

public Builder setYPosition(int yPosition){
if (yPosition <= 0){
yPosition = 1;
}
particleTextViewConfig.yPosition = yPosition;
return this;
}

public ParticleTextViewConfig instance(){
return particleTextViewConfig;
}
Expand Down Expand Up @@ -155,4 +173,12 @@ public MovingStrategy getMovingStrategy() {
public long getDelay() {
return delay;
}

public int getXPosition() {
return xPosition;
}

public int getYPosition() {
return yPosition;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class ParticleTextView extends View {
private long delay = 1000;
private long delayHolder = 1000;
private int textIterator = 0;
private int xPosition;
private int yPosition;

public ParticleTextView(Context context) {
super(context);
Expand Down Expand Up @@ -80,6 +82,8 @@ public void setConfig(ParticleTextViewConfig config) {
this.movingStrategy = config.getMovingStrategy();
this.delay = config.getDelay();
this.delayHolder = config.getDelay();
this.xPosition = config.getXPosition();
this.yPosition = config.getYPosition();
} else {
Log.e("CONFIGERROR", "ParticleTextView Config is Null");
}
Expand All @@ -105,10 +109,12 @@ public boolean isAnimationStop(){
return this.isAnimationStop;
}

private int[][] bitmapTransition(int centerX, int centerY) {
private int[][] bitmapTransition() {
int centerX = (int) (((float) getWidth() / 100) * xPosition);
int centerY = (int) (((float) getHeight() / 100) * yPosition);
int[][] colorArray;
textPaint = initTextPaint();
bitmap = Bitmap.createBitmap(centerX * 2, centerY * 2, Bitmap.Config.ARGB_8888);
bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
Canvas textCanvas = new Canvas(bitmap);
textCanvas.drawText(targetText, centerX, centerY, textPaint);
colorArray = new int[bitmap.getHeight()][bitmap.getWidth()];
Expand All @@ -117,7 +123,6 @@ private int[][] bitmapTransition(int centerX, int centerY) {
colorArray[row][column] = bitmap.getPixel(column, row);
}
}
Log.d("Bitmap Transition", "Run");
return colorArray;
}

Expand All @@ -142,7 +147,6 @@ protected void onDraw(Canvas canvas) {
}
}
setParticles();
Log.d("TargetText", targetText);
setParticles = true;
}

Expand All @@ -151,7 +155,6 @@ protected void onDraw(Canvas canvas) {
}

if (!checkJudgeDistance()) {
Log.d("Particles", "Paused");
pauseAnimation();
}

Expand Down Expand Up @@ -199,10 +202,7 @@ protected void onDraw(Canvas canvas) {
}

private void setParticles(){
Log.d("Particles", "Set Particles");
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
int[][] colorArray = bitmapTransition(centerX, centerY);
int[][] colorArray = bitmapTransition();
int red, green, blue;
particles = new Particle[(colorArray.length / rowStep) * colorArray[0].length / columnStep];
int index = 0;
Expand Down