canvas

Rotate along Z- axis in HTML5 - Flip card

Hi All, I just came across a simple flash animation on flip card The Playing Card Effect The card has 2 images "front" image and "back" image, when clicked the card toggles with rotating along Z axis showing the front and back face accordingly. Can the same effect be achieved using HTML5 / Canvas / CSS3 ?? PS: I'm complete newbie/noob...

Specifying a WPF's databound attribute's design-time value in XAML

I'm playing around with a Canvas inside of a Viewbox, and unforunately, the only way to see the elements in the Canvas, I have to assign it a Height and Width. However, the problem is that my Height and Width values come from my ViewModel via databinding. I know that Blend gets around this with the d: designer namespace, which is set t...

JavaScript: How to get the center of a pie slice?

Hi I am trying to create a simple pie chart using the HTML canvas element. I found a nice tutorial on the web and starting to learn how it is done. Now I want to add some text and since I am pretty retarded at math/geometry I need to know how to find the center of each slice in the pie where the text can be added. Here is the loop code...

What happens in the system when canvas.drawBitmap is called?

I have a scrollable and zoomable map which has a low res copy of the map which is drawn when the zoom scale is small and a tile system when the user zooms in past a certain point. The problem im having is that the very first time the tiles are drawn there is a short, but noticable lag. After that initial lag everything is smooth. The GC ...

HTML5 Canvas Performance: Loading Images vs Drawing

I'm planning on writing a game using javascript / canvas and I just had 1 question: What kind of performance considerations should I think about in regards to loading images vs just drawing using canvas' methods. Because my game will be using very simple geometry for the art (circles, squares, lines), either method will be easy to use. I...

Canvas professional drawing effects

Recently I've been learning HTML5 stuff, especially canvas. I looked at many online drawing applications written in Flash(e.g. http://www.sumopaint.com, http://www.onemotion.com/flash/sketch-paint/) and they all seem packaged with awesome drawing effects. Smooth lines, simulated pencil/brush etc. What I'd like to know is - is there a ...

How to force a scrollbar to scroll a canvas

Hi I was wondering if there is any way to force a scrollbar to scroll a canvas. I placed canvas in scrollview and I overrode the measureoverride method. Scrollbars show when I reach the ends of visible parts of the canvas. However I would like the canvas to scroll because now, despite the fact that scrollbars show, the canvas does not f...

How to work with HTML elements underneath a canvas

I have a container of some HTML divs and with some CSS if I hover over them, the background color changes. I want to overlay a canvas on top of the container so that I can draw lines. The problem is that when the canvas is overlaid, the hovering changes of the divs no longer works. Is there a way to overlay a canvas but still have CSS or...

How to draw a filled triangle in android canvas?

So I'm drawing this triangle in android maps using the code below in my draw method: paint.setARGB(255, 153, 29, 29); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setAntiAlias(true); Path path = new Path(); path.moveTo(point1_returned.x, point1_returned.y); path.lineTo(point2_return...

JQuery Shuffle Effect using Html5 [Canvas +CSS +JS]

Hi All, I saw a JQuery Shuffle Example and I was trying to implement the same using HTML5 and Canvas + CSS + JS with images. but finding animation/drawing using Canvas bit difficult. I just had idea of creating as many canvas as images and then try to move the canvas for shuffle animation. Are there any libraries to achieve the same...

How-to create a clickable Button with a ShapeDrawable?

Hello, I'm trying to draw a shape on a Canvas and get information about the clicks that the user performs on that Canvas. I created a class which extends the Button class. class CustomDrawableButton extends Button { private final ShapeDrawable mDrawable; int x = 50; int y = 50; int width = 30; int height = 30; ...

html5 canvas clicking on bezier path shape detection

Hello, I have a canvas with some irregular shape drawings in it, and I would like to have a feedback when someone clicks on a specific one? I've been looking everywhere for this and have only found solutions for rectangle. I think it may have to do with isPointInPath(), but I've yet to find a concise explanation on how to use it. An...

How to save a canvas drawing?

I have this finger-painting app and I want my users may save what they draw and come back later and keep drawing. What's the lighter way to do this? ...

Change origin of canvas

I have to create a canvas that contains object with position in binding with latitude and longitude. My canvas support element's drag and zooming but until now I have used always standard coordinate (from 0,0) Now I have GPS coords and all objects overlap each other because GPS coord is for example between 45°11'00'N and 45°11'60N... s...

How can I determine if I will draw offscreen when doing custom bitmap blitting in a view inside a scrollview in Android

I have subclassed View and do some bitmap drawing inside of the onDraw method. This view is then placed in a horizontal scrollview. Some of the time the bitmaps will not be visible since they are scrolled off screen. To improve performance I would like to avoid drawing anything when the object will not be visible. So the question is, ho...

unable to access html5 canvas?

I'm stumling upon a weird problem: The code just wont be able to access the canvas element. Consider this code: this.canvas = document.getElementById('canvas'); this.context2D = this.canvas.getContext('2d'); Firefox would produce an error say this.canvas is null. But if I write it like this: this.canvas = $('#canvas'); this.context2D...

Drawable object where I can store points for faster paint?

I'm designing a custom view which is an X/Y Plot. It's a moving graph that scrolls to the left with time and new Y values are continuously coming in at 10 per second. I've been able to make it work with an array of integers where the array index is the X value and the integer value is the Y value, but this seems horribly inefficient (B...

Android - Any way to access an Overlay's canvas in another class?

While this may sound backwards, I have a need to draw to my Overlay in another class. I get a bitmap from the MapsView, then essentially draw it on the overlay. I am having difficulty doing this however. Here is what I am doing. First I generate a bitmap from the mapview: Bitmap bitmap = Bitmap.createBitmap(400, 800, Bit...

Resizing a HTML canvas blanks its contents

I have a HTML canvas element which is resized when the user resizes the screen. canvas.height = pageHeight(); canvas.width = pageWidth(); The actual resizing works fine, but it blanks the canvas. I would like to keep the contents. Is there another method of changing the size of a canvas element, or is there a way to store the content...

How do I clear text from the <canvas> element?

I have put text on an image in a <canvas> tag (the text was taken from an input box). Now if I put a new text on the <canvas>, it is imposed on the previous text. How do I clear the existing text on the canvas before putting in the new text? I have tried resetting the canvas by assigning canvas.width but the text stays on. Any help peo...