Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
quaap committed Nov 2, 2018
1 parent 05d6e64 commit e0dbcbb
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@

public class Awaken extends Drawgorythm {

private float alpha = 3;
private float alpha = 10;
private float scale = .0001f;
private float scalev = .000008f;
private Rect dstrect;
private Rect srcrect;

private Rect gradrect;
private Bitmap img;
private Bitmap img2;

private Bitmap [] gradient;
private Paint alphatweak;
private Paint white = new Paint();
Expand All @@ -40,30 +38,30 @@ public class Awaken extends Drawgorythm {

private Matrix m = new Matrix();

private UpdaterThread mUpdaterThread;
//private UpdaterThread mUpdaterThread;

private final Object imgsync = new Object();
private List<RectF> poss = new ArrayList<>();
private List<RectF> dVs = new ArrayList<>();
private List<Bitmap> bitmaps = new ArrayList<>();

private int num;
//private Canvas c;

public Awaken(Context context) {
super(context);

//img = context.getResources().getDrawable(R.drawable.rift);
dstrect = new Rect();
gradient = new Bitmap[4];
gradient[0] = BitmapFactory.decodeResource(context.getResources(),R.drawable.gradient2);
gradient[1] = BitmapFactory.decodeResource(context.getResources(),R.drawable.gradient3);
gradient[2] = BitmapFactory.decodeResource(context.getResources(),R.drawable.gradient4);
gradient[3] = BitmapFactory.decodeResource(context.getResources(),R.drawable.gradient5);
gradient[0] = BitmapFactory.decodeResource(context.getResources(),R.drawable.gradient);
gradient[1] = BitmapFactory.decodeResource(context.getResources(),R.drawable.gradient2);
gradient[2] = BitmapFactory.decodeResource(context.getResources(),R.drawable.gradient5);
gradient[3] = BitmapFactory.decodeResource(context.getResources(),R.drawable.gradient4);
gradrect = new Rect(0,0,gradient[0].getWidth(),gradient[0].getHeight());

alphatweak = new Paint();
alphatweak.setColor(Color.WHITE);
white.setColor(Color.WHITE);
num = Rand.getInt(3,9);
num = Rand.getInt(2,4);

}

Expand All @@ -72,104 +70,28 @@ public Awaken(Context context) {
public void canvasChanged(Canvas canvas) {
super.canvasChanged(canvas);

for (int i=0; i<num; i++) {
// drawbjects.add(new Drawbject(gradient.copy(Bitmap.Config.ARGB_8888,true),1,1));
for (int i = 0; i < num; i++) {

int x = Rand.getInt(mCenterX-mCenterX/10, mCenterX+mCenterX/10);
int y = Rand.getInt(mCenterY-mCenterY/10, mCenterY);
int w = Rand.getInt(mWidth/15, mWidth/11);
int x = Rand.getInt(mCenterX - mCenterX / 5, mCenterX);
int y = Rand.getInt(mCenterY*3/4 - mCenterY / 5, mCenterY*3/4);
int w = Rand.getInt(mWidth / 15, mWidth / 11);
int h = w + 2; // + Rand.getInt(mHeight/7);
RectF dst = new RectF(x,y,x+w, y+h);
RectF dst = new RectF(x, y, x + w, y + h);

poss.add(dst);
dVs.add(new RectF(Rand.getFloatNeg1To1(), Rand.getFloatNeg1To1(), 0,0));
dVs.add(new RectF(Rand.getFloatNeg1To1(), Rand.getFloatNeg1To1(), 0, 0));

}
img = Bitmap.createBitmap(mWidth, mHeight, gradient[0].getConfig());
img2 = Bitmap.createBitmap(mWidth, mHeight, gradient[0].getConfig());
//c = new Canvas();
//c.setBitmap(img2);
//img = gradient;
srcrect = new Rect(0, 0, img.getWidth(), img.getHeight());

if (mUpdaterThread!=null) {
mUpdaterThread.done=true;
}

mUpdaterThread = new UpdaterThread();

mUpdaterThread.start();

}

@Override
public void stopping() {
if (mUpdaterThread!=null) {
mUpdaterThread.done=true;
}
}

private class UpdaterThread extends Thread {
boolean done=false;
int sleep = 1000;

@Override
public void run() {

while(!done) {

//c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.SRC);
for (int i = 0; i < num; i++) {
RectF d = poss.get(i);
RectF dV = dVs.get(i);

if (d.left<=10) dV.left = -dV.left;
if (d.top<=10) dV.top = -dV.top;
if (d.right>=mWidth-10) dV.left = -dV.left;
if (d.bottom>=mHeight*3/4) dV.top = -dV.top;

d.set(d.left+dV.left - d.left*scale, d.top+dV.top - d.top*scale,
d.right+dV.left+ d.left*scale, d.bottom+dV.top + d.top*scale);

m.setRectToRect(new RectF(gradrect), d, Matrix.ScaleToFit.CENTER);

//c.drawBitmap(gradient[i%gradient.length], m, white);

if (mTouchDY>0 && i%2==0 || mTouchDY<0 && i%2!=0) {
//draws += .001*dY;
dV.left = Math.signum(mTouchX - d.left) * Math.abs(dV.left) * (float)Rand.getDouble(.5,1.5);
dV.top = Math.signum(mTouchY - d.top) * Math.abs(dV.top) * (float)Rand.getDouble(.5,1.5);
Log.d("Awake", "" + scale);
}

if (scale>.004) {
scalev = -.00008f; // + Math.sin(draws/5)/1000;
}
else if (scale<-.002) {
scalev = .000008f;
}
scale += scalev;

}
synchronized (imgsync) {
img = img2.copy(Bitmap.Config.ARGB_8888, false);
}
try {
sleep(sleep);
} catch (InterruptedException e) {
e.printStackTrace();
}
done = true;

}
}
}


Matrix r = new Matrix();
int count = 0;
@Override
public void doDraw(Canvas canvas, long ticks) {
canvas.rotate(-mRoll, mCenterX, mCenterY+mCenterY/2);

int sign = 1;
if (alpha > 250) {
Expand All @@ -183,7 +105,7 @@ public void doDraw(Canvas canvas, long ticks) {

alpha += .01 * sign + Math.sin(draws/2);

draws+=.1;
draws+=.15;

alphatweak.setAlpha((int)alpha);

Expand All @@ -199,15 +121,15 @@ public void doDraw(Canvas canvas, long ticks) {
d.set(d.left+dV.left - d.left*scale, d.top+dV.top - d.top*scale,
d.right+dV.left+ d.left*scale, d.bottom+dV.top + d.top*scale);

m.setRectToRect(new RectF(gradrect), d, Matrix.ScaleToFit.CENTER);
//m.setRectToRect(new RectF(gradrect), d, Matrix.ScaleToFit.CENTER);

canvas.drawBitmap(gradient[i%gradient.length], m, alphatweak);
canvas.drawBitmap(gradient[i%gradient.length], d.left, d.top, alphatweak);

if (mTouchDY>0 && i%2==0 || mTouchDY<0 && i%2!=0) {
//draws += .001*dY;
dV.left = Math.signum(mTouchX - d.left) * Math.abs(dV.left) * (float)Rand.getDouble(.5,1.5);
dV.top = Math.signum(mTouchY - d.top) * Math.abs(dV.top) * (float)Rand.getDouble(.5,1.5);
Log.d("Awake", "" + scale);
//Log.d("Awake", "" + scale);
}

if (scale>.004) {
Expand All @@ -220,8 +142,10 @@ else if (scale<-.002) {

}

// r.reset();
// r.postRotate(-mRoll, mCenterX, mCenterY+mCenterY/2);
//r.reset();
//r.postRotate(-mRoll, mCenterX, mCenterY+mCenterY/2);

//canvas.setMatrix(r);
//
// synchronized (imgsync) {
// canvas.drawBitmap(img, r, alphatweak);
Expand Down
Binary file modified app/src/main/res/drawable/gradient2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/gradient3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/gradient4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/gradient5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
android:layout_marginTop="@dimen/activity_vertical_margin" />

<TextView
android:visibility="gone"
android:text="@string/awaken_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -147,6 +148,7 @@


<Button
android:visibility="gone"
android:text="@string/awaken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit e0dbcbb

Please sign in to comment.