ericdrowell / KineticJS

KineticJS is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://www.kineticjs.com
3.98k stars 754 forks source link

New plugin for KineticJS - display html inside canvas #680

Closed lavrton closed 10 years ago

lavrton commented 11 years ago

Hello. I made a little plugin that helps me to display html inside canvas. Reason: it is hard to display some html elements inside kineticjs stage, because:

  1. I have to create element and take care about positions.
  2. It is REALLY hard to make it draggable - I have to use external libs.

https://github.com/slash-system/KineticJS.HTML Demo: http://jsfiddle.net/lavrton/3Tybj/ Note: html is displaying as IMAGE!

Does it usefull for someone else?

ericdrowell commented 11 years ago

Way cool! I'll take a look as soon as I can

Eric

Sent from my iPad

On Nov 6, 2013, at 9:41 PM, Anton Lavrenov notifications@github.com wrote:

Hello. I made a little plugin that helps me to display html inside canvas. Reason: it is hard to display some html elements inside kineticjs stage, because:

  1. I have to create element and take care about positions.
  2. It is REALLY hard to make it draggable - I have to use external libs.

https://github.com/slash-system/KineticJS.HTML Demo: http://jsfiddle.net/lavrton/3Tybj/ Note: html is displaying as IMAGE!

Does it usefull for someone else?

— Reply to this email directly or view it on GitHub.

scheng2013 commented 11 years ago

Really good!

lavrton commented 11 years ago

API for now is

var html = new Kinetic.HTML({
    html : "<content>",
    callback : function() {}   //callback here is bad
});

May be it wiil be more usefull with this API:

Kinetic.htmlToImage({
    html : "<content>",
    callback : function(img) {
       var image = new Kinetic.Image({
           image : img
       });
   }
});
kidino commented 10 years ago

I am not into canvas web app yet. But I have been considering this. And one of my requirement is it has to be able to render HTML in Canvas. Having this inside KineticJS makes it much more awesome because it'll be easy for manipulation. Thanks!

lavrton commented 10 years ago

Also, if someone interesting, this may be helpfull: https://github.com/niklasvh/html2canvas

dvsmaximaa commented 10 years ago

lavrton.. this example is gud but i want to know is it possible to put image,audio and video tag oh html5 ??