[PlutoLib] Code cleanup

This commit is contained in:
Tefek 2020-10-18 00:57:08 +02:00 committed by Tefek
parent 5c5480d5c4
commit 3bf0d18e88
4 changed files with 18 additions and 17 deletions

View File

@ -23,12 +23,13 @@ public class InputBus
public static void init(Display display)
{
var instance = new InputBus();
var windowPointer = display.getWindowPointer();
GLFW.glfwSetKeyCallback(display.getWindowPointer(), instance.keyboard);
GLFW.glfwSetMouseButtonCallback(display.getWindowPointer(), instance.mouseButton);
GLFW.glfwSetCursorPosCallback(display.getWindowPointer(), instance.cursorPosition);
GLFW.glfwSetScrollCallback(display.getWindowPointer(), instance.scroll);
GLFW.glfwSetCharCallback(display.getWindowPointer(), instance.charInput);
GLFW.glfwSetKeyCallback(windowPointer, instance.keyboard);
GLFW.glfwSetMouseButtonCallback(windowPointer, instance.mouseButton);
GLFW.glfwSetCursorPosCallback(windowPointer, instance.cursorPosition);
GLFW.glfwSetScrollCallback(windowPointer, instance.scroll);
GLFW.glfwSetCharCallback(windowPointer, instance.charInput);
INSTANCE.set(instance);
}

View File

@ -1,5 +1,6 @@
package cz.tefek.pluto.io.logger;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.OutputStream;
@ -10,7 +11,7 @@ import java.io.OutputStream;
* @author 493msi
*
*/
class OutputSplitStream extends OutputStream
public class OutputSplitStream extends OutputStream
{
private final OutputStream outputStreamA;
private final boolean shouldAClose;
@ -36,14 +37,14 @@ class OutputSplitStream extends OutputStream
}
@Override
public void write(byte[] b) throws IOException
public void write(@Nonnull byte[] b) throws IOException
{
this.outputStreamA.write(b);
this.outputStreamB.write(b);
}
@Override
public void write(byte[] b, int off, int len) throws IOException
public void write(@Nonnull byte[] b, int off, int len) throws IOException
{
this.outputStreamA.write(b, off, len);
this.outputStreamB.write(b, off, len);

View File

@ -10,7 +10,7 @@ package cz.tefek.pluto.math;
public class CubicBezier
{
private static final int iterations = 16;
private double a, b, c, d;
private final double a, b, c, d;
/**
* Creates a new {@code CubicBezier} from the given parameters.
@ -62,23 +62,22 @@ public class CubicBezier
double t = 0.5;
double x;
double y = 3 * (1 - t) * (1 - t) * t * this.b + 3 * (1 - t) * t * t * this.d + t * t * t;
// Resulting Y value
double result = 3 * (1 - t) * (1 - t) * t * this.b + 3 * (1 - t) * t * t * this.d + t * t * t;
double delta = 0.25;
boolean uh;
for (int i = 0; i < iterations; i++)
{
x = 3 * (1 - t) * (1 - t) * t * this.a + 3 * (1 - t) * t * t * this.c + t * t * t;
y = 3 * (1 - t) * (1 - t) * t * this.b + 3 * (1 - t) * t * t * this.d + t * t * t;
result = 3 * (1 - t) * (1 - t) * t * this.b + 3 * (1 - t) * t * t * this.d + t * t * t;
uh = x > xIn;
t += uh ? -delta : delta;
t += x > xIn ? -delta : delta;
delta /= 2;
}
return y;
return result;
}
}

View File

@ -42,7 +42,7 @@ public class CubicBezierLT
}
/**
* Retrives the approximate value for the given x and the supplied
* Retrieves the approximate value for the given x and the supplied
* parameters in the constructor.
*
* @param xIn the input X position