Crates.io | piano_keyboard |
lib.rs | piano_keyboard |
version | 0.2.3 |
source | src |
created_at | 2019-02-16 18:06:47.851159 |
updated_at | 2020-04-07 13:48:24.631948 |
description | Provides graphical representation of a piano keyboard |
homepage | https://github.com/gin66/piano_keyboard |
repository | https://github.com/gin66/piano_keyboard |
max_upload_size | |
id | 115198 |
size | 83,950 |
This crate provides the graphical elements in order to draw a piano keyboard with close to realistic, pixel accurate appearance.
Reference for the dimension is this internet image:
The dimensions described have been used to create the elements of a piano keyboard like for an octave like this:
It is visible, that between white keys and even between white and black keys a gap is ensured.
The graphical representation only provides the white and black areas for the keys. Those areas are represented by pixel accurate, non-overlapping rectangles. No aliasing or similar is done on this level.
Pixel accurate has the consequence, that in order to fill the requested width, any gaps, white or black keys may need to be modified by up to one pixel. Those changes may or may not be visible. If no adjustments have been made for a given width and key range is reported by the function is_perfect()
If the enlargement of various elements does not succeed, then as last resort technique the outter gaps are enlarged.
The gap between white and black keys can be removed by an option of the KeyboardBuilder.
The interface is prepared to be compatible for an extension towards a 3d keyboard. That's why the returned keyboard is called Keyboard2D and the related build function is called build2d().