canvas

How do I rotate a canvas without disturbing the coordinate system in Android?

I am trying to rotate a canvas with canvas.rotate and move an object on it at the same time. The problem is that with the rotation, the coordinate system of the canvas rotates as well, so I get cases when my object is supposed to be moving along the y axis, but the y axis is rotated on place of the x axis. It is a mess. Is there a way to...

Issue with scrollviewer and canvas

I have a custom canvas control which sits inside a scrollviewer - I have implemented drag, drop and move for items on the canvas and overridden MeasureOverride so that when I move an item around on the canvas its size reflects the changes so if I move the item beyond the visible portion of the canvas it will resize to accomodate the move...

Silverlight - Creating a canvas with auto-alignment and scale

Hello How can i create a canvas of this kind - http://www.silverdiagram.net/Projects/SilverDiagram/SilverDiagram_Demo.aspx? I want to position the controls exactly aligned to each other. I want to help users to align it properly using auto-alignment (like visual studio) and by providing user the scale. ...

mathematics for drawing little lines around circle

I have to draw lines around a circle (like in clock). How can i achieve this using a for loop? ...

rotating an arrow in canvas

I want to rotate the arrow to any given angle. What i need to add/modify so that it can be rotated to any angle. Currently its on 180 degree. function drawArrowAtAngle(cx,cy,angle,context){ context.save(); context.beginPath(); context.lineWidth = 1; context.strokeStyle = '#aaa'; context.moveTo(cx+25,cx-2); context.lineTo(cx-...

How do i change the color multiplier of a lightingColorFilter instance

Based on the doc, http://developer.android.com/reference/android/graphics/LightingColorFilter.html it seems like the LightingColorFilter class only has a constructor. (Same to its parent class, ColorFilter) How do i keep only ONE instance of LightingColorFilter while having the flexibility to modify the color properties for that filt...

iphone/ipad large canvas vs small canvas + div animation

Since I dont have either of these devices handy to test, which method would be faster on an iphone/ipad? One large canvas (overlayed over a bg of the same size), that is cleared, and has new pixel data drawn to it each frame, at a certain position or A small canvas that updates each frame, contained in a div that is animated across a ...

canvas data out of range? problem in FF

I run this code every frame, works great in chrome data[index + 0] = bgData[dis + 0]; data[index + 1] = bgData[dis + 1]; data[index + 2] = bgData[dis + 2]; data[index + 3] = 255; but firefox gives the error: An invalid or illegal string was specified" code: "12 unless I add -1 to each line as below: data[index + 0] = bgData[di...

Drawing a circle on the canvas using mouse events

I am trying to draw a circle using mouse on the canvas using mouse events, but it does not draw anything: tools.circle = function () { var tool = this; this.started = false; this.mousedown = function (ev) { tool.started = true; tool.x0 = ev._x; tool.y0 = ev._y; ctx.moveTo(tool.x0,tool.y0); }; this.mousemove = function (ev) { var center...

js render loop that breaks once a condition is met

How do I set up a setInterval render loop that breaks, once a condition is met? ...

Android: can I create a view/canvas that is not rectangular, but e.g. round?

I have a view that is round and hovering above (-> in z-axis direction coming out of the screen) the main content. When the someone taps the screen I want either the main content to be selected or the view hovering above, when it covers the main view. So far that works perfectly. I have a round shaped item on a transparent canvas. Meani...

drawing part of a bitmap on an Android canvas

How can you blit a non-rectangular (e.g. oval) part of a bitmap into a canvas on Android? Consider how you'd blit a rectangular part of a bitmap: canvas.DrawBitmap(src,src_rect,dest_rect,paint). Sadly there is no corresponding methods for non-rectangular regions. Four approaches present themselves (maybe you know a fifth?): copy the...

Canvas versus SVG animations (effects[filters] and performance)

I am developing an application that should run equally smoothly on a web browser (IE support completely optional) and on iPhones and have tested various libraries for days, including: jQuery SVG, CAKE (Canvas Animation Kit Experiment), Burst Engine, Processing.js and Raphael, and have yet to find the right one for this experiment. The ...

How to implement sineWaveTo squareWaveTo and sawWaveTo lines in html5 canvas 2d context?

I would like to try an implement these so that they can be used in a manner similar to lineTo(). Starting from the current point, given the ending coordinates the functions would draw either a square, saw, or sine line all the way to the the ending coordinates. I dont know if we can factor in both Amplitude AND Frequency because I guess...

Mode7-like perspective transform in canvas?

I'm making a canvas-based game engine and am wondering if anyone has any good info on how to achieve an overhead view perspective. What I'm looking for is somewhere halfway between the traditional birds eye view and the old SNES mode7 view. Just a slight angle to give the illusion of 3D. I'm trying to figure out what is going to be the ...

canvas drawImage doesn't draw images the first time

I'm working on a simple JavaScript game using HTML5 canvas. It's a very typical game-loop setup involving: init() function that initializes objects to be used the playfield, randomizing some start x/y positions and similar setup tasks draw() function that draws all the game objects, including some simple canvas shapes and a few images ...

WPF Programatically scrolling a canvas in a items control

I have an ItemsControl that contains a canvas within a ScrollViewer. The canvas is large and only a portion of it displays at a time. I want to programatically scroll it (the user clicks and drags the canvas to scroll). I looked through the ScrollViewer methods and tried the following in the mouse event handlers: var scrollViewer = (sen...

want to copy from one canvas to another

I want to copy the image drawn in one canvas (details) into another canvas. The commonly discussed solution of using bitmaps will not work because the Bitmap class does not have many of the important methods belonging to the Canvas class. Are there any other solutions? ...

How can I make my GUI Frame larger?

The problem is, I am unable to make it a dimension with 800x600. In other words, when I run the program, the frame is so small that I can not do anything with it. How can I make the frame larger? I have set the preferred size already ans set the canvas bounds. Then what is the problem? public class GameCanvas extends Canvas { pri...

Blur the layer underneath

Hey! I have a SlidingDrawer in my application. When it opens, I want everything underneath it to be blurred. Anyway I can do this? Thanks. ...