@@ -54,8 +54,8 @@ public class DropRenderer {
54
54
private static final float BLACK_KEY_HEIGHT_RATIO = 0.6F ;
55
55
private static final float PIANO_HEIGHT_DIVIDER = 7F ;
56
56
private static final int KEY_LINE_HEIGHT = 2 ;
57
- private static final int KEY_LINE_OFFSET = 25 ;
58
- private static final int KEY_PRESS_DEPTH = 20 ;
57
+ private static final float KEY_LINE_OFFSET_RATIO = 11.6F ;
58
+ private static final float KEY_PRESS_DEPTH_RATIO = 14.5F ;
59
59
private static final long KEY_ANIMATION_DURATION = 250_000_000L ;
60
60
61
61
private final SoundSystemSongPlayer songPlayer ;
@@ -233,24 +233,25 @@ private void drawPiano(final Matrix4fStack positionMatrix) {
233
233
Renderer2D .INSTANCE .beginGlobalBuffering ();
234
234
Renderer2D .INSTANCE .filledRect (positionMatrix , 0 , 0 , width , height , Color .BLACK );
235
235
236
+ final float keyLineOffset = height / KEY_LINE_OFFSET_RATIO ;
236
237
for (int nbsKey = 0 ; nbsKey < this .pianoKeyPositions .length ; nbsKey ++) {
237
238
final float x = this .pianoKeyPositions [nbsKey ];
238
239
final float progress = this .pianoKeyLastColors [nbsKey ] != null ? MathUtils .clamp ((System .nanoTime () - this .pianoKeyLastPlayed [nbsKey ]) / (float ) KEY_ANIMATION_DURATION , 0F , 1F ) : 1F ;
239
- final float pressOffset = KEY_PRESS_DEPTH - KEY_PRESS_DEPTH * (progress < 0.5F ? 1F - progress : progress );
240
+ final float pressOffset = height / KEY_PRESS_DEPTH_RATIO - height / KEY_PRESS_DEPTH_RATIO * (progress < 0.5F ? 1F - progress : progress );
240
241
if (!this .isBlackKey (nbsKey )) {
241
242
Renderer2D .INSTANCE .filledRect (positionMatrix , x + 1 , pressOffset , x + whiteKeyWidth - 1 , height , Color .WHITE );
242
243
if (this .pianoKeyLastColors [nbsKey ] != null ) {
243
244
Renderer2D .INSTANCE .filledRect (positionMatrix , x + 1 , pressOffset , x + whiteKeyWidth - 1 , height , this .pianoKeyLastColors [nbsKey ].withAlpha (Math .round (200 * (1 - progress ))));
244
245
}
245
- Renderer2D .INSTANCE .filledRect (positionMatrix , x , height - KEY_LINE_OFFSET + pressOffset , x + whiteKeyWidth , height - KEY_LINE_OFFSET - KEY_LINE_HEIGHT + pressOffset , Color .GRAY );
246
+ Renderer2D .INSTANCE .filledRect (positionMatrix , x , height - keyLineOffset + pressOffset , x + whiteKeyWidth , height - keyLineOffset - KEY_LINE_HEIGHT + pressOffset , Color .GRAY );
246
247
} else {
247
248
positionMatrix .pushMatrix ();
248
249
positionMatrix .translate (0 , 0 , 1 );
249
250
Renderer2D .INSTANCE .filledRect (positionMatrix , x , pressOffset , x + blackKeyWidth , height * BLACK_KEY_HEIGHT_RATIO , Color .BLACK );
250
251
if (this .pianoKeyLastColors [nbsKey ] != null ) {
251
252
Renderer2D .INSTANCE .filledRect (positionMatrix , x , pressOffset , x + blackKeyWidth , height * BLACK_KEY_HEIGHT_RATIO , this .pianoKeyLastColors [nbsKey ].withAlpha (Math .round (200 * (1 - progress ))));
252
253
}
253
- Renderer2D .INSTANCE .filledRect (positionMatrix , x , height * BLACK_KEY_HEIGHT_RATIO - KEY_LINE_OFFSET + pressOffset , x + blackKeyWidth , height * BLACK_KEY_HEIGHT_RATIO - KEY_LINE_OFFSET - KEY_LINE_HEIGHT + pressOffset , Color .GRAY );
254
+ Renderer2D .INSTANCE .filledRect (positionMatrix , x , height * BLACK_KEY_HEIGHT_RATIO - keyLineOffset + pressOffset , x + blackKeyWidth , height * BLACK_KEY_HEIGHT_RATIO - keyLineOffset - KEY_LINE_HEIGHT + pressOffset , Color .GRAY );
254
255
positionMatrix .popMatrix ();
255
256
}
256
257
}
0 commit comments