I use context-blender to apply the effect of multiplying by the first 192 pixels of a fixed color html background image to achieve a transparency effect in the page title.
In html, I have 2 canvases. One for part of the image to apply the multiplication effect and one for color.
In javascript, after setting the color of the color canvas and the width of both canvases in window.innerWidth I get a background image using
imageObj.src = $('html').css('background-image').replace(/^url|[\(\)]/g, '');
Now a problem arises. I want to draw a cropped image onto an image on the image canvas in order to apply the multiplication effect. I am trying to do the following:
imageObj.onload = function(){
But I'm doing something wrong, getting the cropped height.
Example: for a 1536x1152 image and a browser container 1293x679, the value I get for the height of the cropped source is 230, but to get the crop I need to use something around 296.
Edit:
I use background-size: css cover art to create a background image
Edit2:
I created a fiddle to illustrate the problem. If you uncomment the line //cHeight *= magicConstant; , the cropped image looks much better, but everything ceases to make sense. I removed the multiplication effect of the violinist, but should not have reproduced the problem. I also noticed that the behavior changed if I remove the second canvas from the URL.
Btw, this behavior happened with google chrome, but I think the same thing happens with safari and firefox.
dcarneiro
source share