Skip to content
Advertisement

Tag: canvas

How to access canvas context in React

I made a color picker with React and Canvas. Currently the components are rendered in React and canvas is done with vanilla javascript. I’d like to two to mesh more, so I want the click events to be handled with React. For example, this I would hope would be able to translate to this But that doesn’t work because I

Pinch/pucker an image in canvas

How can I pinch/pucker some area of an image in canvas? I’ve made a solar system animation some time ago, and I started rewriting it. Now, I want to add gravity effect to masses. To make the effect visible, I turned the background into a grid and I’ll be modifying it. Desired effect is something like this (made in PS)

Html2canvas image capturing issue with UTF-8 characters

I want to capture my webpage, In order to this I find html2canvas, when I use as shown below ,my UTF-8 (persian) characters get in trouble and this direction destroyed as you see. HTML: JavaScript: WebPage: Captured WebPage via html2canvas: you can see full example here What is wrong with my implementation? Answer Set the box css that have trouble

HTML5 Canvas Javascript how to make smooth brush

Hello i need make smooth brush likes this: I try to create it, i make circle and fill it, but result not successful: Can be seen circles.. this is not smooth like first example my example code: http://codepen.io/anon/pen/NPjwry Answer Try with a smaller globalAlpha and decrease the stepping (so you draw more circles) Updated codepen: http://codepen.io/gpetrioli/pen/ramqBz

Converting base64 to blob in javascript

I tried to convert a JPEG’s base64 string to a blob on a Cordova/hybrid app running on iOS 8 using the following function b64toBlob. However it’s giving an error when we do How can be work around this error? Answer Try this out. Please note that dataURI is assumed to include base64 prefix. (e.g. “data:image/jpeg;base64,”) Usage:

Increase performance for 10,000 particles in HTML5 Canvas

I have two JS Fiddles, both with 10,000 snow flakes moving around but with two different approaches. The first fiddle: http://jsfiddle.net/6eypdhjp/ Uses fillRect with a 4 by 4 white square, providing roughly 60 frames per second @ 10,000 snow flakes. So I wondered if I could improve this and found a bit of information on HTML5Rocks’ website regarding canvas performance.

HTML canvas image from rgb values

I have three 12×12 arrays, each with R, G and B values. How would I go about outputting the image (12×12) using HTML Canvas? I’ve come across Canvas demos that show drawing lines and whatnot, but nothing like providing some RGB arrays to produce something. Any guidance is greatly appreciated. Answer You can use the fillRect method, described here :

Advertisement