canvas

iOS HTML5 Canvas toDataURL

谁都会走 提交于 2020-01-01 05:49:10
问题 I need some assistance. We seem to be having an issue with iOS with regards to getting the base64 of an image via HTML 5 / Canvas. Everything works fine if we use the default height / width of the canvas or hard code the height and width. However if we set the canvas height / width to that of the image src then the image won’t load into the canvas and therefore we won’t get the image as base64. Code snippet which works: function convertImageToBase64(imgUrl, callback) { var canvas = document

javascript ImageData typed array read whole pixel?

本小妞迷上赌 提交于 2020-01-01 04:27:05
问题 So there is are a lot of examples on how to write an entire pixel from a Uint32Array view of the ImageData object. But is it possible to read an entire pixel without incrementing the counter 4 times? From hacks.mozilla.org, writing an rgba pixels looks like this . var imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight); var buf = new ArrayBuffer(imageData.data.length); var buf8 = new Uint8ClampedArray(buf); var data = new Uint32Array(buf); for (var y = 0; y < canvasHeight; ++y) {

HTML5 canvas scaling issue on iOS platforms

半城伤御伤魂 提交于 2020-01-01 03:39:05
问题 I've been developing a project in phonegap, attempting to build for Android and iOS. The main idea is to access a saved picture on the phone library, save that picture to an HTML img element, and then draw that img element onto a canvas. From there, the user can scale and rotate the image. I've had no issues on the Android. I've tested using emulators and devices, and have tested a wide array of devices (different pixel ratios, densities, etc.) and the resulting canvas transformations always

getImageData - Web workers - How can I reduce garbage collection?

拈花ヽ惹草 提交于 2020-01-01 03:38:07
问题 I've got a sample web-worker canvas update script running, but I've noticed it stalls every few seconds for about 200ms. The usual loop time is around 15ms. I'm guessing this is garbage collection - it looks like it from the profiler. http://codepen.io/SarahC/pen/bgBoMM I think it is in this function: function nextFrame(){ timeChart.start(); workersWorking = workerCount; var stripHeight = ~~( h / workerCount ); for(var i = 0; i < workerCount; i++){ var localImageData = ctx.getImageData(0,

d3.js visualization on android 2.3

会有一股神秘感。 提交于 2020-01-01 03:25:08
问题 I know that the android browser for 2.3 does not support SVG, but I'd like to know whether I could convert a d3.js SVG Visualization to a canvas using Canvg on clientside. Is the browser able to parse SVG elements at all, or would this transformation from SVG to Canvas need to happen server side? Thanks in advance! // Grab data from server... var btoken = window.location.search.split( 'bearer_token=')[1].split('&')[0]; var endpoint = "http://dcaps-staging.media.mit.edu:8080/api/reality

iPhone/iPad HTML5 Canvas fillText problem

99封情书 提交于 2020-01-01 03:24:10
问题 I'm having strange issues with text on a canvas when using an iPhone or iPad. Either the text gets drawn properly (rarely), or it gets drawn upside down, or it doens't get drawn at all. When the text does manage to get drawn, it is wiped when the iPhone/Pad is rotated. I have the following code. It seems that I can only get the text to stay on the page at all if I use a setTimeout. It seems to be drawn over if I call fillText as soon as the document is loaded. Anyone else experiencing this

Get color value of specific position in colorbar with gradient

喜夏-厌秋 提交于 2020-01-01 03:11:47
问题 I generated a gradient colobar with CSS3 styles (fiddle) and now want the color value of a specific location (by x and y coords) in that colorbar. As far as I know there is no direct way to do that. I see two options: Implement the gradient algorithm in JavaScript and calculate the value from scratch. Is there an exact definition how that algorithm works for multiple colors? Does the gradient look the same in every browser? Use a canvas and createLinearGradient method to draw the gradient and

9月学习笔记-前端知识碎片

安稳与你 提交于 2020-01-01 02:50:18
工作笔记-知识碎片-2019-9 1.Echarts的cursor指向无效 原因:echarts使用canvas画图,使用行内样式设定canvas的 cursor:pointer; 解决:使用样式覆盖这个行内样式比如: .echarts canvas{cursor:pointer !important;} 2.轮播图片宽高自适应问题 效果图: 宽度为自适应屏幕宽度,有最小宽度,高度不管是设为固定px或百分比都会导致图片变形或被裁剪,所以应动态设定图片高度。 html: <div class="ty-carousel"> <el-carousel ref='ctest' :height="imgHeight+'px'" :interval='5000'> <el-carousel-item v-for="(item,index) in carouselData" :key="index"> <img ref="image" :src="item.src" alt=""> </el-carousel-item> </el-carousel> </div> style: .ty-carousel{ margin-bottom: 16px; } .ty-carousel .el-carousel__item img { width: 100%; height: auto; } .ty

External Font on HTML5 Canvas

£可爱£侵袭症+ 提交于 2020-01-01 01:44:13
问题 I am completely baffled as to how to change the font I'm using when drawing text on a canvas. The following is the font I have defined in my CSS: @font-face{ font-family:"Officina"; src:url(OfficinaSansStd-Book.otf); } Now in my HTML/JavaScript I'm tempted to say: context.font = '30px "Officina"'; But this doesn't work. It works fine if I use a web available font (like Arial), and the Officina font shows up fine when I just write plain text directly to the webpage. What am I missing? 回答1: To

How can I use the multiply blend mode on a canvas in real time?

大兔子大兔子 提交于 2020-01-01 01:16:07
问题 Edit as of 2016 : The "multiply" value is implemented for globalCompositeOperation. The performance is more than sufficient for real-time graphics. Essentially, I have two canvases (one is an invisible canvas used for drawing) and I want to blend the invisible canvas onto the visible one with the multiply blend mode. Context.globalCompositeOperation does not include multiply (though it should, in my opinion) and using imageData to manually blend the canvases is too slow (I need to be able to