canvas

Cropping with drawImage not working in Safari

两盒软妹~` 提交于 2019-12-29 07:34:08
问题 I'm working on some simple image manipulation functions with canvas. The user uploads an image, is able to rotate and crop it and then clicks ok. The image is then split in half with each half drawn mirrored to two canvas elements, like this: Original Mirrored It all works great in Chrome, Firefox, IE and Android devices. Safari won't play nice though. All the image manipulation works fine except the split function. It does draw to one of the canvas elements, but the other is just black. I've

Chrome gives a warning when loading an SVG in an <img>

余生长醉 提交于 2019-12-29 07:31:49
问题 In order to display an SVG image file onto a canvas I have the following line on the HTML: <img id="soundOnImg" src="img/speaker_on.svg" style="display:none"></img> and then to draw it on the canvas I do: ctx2d.drawImage($("#soundOnImg")[0], 10, 10, 200, 200); (using jQuery $() there) This works perfectly except for one annoyance - Chrome gives me the following warning: Resource interpreted as image but transferred with MIME type image/svg+xml. What does this warning mean? I tried using

Chrome gives a warning when loading an SVG in an <img>

与世无争的帅哥 提交于 2019-12-29 07:31:30
问题 In order to display an SVG image file onto a canvas I have the following line on the HTML: <img id="soundOnImg" src="img/speaker_on.svg" style="display:none"></img> and then to draw it on the canvas I do: ctx2d.drawImage($("#soundOnImg")[0], 10, 10, 200, 200); (using jQuery $() there) This works perfectly except for one annoyance - Chrome gives me the following warning: Resource interpreted as image but transferred with MIME type image/svg+xml. What does this warning mean? I tried using

Random images falling like rain in canvas (Javascript)

血红的双手。 提交于 2019-12-29 07:14:14
问题 So I have been playing around with canvas. Trying to simulate random falling objects, drawing the background image is no problem and not the 2nd img that is supposed to simulate a rain drop. I can get the drop to come down at a random x but now I am not really sure on how to loop the drop image x times set by the variable noOfDrops. I left my loop commented out, the working code with just one drop falling randomly is: <!DOCTYPE html> <html lang="en"> <head> <title>Canvas Regn</title> <script

Why CORS on Images with HTML Canvas?

倾然丶 夕夏残阳落幕 提交于 2019-12-29 07:03:53
问题 Recently, I spent a bit of time researching a solution to a rather common problem in web development- I was dealing with logos middle-aligned on a transparent background, but having to place text below them, it would then appear as though the amount of whitespace between the text and the image shifts from page to page. After a bit of research, I discovered I could re-align the images bottom-left using a canvas, and the solution worked beautifully... at least until I integrated the solution

How to apply image effects like edge detection oncamera stream in Windows 8 app?

為{幸葍}努か 提交于 2019-12-29 06:30:11
问题 I am trying to apply image manipulation effects in Windows 8 app on camera feeds directly. I have tried a way using canvas and redrawing images after applying effects getting from webcam directly. But this approach works fine for basic effects but for effects like edge detection its creating large lag and flickering while using canvas approach. Other way is to create MFT(media foundation transform) but it can be implemented in C about which i have no idea. Can anyone tell me how can i achieve

Chart.js Doughnut with rounded edges

自闭症网瘾萝莉.ら 提交于 2019-12-29 06:21:29
问题 I created a donut chart with Chart.js and I want it to have rounded edges at both ends. I want it to be like this: But I have it like this, with sharp edges: The best I found was this answer: How to put rounded corners on a Chart.js Bar chart, but it is for bar charts, and I have no clue of how to adapt it for doughnuts.. Here is my code: HTML <div class="modal-div-canvas js-chart"> <div class="chart-canvas"> <canvas id="openedCanvas" width="1" height="1"></canvas> <div class="chart

Convert an image to canvas that is already loaded

偶尔善良 提交于 2019-12-29 05:36:19
问题 I am working on a plugin in which I'm converting Image into Canvas and storing as data url .This function triggers on 'load' event but how can I convert an image which is already there on the page? (Don't want to refresh the page or load any image again). I tried using the Filereader() function but that also works on 'onload' concept. So how can I save the image as data url when the user clicks on the image? image.addEventListener("load", function () { var imgCanvas = document.createElement(

Skewing a bitmap only in the vertical direction

左心房为你撑大大i 提交于 2019-12-29 04:54:47
问题 I want to skew (correct me if this is not the correct word) a bitmap so that it appears to have depth. A good way to visualize what I am asking for is how the credits of Star Wars are angled to show depth. I have tried the following: canvas.getMatrix().postSkew(kx,ky,px,py); and canvas.skew(sx,sy); But I have not had much success. The above methods seem to always transform the bitmap into a parallelogram. Is there a way to transform the bitmap into a trapezoid instead? Here is a snippet of

HTML5 Canvas save() and restore() performance

随声附和 提交于 2019-12-29 04:54:12
问题 So the issue that I'm having is that in developing an HTML5 canvas app I need to use a lot of transformations (i.e. translate, rotate, scale) and therefore a lot of calls being made to context.save() and context.restore(). The performance drops very quickly even with drawing very little (because the save() and restore() are being called as many times as possible in the loop). Is there an alternative to using these methods but still be able to use the transformations? Thank you! 回答1: Animation