Skip to content

Commit

Permalink
electric ring
Browse files Browse the repository at this point in the history
  • Loading branch information
quaap committed Dec 5, 2016
1 parent 33a93d2 commit d523353
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,47 @@ public void doDraw(final Canvas canvas, final long ticks) {

class BarbedRing extends Ring {

double size = 2;
double speed = 40;
double modsize = size;
double dsize = .1;

public void doDraw(final Canvas canvas, final long ticks) {

for (long j=0; j<ticks; j++) {
for (int i = 0; i < 2; i++) {
double rad1 = rad;
if (i == 1) rad1 = i * Math.PI - rad;
float x = (float) (r * Math.sin(rad1));
float y = (float) (r * Math.cos(rad1));
double rnd = Math.random();
int sizex = (int) (rnd * r / 10 * Math.cos(rad1 * 50)) + 1;
int sizey = (int) (rnd * r / 10 * Math.sin(rad1 * 50)) + 1;
canvas.drawLine(mCenterX + x, mCenterY + y, mCenterX + x + sizex, mCenterY + y + sizey, mForeground);
}
if (mTouchDY!=0) {
size+= Math.signum(mTouchDY)/5;
if (size>15) size=15;
if (size<1) size=1;
modsize = size;
dsize = .1;
}

rad += .001;
modsize += dsize;
dsize += (size - modsize)/size/10;


if (mTouchDX!=0) {
speed+= Math.signum(mTouchDX)/5;
if (speed>60) speed=60;
if (speed<4) speed=4;
}


rad = 0;
do {


float x = (float) (r * Math.sin(rad));
float y = (float) (r * Math.cos(rad));
double rnd = Math.random();
int sizex = (int) (modsize*rnd * r / 10 * Math.cos(rad * speed)) + 1;
int sizey = (int) (modsize*rnd * r / 10 * Math.sin(rad * speed)) + 1;
canvas.drawLine(mCenterX + x, mCenterY + y, mCenterX + x + sizex, mCenterY + y + sizey, mForeground);


rad += .005;
} while (rad<Math.PI*2);

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public GraphicDmn(Context context, AttributeSet attrs) {
d1.setPaints(mLinePaint, mBgColor);
//drawers.add(d1);

Drawgorythm d2 = new PentaRing();
Drawgorythm d2 = new BarbedRing();
d2.setPaints(mLinePaint, mBgColor);
drawers.add(d2);

Expand Down

0 comments on commit d523353

Please sign in to comment.