simplify access to display width and height and halves

This commit is contained in:
yugecin
2018-07-08 00:30:47 +02:00
parent 27bbc874da
commit d412a2e39e
44 changed files with 339 additions and 399 deletions

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,10 +38,10 @@ public class ApproachCircleSpinner extends Spinner {
ang += 15;
}
double rad = displayContainer.width / 4.0f * (1d - Spinner.PROGRESS);
double rad = width / 4.0f * (1d - Spinner.PROGRESS);
point[0] = displayContainer.width / 2.0f + rad * Math.sin(ang / 180d * Math.PI);
point[1] = displayContainer.height / 2.0f - rad * Math.cos(ang / 180d * Math.PI);
point[0] = width2 + rad * Math.sin(ang / 180d * Math.PI);
point[1] = height2 - rad * Math.cos(ang / 180d * Math.PI);
return point;
}

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,30 +41,30 @@ public class BeamSpinner extends Spinner {
index = ++index % 4;
final int MOD = 60;
point[0] = displayContainer.width / 2d;
point[1] = displayContainer.height / 2d;
point[0] = width2;
point[1] = height2;
if( index == 0 ) {
add( MOD, 90 );
add( MOD, 180 );
} else if( index == 1 ) {
add( MOD, 90 );
add( displayContainer.height / 2 * 0.8d, 0 );
} else if( index == 2 ) {
add( MOD, -90 );
add( displayContainer.height / 2 * 0.8d, 0 );
} else if( index == 3 ) {
add( MOD, -90 );
add( MOD, 180 );
if (index == 0) {
add(MOD, 90);
add(MOD, 180);
} else if (index == 1) {
add(MOD, 90);
add(height2 * 0.8d, 0);
} else if (index == 2) {
add(MOD, -90);
add(height2 * 0.8d, 0);
} else if (index == 3) {
add(MOD, -90);
add(MOD, 180);
ang += 0.3;
}
return point;
}
private void add( double rad, double ang ) {
point[0] += rad * Math.cos( (this.ang + ang) / 180d * Math.PI);
point[1] -= rad * Math.sin( (this.ang + ang) / 180d * Math.PI);
private void add (double rad, double ang ) {
point[0] += rad * Math.cos((this.ang + ang) / 180d * Math.PI);
point[1] -= rad * Math.sin((this.ang + ang) / 180d * Math.PI);
}
@Override

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -36,10 +36,10 @@ public class CircleSpinner extends Spinner {
ang += 15;
}
double rad = displayContainer.width / 4.0f;
double rad = width / 4.0f;
point[0] = displayContainer.width / 2.0f + rad * Math.sin(ang / 180d * Math.PI);
point[1] = displayContainer.height / 2.0f - rad * Math.cos(ang / 180d * Math.PI);
point[0] = width2 + rad * Math.sin(ang / 180d * Math.PI);
point[1] = height2 - rad * Math.cos(ang / 180d * Math.PI);
return point;
}

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
import static yugecin.opsudance.core.InstanceContainer.*;
public class CubeSpinner extends Spinner {
@@ -90,10 +90,10 @@ public class CubeSpinner extends Spinner {
x *= 3.0d / ( z + 3.0d + 5.0d + 0.5 );
y *= 3.0d / ( z + 3.0d + 5.0d + 0.5 );
double scale = displayContainer.width / (3.0f + 0.5f * Math.cos(size / 180f * Math.PI));
double scale = width / (3.0f + 0.5f * Math.cos(size / 180f * Math.PI));
//double scale = Options.width / (3.0f + -1f * ((float)(Options.s.ElapsedMilliseconds % Options.beatTimeMs)/(float)Options.beatTimeMs));
point[0] = (int) ( displayContainer.width / 2.0f + scale * x );
point[1] = (int) ( displayContainer.height / 2.0f - scale * y );
point[0] = (int) (width2 + scale * x );
point[1] = (int) (height2 - scale * y );
return point;
}

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,10 +38,10 @@ public class DonutSpinner extends Spinner {
ang += 15;
}
double rad = displayContainer.width / 4.0f;
double rad = width / 4.0f;
point[0] = displayContainer.width / 2.0f + rad * Math.sin(ang);
point[1] = displayContainer.height / 2.0f - rad * Math.cos(ang);
point[0] = width2 + rad * Math.sin(ang);
point[1] = height2 - rad * Math.cos(ang);
return point;
}

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,12 +39,12 @@ public class FivePointStarApproachSpinner extends Spinner {
odd = !odd;
}
double rad = displayContainer.width / 4.0f * (1d - Spinner.PROGRESS);
double rad = width / 4.0f * (1d - Spinner.PROGRESS);
if (!odd) {
rad /= 3d;
}
point[0] = displayContainer.width / 2d + Math.cos(ang) * rad;
point[1] = displayContainer.height / 2d + Math.sin(ang) * rad;
point[0] = width2 + Math.cos(ang) * rad;
point[1] = height2 + Math.sin(ang) * rad;
return point;
}

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,11 +24,9 @@ public class FivePointStarSpinner extends Spinner {
@Override
public void init() {
double[][] points = new double[10][];
double midx = displayContainer.width / 2d;
double midy = displayContainer.height / 2d;
double angleIncRads = Math.PI * 36d / 180d;
double ang = -Math.PI / 2d;
double maxrad = displayContainer.width / 4d;
double maxrad = width / 4d;
double minrad = maxrad / 3d;
for (int i = 0; i < 10; i++) {
double rad = maxrad;
@@ -36,8 +34,8 @@ public class FivePointStarSpinner extends Spinner {
rad = minrad;
}
points[i] = new double[] {
midx + Math.cos(ang) * rad,
midy + Math.sin(ang) * rad
width2 + Math.cos(ang) * rad,
height2 + Math.sin(ang) * rad
};
ang += angleIncRads;
}

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,9 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
import static yugecin.opsudance.core.InstanceContainer.*;
public class HalfCircleSpinner extends Spinner {
@@ -47,8 +45,8 @@ public class HalfCircleSpinner extends Spinner {
skipang += 359;
}
point[0] = displayContainer.width / 2.0d + displayContainer.height / 2 * 0.8d * Math.cos(ang/180d*Math.PI);
point[1] = displayContainer.height / 2.0d + displayContainer.height / 2 * 0.8d * Math.sin(ang/180d*Math.PI);
point[0] = width2 + height2 * 0.8d * Math.cos(ang/180d*Math.PI);
point[1] = height2 + height2 * 0.8d * Math.sin(ang/180d*Math.PI);
return point;
}

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,9 +24,9 @@ public class IlluminatiSpinner extends Spinner {
@Override
public void init() {
init( new double[][] {
new double[] { displayContainer.width / 2d - 120, displayContainer.height / 2d + 80 },
new double[] { displayContainer.width / 2d, displayContainer.height / 2d - 160 },
new double[] { displayContainer.width / 2d + 120, displayContainer.height / 2d + 80 }
new double[] { width2 - 120, height2 + 80 },
new double[] { width2, height2 - 160 },
new double[] { width2 + 120, height2 + 80 }
} );
}

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
*/
package yugecin.opsudance.spinners;
import static java.lang.Math.*;
import static yugecin.opsudance.core.InstanceContainer.*;
public class LessThanThreeSpinner extends Spinner {
@@ -24,9 +25,7 @@ public class LessThanThreeSpinner extends Spinner {
private int angle = 0;
@Override
public void init()
{
public void init() {
}
@Override
@@ -37,15 +36,12 @@ public class LessThanThreeSpinner extends Spinner {
}
if( angle > 360 ) angle = 0;
double theta = angle / 180d * Math.PI;
double[] pos = new double[] {
displayContainer.width / 2d,
displayContainer.height / 2d
};
double[] pos = { width2, height2 };
double r = 2 - 2 * Math.sin( theta ) + Math.sin( theta ) * Math.sqrt( Math.abs( Math.cos( theta ) ) ) / ( Math.sin( theta ) + 1.4 );
double r = 2 - 2 * sin(theta) + sin(theta) * sqrt(abs(cos(theta))) / (sin(theta) + 1.4);
pos[0] += Math.cos( theta ) * r * 100;
pos[1] -= Math.sin( theta ) * r * 100 + 100;
pos[0] += Math.cos(theta) * r * 100;
pos[1] -= Math.sin(theta) * r * 100 + 100;
return pos;
}

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@ public class RektCircleSpinner extends Spinner {
@Override
public void init() {
index = 0;
size = displayContainer.height * 0.8d;
size = height * 0.8d;
point = new double[2];
}
@@ -42,20 +42,20 @@ public class RektCircleSpinner extends Spinner {
final int INC = 50;
if( index == 0 ) {
point[0] = displayContainer.width / 2d + size / 2d - pos;
point[1] = displayContainer.height / 2d - size / 2d;
point[0] = width2 + size / 2d - pos;
point[1] = height2 - size / 2d;
index++;
} else if( index == 1 ) {
point[0] = displayContainer.width / 2 - size / 2;
point[1] = displayContainer.height / 2 - size / 2 + pos;
point[0] = width2 - size / 2;
point[1] = height2 - size / 2 + pos;
index++;
} else if( index == 2 ) {
point[0] = displayContainer.width / 2 - size / 2 + pos;
point[1] = displayContainer.height / 2 + size / 2;
point[0] = width2 - size / 2 + pos;
point[1] = height2 + size / 2;
index++;
} else if( index == 3 ) {
point[0] = displayContainer.width / 2 + size / 2;
point[1] = displayContainer.height / 2 + size / 2 - pos;
point[0] = width2 + size / 2;
point[1] = height2 + size / 2 - pos;
pos += INC;
if( pos > size ) {
pos = INC;

View File

@@ -1,6 +1,6 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
* Copyright (C) 2016-2018 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,11 +25,11 @@ public class RektSpinner extends Spinner {
public void init() {
init(new double[][] {
{ 10, 10 },
{ displayContainer.width / 2d, 10 },
{ displayContainer.width - 10, 10 },
{ displayContainer.width - 10, displayContainer.height - 10 },
{ displayContainer.width / 2d, displayContainer.height - 10 },
{ 10, displayContainer.height - 10 }
{ width2, 10 },
{ width - 10, 10 },
{ width - 10, height - 10 },
{ width2, height - 10 },
{ 10, height - 10 }
});
}