Point withinRect(Rect rect)

Returns the point that is this fraction within the given rect.

Source

Point withinRect(Rect rect) {
  return new Point(rect.left + dx * rect.width, rect.top + dy * rect.height);
}