[][src]Crate piano_keyboard

Piano_Keyboard

Build Status

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: octave drawing

The dimensions described have been used to create the elements of a piano keyboard like for an octave like this: img

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().

Structs

Keyboard2d

The returned 2d Keyboard with all calculated elements.

KeyboardBuilder

The central builder to create a keyboard.

Rectangle

This is just another rectangle definition.

Enums

Element

The elements provided by a Keyboard are white keys, black keys and the full keyboard - defined by this enum.