Michael
Michael

Reputation: 33297

How to Rotate Canvas using CamanJS?

I use Caman.js and hava a

<canvas> 

element on my page.

How can I rotate this canvas with Caman.js?

I found this but I do not know how to apply it.

Upvotes: 0

Views: 2619

Answers (3)

slinhart
slinhart

Reputation: 572

To outline in more detail on how to get the rotate plugin (and other plugins for Camanjs) included in Camanjs I followed these steps:

  1. Download the plugin files (.coffee files) from camanjs plugin github
  2. Install coffee script through npm. npm install -g coffee-script
  3. Compile the plugin with coffee -c /path/to/script.coffee
  4. Now you will have a .js file. Delete the surronding immediatly invoking function as you will not want it when you place it in the caman.js file (or caman.full.js like I did).
  5. Take the code from the plugin (with the surronding function removed) and paste it at the bottom of you caman.js file, but above the last closing brace.

Now you will have the plugin included into your caman plugin.

Note: I'm sure there is a better way to do this, however, this worked for me and I couldn't find any other information out there outlining these steps.

Upvotes: 1

ivoba
ivoba

Reputation: 5986

Rotate is a Plugin.
You have to compile Caman.js with the plugin since its all written in coffeescript.

The plugins you will find here: https://github.com/meltingice/CamanJS-Plugins

For how to include them have a look at the cakefile

After that is done it will work as stephan1001 wrote.

Upvotes: 1

user2722142
user2722142

Reputation:

Use this:

Caman("#canvasId", function () {
  this.rotate(90);
  this.render();
});

Upvotes: 5

Related Questions