Skip to content
Advertisement

Tag: canvas

Use HTML5 to resize an image before upload

I have found a few different posts and even questions on stackoverflow answering this question. I am basically implementing this same thing as this post. So here is my issue. When I upload the photo, I also need to submit the rest of the form. Here is my html: Previously, I did not need to resize the image, so my

javascript canvas doesn’t draw images

I’m developing hybrid javascript app for android using cordova. In the following code I use two ways of drawing image on canvas: with setTimeout and without. Following code (wrapped with cordova) on android device doesn’t react on func1 but does react on func2. The second click on func1 finally draws image on a canvas. Which is completely strange. I assume

Print canvas contents

http://jsfiddle.net/vpetrychuk/LWup5/. As you can see text in the canvas displays ok, but after clicking “Print” button (and saving page as PDF) output image becomes ugly. Any chance to print the canvas contents without blur? Answer You need to make the actual canvas at print size then scale it on screen using CSS rules. The browser will always use the internal

Custom linear congruential generator in JavaScript

I am trying to create a custom linear congruential generator (LCQ) in JavaScript (the one used in glibc). Its properties as it’s stated on Wikipedia are: m=2^31 , a=1103515245 , c=12345. Now I am getting next seed value with Although the generator seems to work, but when the numbers are tested on canvas: They seem to be horribly biased: http://jsfiddle.net/7VmR9/3/show/

Canvas clip image with two quadraticCurves

I just wanted to clip image in a curve .. but not happening this.. Only image is showing and but not with clip. Answer You have to move everything from the line context.save(); to context.clip(); inside the function object of your imgObj’s onload handler: See http://jsfiddle.net/CSkP6/1/ for an example.

execute javascript from textarea

I’m not entirely sure if this is possible, but I’m trying to create a mini faux editor in a browser that runs javascript on the page. Here’s what I’ve been trying to do in theory HTML javascript more specifically I’m trying to write to a canvas element via the ‘code’ I type into the text area, so that if, for

HTML5, canvas, and strokeRect: some lines too narrow and blurry

A stupid simple canvas usage: Yields a rectangle with narrower lines along top and left: Why does this happen? Do I need to offset with padding? It’s annoying. Answer 2 things. First, odd lineWidths (1, 3, 5, …) will never apply cleanly with drawn on integer pixel values. This is because X and Y refer to the space between pixels

Advertisement