Search the Community
Showing results for tags 'canvas'.
-
Hi, I am a beginner so not sure if this should be placed here or in CSS? Based on this example: http://jsfiddle.net/pmw57/as4UR/ ,have a canvas element, 640X640. How do you center this canvas so it appears in the middle of the screen? Currently it is displaying 0,0. Thank you for your help. writer1
- 2 replies
-
- JavaScript
- CSS
-
(and 2 more)
Tagged with:
-
I seem to have gotten in over my head with this project. I spent most of the day just typing out code, without the ability to debug it due to slow browser speed. When I got off work I started correcting my syntax errors, which didn't take very long. Unfortunately, I have spent many hours trying to resolve some sort of logic error in the game which is apparently a very serious one, as it prevents any of my sprites from appearing. The fillRect() function is showing up perfectly, but the drawImage() function is not. I will go ahead and post the whole game code, as it is pretty concise by my own meager standards. I am a noob to javascript and coding in general, and this will probably show. That being said, I really expected this to work, and would certainly appreciate any help which is on offer. Upon previewing my post I noticed that spacing differences rendered my map array unreadable. I have decided to attach a text file (as I am not permitted to upload .js files) instead of pasting. I hope this is acceptable. script.txt
- 5 replies
-
- logic error
- canvas
-
(and 4 more)
Tagged with:
-
I am having problems using the "<canvas>" tag as I am using HTML code from your website. http://www.w3schools...tml5_canvas.asp - Canvas Coordinates. Now, I have a piece of code that I have to find the "<canvas>" tag to add. In the code, I found out that a div creates the canvas. But how would I add an image that bounces across the screen when the mouse is over the canvas. I already have the co-ordinates of the mouse and the image inserted. I have attached the .html file and an image a.png. This should create an object and show you the co-ordinates of the mouse when it is over the canvas. And when it is not, it does not show any co-ordinates and shows a heading of PAUSED.index.htmlMany Thanks,[EDIT] Please could someone reply and post some code for this problem. I am only new to HTML. There is Javascript in there but that was in the canvas code here:-http://www.w3schools.com/html/html5_canvas.asp [/EDIT]Additional:-This doen't work in Internet Explorer 10 - well it didn't when I tried.
-
Hi, I need to draw arrows to make links between elements of a table to make a kind of "route".I used canvas to do this and the result is exactly what I want graphically. However, I need to do actions on the table (like editing a cell by doubleclicking on it) but the canvas has got a z-index higher than my table to be visible so I can't access my table cells. Anyone has got an idea ? Thanks in advance. Matthieu.
-
Hello,I want to make a script to check if there is anything drawn on a canvas.I tried to use this script: [/font][font=arial,helvetica,sans-serif]var ctx = document.getElementById("canvas").getContext("2d");[/font][font=arial,helvetica,sans-serif]/* Some other code, including some drawing code[/font][font=arial,helvetica,sans-serif]All drawings are black, with alpha value 255 */[/font] [font=arial,helvetica,sans-serif]var a = ctx.[color=#000000][size=1]getImageData(0,0,room.width,room.height)[/size][/color].data.indexOf(255); // to see if anything is drawn[/font][font=arial,helvetica,sans-serif] But for some reason it didn't work.I have also tested some other array methods, but they didn't work either on the imageData.dataIs there some way to make this work?Using a for loop instead would probably be to slow. Michiel
-
Hi I'm a little new to JavaScript and I am trying to make a small program using an HTML5 canvas. However, when the following code is executed:function Prog(){ var self = this; this.init = function() { var d = document; self.canvas = d.getElementById("can"); self.c = self.canvas.getContext("2d");...}var p = new Prog();p.init();The code works in the other major browsers, but in opera, it throws an error saying "cannot convert self.canvas to object" or sometimes just "self.canvas is null"Thanks in advance
- 3 replies
-
- Opera
- Javascript
-
(and 2 more)
Tagged with:
-
I've been enthusiastically reading a lot of w3schools' tutorials and reference pages on HTML, which is a very big step in the right direction for HTML. Alright, so far so good. The <canvas> and <video> tags are amazing, and things like the technique used here is very exciting: http://www.w3schools...drawimage_video However, I've run into a bit of a show-stopper: the example above, and any similar ones I've been able to find, does not work on mobile devices - even ones that support both <video> and <canvas> by themselves. I haven't tried it on any iOS devices, but web searches indicate they would have the same issues. I've attached a screenshot of how the above example looks on an Asus TF300 tablet (Android 4.0.3). Am I the only one running into these issues, or has anyone else experienced similar problems? If so, were you able to solve it - and how? Regards, Mikkel