Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cached Image does not show border anymore #1041

Open
confile opened this issue Nov 10, 2014 · 0 comments
Open

Cached Image does not show border anymore #1041

confile opened this issue Nov 10, 2014 · 0 comments

Comments

@confile
Copy link

confile commented Nov 10, 2014

I use KineticJS 5.1.0 and want to apply a filter on an Image. My image has a border. After applying cache and filter the border in gone.

Here is the code I use (http://jsfiddle.net/confile/qgrjjjq9/):

var imageObj = new Image();
      imageObj.onload = function() {
        var stage = new Kinetic.Stage({
          container: 'container',
          width: 600,
          height: 700
        });
        var layer = new Kinetic.Layer();
        img = new Kinetic.Image({
          x: 250,
          y: 200,
          image: imageObj,
          draggable: true
        });
        img.clearCache();
        img.setOffsetX(img.getWidth() / 2); 
          img.setOffsetY(img.getHeight() / 2); 
        img.stroke("green");  
        img.strokeWidth(4);
        img.strokeScaleEnabled(false);  
        img.strokeEnabled(true);  

        layer.add(img);
        stage.add(layer);

        img.cache({
            x: -(img.getWidth() / 2),
            y: -(img.getHeight() / 2),
            drawBorder: true
          });
        img.filters([Kinetic.Filters.Invert]);
        layer.draw();

          console.log("type: "+img.getType());  
      };
       imageObj.crossOrigin = "anonymous";
      imageObj.src =
  "https://dl.dropboxusercontent.com/u/47067729/darth-vader.jpg";      

Here is the image before the caching:

edit_fiddle_-_jsfiddle

And the image after caching and filter:

edit_fiddle_-_jsfiddle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant