Search Results

Search found 3347 results on 134 pages for 'html5 canvas'.

Page 5/134 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • HTML5 Canvas compositing question (source-in)

    - by Alex Ciarlillo
    I am trying to recreate a page flipping type animation in HTML5 using canvas. The animation is based on ideas from here: hxxp://oreilly.com/javascript/archive/flashhacks.html but thats not really important. The problem I am having is that using the 'source-in' composite operation is not giving me the results I expect and would like clarification as to why. Here is the example: (i think it can only be viewed in chrome, not working in FF 3.6) http://acpound.fylez.com/test/example.html The black rectangle is supposed to act as a 'mask' for the page being turned over. All I want to see is the turning page in the areas where it overlaps the mask. The problem is the entire black rectangle is drawn, not just the area where they overlap. The source is all on the page. I know HTML5 isn't really being used yet, I'm just experimenting for my personal site and curiosity. Any ideas would be greatly appreciated.

    Read the article

  • Is there a portal dedicated to HTML5 games?

    - by Bane
    Just to get something straight; by "portal", I mean a website that frequently publishes a certain type of games, has a blog, some articles, maybe some tutorials and so on. All of these things are not required (except the game publishing part, of course), for example, I consider Miniclip to be a flash game portal. The reason for defining this term is because I'm not sure if other people use it in this context. I recently (less than a year ago) got into HTML5 game development, nothing serious, just my own small projects that I didn't really show to a lot of people, and that certainly didn't end up somewhere on the web (although, I am planning to make a website for my next game). I am interested in the existence of an online portal where indie devs (or non-indie ones, doesn't really matter that much) can publish their own games, sort of like "by devs for devs", also a place where you can find some simple tutorials on basic HTML5 game development and so on... I doubt something like this exists for several reasons: You can't really commercialize an HTML5 game without a strong server-side and microtransactions The code can be easily copied HTML5 is simply new, and things need time to get their own portals somewhere... If a thing like this does not exist, I think I might get into making one some day...

    Read the article

  • Collision detection between a sprite and rectangle in canvas

    - by Andy
    I'm building a Javascript + canvas game which is essentially a platformer. I have the player all set up and he's running, jumping and falling, but I'm having trouble with the collision detection between the player and blocks (the blocks will essentially be the platforms that the player moves on). The blocks are stored in an array like this: var blockList = [[50, 400, 100, 100]]; And drawn to the canvas using this: this.draw = function() { c.fillRect(blockList[0][0], blockList[0][1], 100, 100); } I'm checking for collisions using something along these lines in the player object: this.update = function() { // Check for collitions with blocks for(var i = 0; i < blockList.length; i++) { if((player.xpos + 34) > blockList[i][0] && player.ypos > blockList[i][1]) { player.xpos = blockList[i][0] - 28; return false; } } // Other code to move the player based on keyboard input etc } The idea is if the player will collide with a block in the next game update (the game uses a main loop running at 60Htz), the function will return false and exit, thus meaning the player won't move. Unfortunately, that only works when the player hits the left side of the block, and I can't work out how to make it so the player stops if it hits any side of the block. I have the properties player.xpos and player.ypos to help here.

    Read the article

  • Flip <canvas> (rotate 180deg) after being published on page.

    - by smallmeans
    I'm trying to rotate a canvas element AFTER it's been appended to the DOM. Canvas is 600x50 and this is the code at hand: var canvas = document.getElementsByTagName('canvas')[2]; var ctx = canvas.getContext('2d'); ctx.translate(300, 25); // rotate @ center ctx.rotate(angle * Math.PI/180); which isn't accomplishing the task. Am I missing something? Thanks

    Read the article

  • Are all <canvas> tag dimensions in pixels?

    - by Simon Omega
    Are all tag dimensions in pixels? I am asking because I understood them to be. But my math is broken or I am just not grasping something here. I have been doing python mostly and just jumped back into Java Scripting. If I am just doing something stupid let me know. For a game I am writing, I wanted to have a blocky gradient. I have the following: HTML <canvas id="heir"></canvas> CSS @media screen { body { font-size: 12pt } /* Game Rendering Space */ canvas { width: 640px; height: 480px; border-style: solid; border-width: 1px; } } JavaScript (Shortened) function testDraw ( thecontext ) { var myblue = 255; thecontext.save(); // Save All Settings (Before this Function was called) for (var i = 0; i < 480; i = i + 10 ) { if (myblue.toString(16).length == 1) { thecontext.fillStyle = "#00000" + myblue.toString(16); } else { thecontext.fillStyle = "#0000" + myblue.toString(16); } thecontext.fillRect(0, i, 640, 10); myblue = myblue - 2; }; thecontext.restore(); // Restore Settings to Save Point (Removing Styles, etc...) } function main () { var targetcontext = document.getElementById(“main”).getContext("2d"); testDraw(targetcontext); } To me this should produce a series of 640w by 10h pixel bars. In Google Chrome and Fire Fox I get 15 bars. To me that means ( 480 / 15 ) is 32 pixel high bars. So I change the code to: function testDraw ( thecontext ) { var myblue = 255; thecontext.save(); // Save All Settings (Before this Function was called) for (var i = 0; i < 16; i++ ) { if (myblue.toString(16).length == 1) { thecontext.fillStyle = "#00000" + myblue.toString(16); } else { thecontext.fillStyle = "#0000" + myblue.toString(16); } thecontext.fillRect(0, (i * 10), 640, 10); myblue = myblue - 10; }; thecontext.restore(); // Restore Settings to Save Point (Removing Styles, etc...) } And get a true 32 pixel height result for comparison. Other than the fact that the first code snippet has shades of blue rendering in non-visible portions of the they are measuring 32 pixels. Now back to the Original Java Code... If I inspect the tag in Chrome it reports 640 x 480. If I inspect it in Fire Fox it reports 640 x 480. BUT! Fire Fox exports the original code to png at 300 x 150 (which is 15 rows of 10). Is it some how being resized to 640 x 480 by the CSS instead of being set to a true 640 x 480? Why, how, what? O_o I confused...

    Read the article

  • Architecture for html5 multiplayer game?

    - by Tihomir Iliev
    Hello I want to write a HTML5 multiplayer game in which there are rooms with two players answering a series of questions with 3 possible answers, 10sec/question, which are being downloaded from a server. It will have some ratings and so on. I want to make it as scalable as possible. I wonder what technologies to use to accomplish that. HTML5, CSS3 and JavaScript obviously. But what about the server-side? I have been researching and found that Socket.IO + Node.js + mongoDB would do the job but after doing some more research it maybe not. Can you suggest me some kind of architecture for doing this game? Free technologies, if possible. Or what to read and from where to start in order to understand how to do it. Thanx in advance! P.S. I have an experience with HTML5, CSS3, JavaScript, C#, ASP.NET MVC and relational db's.

    Read the article

  • Pixel Perfect Collision Detection in HTML5 Canvas

    - by Armin Ronacher
    Hi, I want to check a collision between two Sprites in HTML5 canvas. So for the sake of the discussion, let's assume that both sprites are IMG objects and a collision means that the alpha channel is not 0. Now both of these sprites can have a rotation around the object's center but no other transformation in case this makes this any easier. Now the obvious solution I came up with would be this: calculate the transformation matrix for both figure out a rough estimation of the area where the code should test (like offset of both + calculated extra space for the rotation) for all the pixels in the intersecting rectangle, transform the coordinate and test the image at the calculated position (rounded to nearest neighbor) for the alpha channel. Then abort on first hit. The problem I see with that is that a) there are no matrix classes in JavaScript which means I have to do that in JavaScript which could be quite slow, I have to test for collisions every frame which makes this pretty expensive. Furthermore I have to replicate something I already have to do on drawing (or what canvas does for me, setting up the matrices). I wonder if I'm missing anything here and if there is an easier solution for collision detection.

    Read the article

  • HTML5 Canvas and Game Programming

    - by LemonBeagle
    I hope this isn't too open ended. I'm wondering if there is a better (more battery-friendly) way of doing this -- I have a small HTML 5 game, drawn in a canvas (let's say 500x500). I have some objects whose positions I update every 50ms or so. My current implementation re-draws the entire canvas every 50ms. I can't imagine that being very good for battery life on mobile platforms. Is there a better way to do this? This must be a common pattern with games. EDIT: as requested, here are some more updates: Right now, the objects are geometric primitives drawn via arcs and lines. I'm not opposed to making these small png/jpg/gif files instead of that'd help out. These are small graphics -- just 15x15 or so. As the game progresses, more and more of the screen changes at a time. However, at the start, the screen changes relatively slowly (the objects randomly moved a few pixels every 50ms).

    Read the article

  • HTML5 Canvas: How to make a loading spinner by rotating the image in degrees?

    - by Bill
    I am making a loading spinner with html5 canvas. I have my graphic on the canvas but when i rotate it the image rotates off the canvas. How do I tell it to spin the graphic on its center point? <!DOCTYPE html> <html> <head> <title>Canvas test</title> <script type="text/javascript"> window.onload = function() { var drawingCanvas = document.getElementById('myDrawing'); // Check the element is in the DOM and the browser supports canvas if(drawingCanvas && drawingCanvas.getContext) { // Initaliase a 2-dimensional drawing context var context = drawingCanvas.getContext('2d'); //Load the image object in JS, then apply to canvas onload var myImage = new Image(); myImage.onload = function() { context.drawImage(myImage, 0, 0, 27, 27); } myImage.src = "img/loading.png"; context.rotate(45); } } </script> </head> <body> <canvas id="myDrawing" width="27" height="27"> </canvas> </body> </html>

    Read the article

  • My HTML5 web app crashes and I have no clue how to debug

    - by Shouvik
    Hi All, I have written a word game using HTML5 canvas tag and a little bit of audio. I developed the application on the chrome web browser on a linux system. Recently during the testing phase it was tried on safari 5.0.3 on Mac and the webpage froze. Not just the canvas element, but interactive element on the page froze. I have at some times experienced this problem on google chrome when I was developing but since the console did not throw any error before this happened, I did not give it much credence. Now as per requirements I am supposed to support both chrome and safari but this dismal performance on safari has left me shocked and I cannot see what error can be thrown which might lead to such a situation. Worse yet the CPU usage on using this application peaks to 70-80percent on my 2yr old macbook running ubuntu... I can only but pity the person who uses mac to operate this app, which undoubtedly is a heavier OS. Could someone help me out with a place I can start with to find out what exactly is causing this issue. I have run profiles on this webapp on google chromes console and noticed that in the heap spanshot value increases steadily with the playing of the game, specifically (root) value which jumps up by 900 counts. Any help would be very appreciated! Thanks EDIT: I don't know if this helps, but I have noticed that even on refreshing the page after the app becomes unresponsive the page reloads and I am still not able to interact with the page elements but the tab scroll bar continues to work and I can see my application window completely. So to summaries the tab stops accepting any sort of user interaction inside the page. Edit2: Nop. It doesn't work still... The app crashes on double click on the canvas element. The console is not throwing any errors either! =/ I have noticed this problem is isolated only to safari!

    Read the article

  • How to run setInterval() on multiple canvases simultaneously?

    - by Alex
    I have a page which has several <canvas> elements. I am passing the canvas ID and an array of data to a function which then grabs the canvas info and passes the data onto a draw() function which in turn processes the given data and draws the results onto the canvas. So far, so good. Example data arrays; $(function() { setup($("#canvas-1"), [[110,110,100], [180,180,50], [220,280,80]]); setup($("#canvas-2"), [[110,110,100], [180,180,50], [220,280,80]]); }); setup function; function setup(canvas, data) { ctx = canvas[0].getContext('2d'); var i = data.length; var dimensions = { w : canvas.innerWidth(), h : canvas.innerHeight() }; draw(dimensions, data, i); } This works perfectly. draw() runs and each canvas is populated. However - I need to animate the canvas. As soon as I replace line 8 of the above example; draw(dimensions, data, i); with setInterval( function() { draw(dimensions, data, i); }, 33 ); It stops working and only draws the last canvas (with the others remaining blank). I'm new to both javascript and canvas so sorry if this is an obvious one, still feeling my way around. Guidance in the right direction much appreciated! Thanks.

    Read the article

  • How to save HTML5 canvas?

    - by bebraw
    Currently I am using Canvas2Image to save the content of my HTML5 canvas. It doesn't appear to work in Google Chrome, however. Any ideas on how to work around the issue are welcome. :)

    Read the article

  • Resizing canvas, where's the problem?

    - by Noor
    I'll post a link since theres to much to post here: http://hem.bredband.net/noor/canvas.htm My goal is to make the picture fit inside the window with the width of the image being the same as the window, even after resize. If the pictures height becomes to big for the window then the picture should resize itself according to the height and not the width. Somewhere along my code there is something wrong.. forgive me if this is stupid, i am still learning.. Thanks!

    Read the article

  • ASP.net canvas server control

    - by Pierreten
    I was wondering if anyone has come up with an ASP.net server tag for the HTML5 canvas? I was thinking of something where I could declaritively define paths, curves; etc in the aspx markup, and the control would deliver the js to do this (perhaps with support for browser detection, and delivery of an emulation script for IE browsers.) Maybe a good idea for a Codeplex project for me to start up?

    Read the article

  • [Tkinter/Python] Different line widths with canvas.create_line?

    - by Sam
    Does anyone have any idea why I get different line widths on the canvas in the following example? from Tkinter import * bigBoxSize = 150 class cFrame(Frame): def __init__(self, master, cwidth=450, cheight=450): Frame.__init__(self, master, relief=RAISED, height=550, width=600, bg = "grey") self.canvasWidth = cwidth self.canvasHeight = cheight self.canvas = Canvas(self, bg="white", width=cwidth, height=cheight, border =0) self.drawGridLines() self.canvas.pack(side=TOP, pady=20, padx=20) def drawGridLines(self, linewidth = 10): self.canvas.create_line(0, 0, self.canvasWidth, 0, width= linewidth ) self.canvas.create_line(0, 0, 0, self.canvasHeight, width= linewidth ) self.canvas.create_line(0, self.canvasHeight, self.canvasWidth + 2, self.canvasHeight, width= linewidth ) self.canvas.create_line(self.canvasWidth, self.canvasHeight, self.canvasWidth, 1, width= linewidth ) self.canvas.create_line(0, bigBoxSize, self.canvasWidth, bigBoxSize, width= linewidth ) self.canvas.create_line(0, bigBoxSize * 2, self.canvasWidth, bigBoxSize * 2, width= linewidth) root = Tk() C = cFrame(root) C.pack() root.mainloop() It's really frustrating me as I have no idea what's happening. If anyone can help me out then that'd be fantastic. Thanks!

    Read the article

  • current transform being applied by canvas

    - by Allain Lalonde
    How can I determine the current transform that's being applied by an html5 canvas. It seems that it only supports two methods for dealing with transforms "transform", "setTransform" but I can't seem to discover the results of applying the transforms. Short of tracking them all myself and duplicating the the matrix mathematics that it must be doing natively, how can I figure out the current transform?

    Read the article

  • HTML 5 Canvas performance

    - by Vilius
    Hello there! I'm just started on playing around with the canvas HTML5-object. For the sake of performance tests, I have made a little ping pong game (http://bit.ly/arTPut). Apart from my quick'n'dirty programming skills, I believe, that there are also some performance boosts, I haven't used. Especially, the ball seams to be blue with a little red-touch, but by my decleration it should be yellow. Would be very nice, if someone could help me! Greetings, Vilius

    Read the article

  • dotted stroke in <canvas>

    - by Sam
    I guess it is not possible to set stroke property such as CSS which is quite easy. With CSS we have dashed, dotted, solid but on canvas when drawing lines/or strokes this doesn't seem to be an option. How have you implemented this? I've seen some examples but they are really long for such a silly function. For example: http://groups.google.com/group/javascript-information-visualization-toolkit/browse_thread/thread/22000c0d0a1c54f9?pli=1

    Read the article

  • HTML Canvas and saving the data on the server

    - by snitko
    Say I've written a simple app that draws circles in browser. Now I'd like to let people save their pictures. How would I store the data on the server? Which format would be the best option? Should I simply store the relevant html? What would be the case when I would want to make a custom format that is stored on the server and parsed back to html canvas when loaded?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >