CamanJS icon indicating copy to clipboard operation
CamanJS copied to clipboard

An idea inspired by the cleanup readme

Open rwaldron opened this issue 10 years ago • 2 comments

// Load with base image from URL Caman.fromURL('/images/test.jpg') // Initialize with a blank white canvas Caman.blank({width: 200, height: 200}).then(function (caman) {}); // Initialize from an img DOM node Caman.fromImage(image).then(function (caman) {}); // Initialize from another canvas Caman.fromCanvas(canvas).then(function (caman) {});

Suggest:

// Load base image from URL
Caman.from(string url);

// Find a canvas or image in the existing DOM, by selector
Caman.from(string selector);

// From an existing canvas node
Caman.from(object canvas node);

// From an existing image node
Caman.from(object image node);

// Create a blank caman canvase from an object containing width/height
// maybe other initialization parameters?
Caman.from(object dimensions);

Purely because it's easy to remember.

rwaldron avatar May 11 '15 21:05 rwaldron

All of them return a Promise, resolved with the same caman object shown in the cleanup readme

rwaldron avatar May 11 '15 21:05 rwaldron

Yeah... it could be done this way. I dunno, I was enjoying being explicit with the initialization. Maybe it's something that could be offered in addition to all of the explicit ones.

meltingice avatar May 11 '15 22:05 meltingice