Adapted from
EaselJS