fit

Scales uniformly an element so that it fits in a given rectangle. No scaling will be applied if the element is already small enough to fit in the rectangle.

Parameters

element kendo.drawing.Element

The drawing element that should be fitted.

rect kendo.geometry.Rect

The rectangle in which the elements should be fitted.

Example

<div id="surface"></div>
<script>
  var draw = kendo.drawing;
  var Rect = kendo.geometry.Rect;

  var group = new draw.Group();
  var rect = new Rect([0, 0], [200, 100]);
  var path = draw.Path.fromRect(new Rect([0, 0], [300, 300]), {
    fill: {
      color: "#ff0000"
    }
  });
  group.append(path, draw.Path.fromRect(rect));

  draw.fit(path, rect);

  var surface = draw.Surface.create($("#surface"));
  surface.draw(group);
</script>
In this article