― I’M SHISHIR RAVEN

WEBSITE & App Builder

Lorem Ipsum is simply dummy text of the printing and type setting industry. Lorem Ipsum has been the industry’s standard dummy text.

Zoom to fit objects in Paper JS.

Objective

In a Fixed space of a particular dimension say 500px X 350px.
I want the PaperJS diagram to fit such that the everything fits well by scaling itself.

var scope = new paper.PaperScope();

var canvas_1 = document.getElementById('canvas_1');
scope.setup(canvas_1)
scope.activate();

var myCircle = new scope.Path.Circle(new scope.Point(100, 70), 50);
myCircle.fillColor = 'black';
var myCircle = new scope.Path.Circle(new scope.Point(10, 10), 50);
myCircle.fillColor = 'green';
var myCircle = new scope.Path.Circle(new scope.Point(200, 200), 50);
myCircle.fillColor = 'yellow';


$(document).ready(function()
{
	$("#zoom_to_fit").click(function()
  {
    scope.project.activeLayer.fitBounds(scope.view.bounds);
  })
  
}); 

Posted

in

by

Tags: