meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.56k stars 406 forks source link

An idea inspired by the cleanup readme #175

Open rwaldron opened 9 years ago

rwaldron commented 9 years ago

// 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 commented 9 years ago

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

meltingice commented 9 years ago

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.