canvas

Canvas.drawText(...) does not print linebreak

Hi all I tried to write some text on a surface view I created. It works fine, if title is false, and there is no linebreak added to the text. But if I add a title and therefore a linebreak, the linebreak isn't printed as expected, but instead there is this symbol [] printed. Any hints why? @Override public void drawObject() { String t...

Javascript Speed - Chrome v Firefox

I wrote this small game at http://amarnus.me/games/dodge. Now if you trying playing the game in both Firefox and Chrome, you would clearly notice that it is significantly slower in Firefox. You can call it an unintentional cheat code, yes. ;-) So my question is - Is this because of a slower Javascript engine in Firefox when compared to ...

Change canvas gradient object's properties.

var i = 0; var x = 960; var y = 540; var interval = window.setInterval(render, 100); function render() { gradient = cxt.createRadialGradient(x, y, i, x, y, i+10); gradient.addColorStop(0, "rgba(0,0,0,0)");//white inside gradient.addColorStop(.4, "rgba(255,255,255,1)");//white inside gradient.addColorStop(.6, "rgba(255,255,255,1)");//...

Silverlight scrollviewer for entire page not working

I have two pages with scrollviewers on them. One works fine, the other doesn't work at all and I don't know why. I'm hoping someone can help me understand what the second doesn't work. The first is this: <UserControl x:Class="DVCMaker.ViewPendingDVC" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http...

Drawing rotated text on a HTML5 canvas

Part of a web application I'm developing requires me to create bar graphs to display various information. I figured, if the user's browser is capable, I would draw them using the HTML5 canvas element. I have no problem drawing lines and bars for my graphs, but when it comes to labeling the axes, the bars, or the lines I ran into a snag. ...

How can I change the background of a Canvas in WPF during runtime?

My scenario is the following. I am creating a little math quiz application for my son and wanted to dynamically change the background ImageBrush of my canvas after each question is answered. I proceeded to embed my images (pngs) into a resource file and figured I would load them into an array and then randomly choose one and load it into...

Android - Animating Layers in Canvas

I'm trying to get to grips with using 'Canvas' in Android. I'm using SDK 1.5. I've been able to rotate text, but the background gets rotated as well. Ideally, I'd like to be able to put my background image on one layer and rotate text (or zoom text) on a second layer. How would I go about creating different layers on the Canvas? And ...

Is there an equivalent of canvas's toDataURL method for SVG?

I am trying to load an svg image into canvas for pixel manipulation I need a method like toDataURL or getImageData for svg on Chrome/Safari I can try doing it through and image and canvas var img = new Image() img.onload = function(){ ctx.drawImage(img,0,0) //this correctly draws the svg image to the canvas! however... var dataURL ...

HTML5 canvas: find out if click co-ordinates are inside a given rectangle

Hi All, May be some one has had similar experiences on this dilemma and can help me out here... Basically, I have a canvas element on which I draw several rectangles in a loop using context.fillRect (x, y, width, height) Now, I want some of the rectangles to be hotspots and respond to click events. I can find out the exact (x,y) of...

Is Flash becoming a dying web technology? (long-term)

I'd like to see what your thoughts are regarding Flash and it's purpose in the future. We all know what some of the pros and cons are for using Flash but with HTML5 growing rapidly, I can see Flash becoming less useful (perhaps even obsolete) unless new features are added to it. Take for example complex animation, fancy fonts, dynamic ...

How do I paint clouds?

I need an algorithm to paint clouds, or cloud like shapes. Obviously, I wouldn't want them all to be similar. What should I use to generate the relevant series of X,Y coordinates to paint the clouds? I am going to implement this either in SVG or Canvas ...

Creating canvas objects at a higher DPI than screen?

I've got a canvas object that I need to be able to create at a higher resolution than what native screen resolution is. I'm using the Flot graphs library, and I'd need to output a graph that looks just as good when it's printed as when it's displayed on screen. The only method I can think of is making the canvas size 3x larger, then sca...

On the fly bitmap editing in Android

I'm creating a scene for a game. There's a background which is a bitmap and player objects. I want to have the player objects to be able to "eat" away at the background with a transparent color as they move around the board. Basically if an object is at a certain point a circle around that object is alpha'ed out of the bitmap. The edits...

Anti Aliasing after rotating context&drawing image with canvas

After rotating a canvas context then drawing an image on it, I find out that the edges of the image becomes jagged.. like so: picture. Is there a way to enable anti aliasing so the edges look more smooth?? ...

Strange HTML5 Canvas drawImage behaviour.

I am writing some code that uses HTML5 canvas. Genereally it works well, but now I found a very strange behaviour. The weird thing is that it is consistent on different browsers, so must be that I understood the thing wrong... despite this the docs seem to say exactly what I do. Here is the code (it's an object method): MyCanvas.prot...

HTML5 Canvas image compositing problem

Consider the following code (includes jQuery): <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript" src = "js/jquery-1.4.2.js"></script> <s...

javascript video canvas

I am testing out canvas and video and I have read up on alot of examples, but I am running into a slight problem when I press the play button on the video canvas doesn't play the video as well it just shows a snapshot. I can not figure out why it doesn't play simultaneously. Here is my code in javascript. function draw() { var ctx3 = d...

Clipboard.SetImage with WPF canvas leaves clipboard empty for large images

I'm rendering a WPF canvas to an image and sticking it on the clipboard. If the canvas is small (< 900px square) it all works fine. I have a larger canvas (3000+px square) and the clipboard is empty (paste option disabled in photoshop/word etc) var transform = canvas.LayoutTransform; canvas.LayoutTransform = null; var size = new Size...

Flex/Actionscript - capturing canvas bitmap with dynamically placed elements.

I'm attempting to find overlap between elements on a flex canvas, an adaptation of http://www.gskinner.com/blog/archives/2005/08/flash_8_shape_b.html The attempt here is to place some text and figure overlap with previously placed text. The simple example below illustrates the problem. Both ImageSnapshot.captureBitmapData(canvas); o...

Fail on setting attribute for canvas from Javascript

Hi all, I have to set the attributes 'width' and 'height' for a canvas element, depending on the available screen resolution. Setting them statically from html works (ex. <canvas id="canv" width="1600" ... ). From Javascript I can't do it. I've googled and searched in SO but I didn't find anything that works. I am using JQuery and I've t...