canvas

How do I make an object change it's direction smoothly?

I have a simple Javascript program that displays a small rectangle in a canvas. The rectangle moves towards the mouse position. When it changes direction, it does so with sharp corners. As in, if the rectangle left a line behind, when I move my mouse in a circle, the rectangle would draw a tilted square. What I'd want to happen, is that...

canvas.getImageData: "Uncaught Error: SECURITY_ERR: DOM Exception 18"

Hi, I've read that it is not possible to use getImageData on an image loaded from a different domain. Any trick to overcome this? Thanks ...

How to convert a block of rendered HTML code or a div into a PNG?

A few notes: a) not an entire page, b) not from server side. c) rendered or "treated" HTML, for instance, <table> <tr><td width="5%"> <td>fact 1 </td> fact 2 </td> </tr> </table> desired results (for the PNG): fact 1 fact 2 fact 3 fact 4 ... not fact 1 fact 2 fact 3 fact 4 ... The <code> "sign"nbsp; </code> may ...

How to load a HTML file into canvas?

Hi, I know we can load an image into a canvas but I wonder if we are able to load a simple HTML file into a canvas. If yes, how? Thanks. ...

Vertical scroll bar on canvas in j2me

Hi all, I want to draw vertical scrollbar on canvas in j2me i'm going to develop application in j2me ...but how i can add vertical scrollbar on canvas in j2me so i can put lots of data on canvas ... ...

How to circumvent the infamous "unterminated string literal" problem

Hi, I attempted to load a simple HTML file into a canvas (browser = ff 3.66). var canvas= document.getElementById('oneElement'); var ctx= canvas.getContext('2d'); var img= new Image(); ctx.drawImage(img, 0, 0, img.width, img.height); img.src = 'data:text/html,&lt;table&gt;&lt;tr&gt;&lt;td&gt;data 1&lt;td&gt;data 2&lt;/td&gt;&lt;/tr&gt...

image.Onload does not complete the image.

This is driving me crazy. I need to load an array of images in Javascript, but I want to make sure that all the images are loaded before starting drawing them. So, I busy-wait for every image onLoad event to be called. First I create images and set their source and onload function: // Load images from names for (i = 0; i < this.nImages...

How to print to pdf using php with a canvas element

I'm trying to make an on-the-fly PDF generator using PHP, but I'm having one problem so far in that the pages I am trying to generate as a PDF have a bar graph generated by flot using a canvas. Does anyone have experience with this or know how to get canvas to print to pdf? I'm also open to the idea of simply having my client load a p...

how to change dimensions of html5 canvas without it scaling content

I init my canvas like this: <canvas id="canvasDiv" width="20" height="20"></canvas> and somewhere in the code I want to resize it to it's final size: var canvas = document.getElementById("canvasDiv"); canvas.style.width = 200; canvas.style.height = 100; However, any pixel I plot on my canvas is scaled (so it's not 1 pixel anymore)....

How to optimize JS canvas drawing?

Hi, My impl of fillRect much (> 3 times) slower than context2d.fillRect. How I can optimize my code or why builtin fillRect faster (some app acceleration?)? My impl: __fillRect : function (data, x, y)//, r, g, b) { var w = this.__width * 4; var idx = x * 4+ y * w; var idx_1 = idx + 4; var idx_2 = idx + 8; var ...

WPF - Drawing image to canvas and erasing and redrawing repeatedly

I currently have a canvas with an image background in a WPF application. Above this canvas, I have a slider control. I need to, as users slide the value of the slider back and forth, draw a red line straight down across the canvas. I need to do this every time the slider value is changed such that the red line is always aligned with t...

How to draw a quadratic curved line between two text objects within a HTML5 canvas?

Hi, Goal per subject. code snip: var canvas= document.getElementById('myCanvas'); var ctx= canvas.getContext('2d'); canvas.width= 520; canvas.height= 405; ctx.font = "15pt Verdana"; ctx.lineWidth = 1; // text 1 ctx.fillText("me and my dog puddie", 210, 90); // text 2 ctx.fillText("you and many ...

Generate c# image object with canvas todataurl

Hi How can i make a Bitmap or Image object with the code generated by canvas.toimageurl() method? The string looks like this: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQA... ...

Nearest Neighbor rendering in Canvas

I have a sprite that animates using a sprite sheet. He is only 16x16, but I want to scale him up to around 64x64 in all its pixel-y goodness! The results are terrible, of course the browser is anti aliasing it. :/ Thanks! ...

Simple HTML5 canvas and jquery question

The following code won't load the green rectangle in the canvas. This is my very first time trying out jquery (either it sucks or me sucks), why such a simple thing is not working, I'm buffled. browser = ff3.6. thanks Playing with jquery because there's another jquery driven piece of code that could be quite useful... <html> <head>...

getDataURL for part of the canvas object

I am building a firefox plugin which allows users to draw any arbitrary figure on an object and save it as an image (png file). var $ = getJQueryOb(); var canvas = '<canvas id="canvas" width="1024" height="1024" style="position:absolute; top:0px; left:0px;"></canvas>'; var currentWindow = Components.classes["@mozilla.org/appshell/window...

Convert PictureStream to HTML5 canvas

I am retrieving a byte array of a pictureStream from a .net webservice. the JSON byte array response looks like this: [137, 80, 78, 372, 617 more...] I am trying to convert this byte array and draw it into an HTML canvas like this var context = document.getElementById('boxcover').getContext('2d'); context.putImageData(movies.PictureS...

Find control position on canvas

I have a canvas which contains a few textblocks and I need to find the top, left corner points that I assigned them in xaml. How can I get those two properties? When I loop through the framework elements on the canvas I can't seem to find those to properties listed. ...

How to use mouse event instead of keycode for HTML5 canvas and jquery?

Hi, I'd to like to replace the following event management from keycode to mouse. How do I go about doing it? Many thanks. supported browser for now = FF 3.6x. // this block of code needs to be replaced $(document).keydown(function(e) { //console.log(e.keyCode); switch(e.keyCode) { case 38: // down draw(x,y--); break; case 40: // u...

HTML5 canvas challenge!

Hi all you geniuses, q1: is it possible to have an invisible rectangle? q2: is it possible to call method upon method? See below. var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); ctx.fillStyle = ""; ctx.strokeStyle = ""; // as far FF 3.67 goes, no way // the goal is to fill the rectangle with some t...