Created
March 20, 2018 10:21
-
-
Save ssaurel/527983621c86bc86939b223624a8ba98 to your computer and use it in GitHub Desktop.
onSizeChanged method for the PianoView on the SSaurel's Channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onSizeChanged(int w, int h, int oldw, int oldh) { | |
super.onSizeChanged(w, h, oldw, oldh); | |
keyWidth = w / NB; | |
height = h; | |
int count = 15; | |
for (int i = 0; i < NB; i++) { | |
int left = i * keyWidth; | |
int right = left + keyWidth; | |
if (i == NB - 1) { | |
right = w; | |
} | |
RectF rect = new RectF(left, 0, right, h); | |
whites.add(new Key(rect, i + 1)); | |
if (i != 0 && i != 3 && i != 7 && i != 10) { | |
rect = new RectF((float) (i - 1) * keyWidth + 0.5f * keyWidth + 0.25f * keyWidth, 0, | |
(float) i * keyWidth + 0.25f * keyWidth, 0.67f * height); | |
blacks.add(new Key(rect, count)); | |
count++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment