Drawing On Multiple Canvas Elements?
Oct 21, 2009
I'm having a problem with the <CANVAS> element in JavaScript. here's what i'm trying to do: I need 3 different canvas elements for writing a signature to. they must all 3 be visible at the same time
My problem that i'm having is that i can't seem to get the code to work which will write to more than one canvas.
[Code]...
View 2 Replies
ADVERTISEMENT
Mar 21, 2010
I am trying to create an Asteroids type game using JavaScript along with html5's canvas element for drawing. I have searched around and have looked at examples but I can't figure out what is wrong with my rendering that I do in the game loop that is run every frame. The problem appears to be only that the canvas is not cleared at the beginning of each frame but I feel there might be something wrong also. The code used and shown below only works in Firefox but not Google Chrome or Safari.
[Code]...
View 2 Replies
View Related
Dec 27, 2010
This is a question concerning the SVG plug in,Here is the code
<html>
<head>
<script language="javascript" type="text/javascript" src="jquery.js"></script>[code].....
1.SVG isn't drawing the circle
2. var svg is undefined keeps popping up.
View 2 Replies
View Related
Oct 21, 2011
I've coded in Java before but I'm still having some trouble. I am trying to draw a ribbon type shape on an <canvas> element and for some reason, when I turned it into a function, it seemed not to work. Here is what I have for drawing the ribbon with a function:
function drawRibbon(height,width,Canvas){
var c=document.getElementById(Canvas);
var cxt=c.getContext("2d");
cxt.fillStyle="#bb0044";
cxt.beginPath();
cxt.moveTo(0,0);
cxt.lineTo(0,height-50);
cxt.lineTo((width-20)/2,height-100);
cxt.lineTo((width-20),height-50);
cxt.lineTo(width-20,0);
cxt.shadowOffsetX = 5;
cxt.shadowOffsetY = 10;
cxt.shadowBlur=10;
cxt.shadowColor = "black";
cxt.fill();
cxt.shadowOffsetX = 0;
cxt.shadowOffsetY = 0;
cxt.shadowBlur=0;
cxt.closePath();
cxt.beginPath();
cxt.strokeStyle = "#ffcc22";
for (i=5;i <= 135; i=i+15){
cxt.moveTo(5,i);
cxt.lineTo(5,i+5);
cxt.stroke();
}}
drawRibbon(200,120,navCanvas);
I feel like it has something either to do with the function definition, or the call. Before this script is executed, i create a canvas in the following way:
<canvas id="navCanvas" height="200" width="120">
Why it is not displaying.
View 3 Replies
View Related
Apr 7, 2009
Before the canvas tag you had to write a script to make a gradient for html element backgrounds. Now you can use canvas and it's as easy as ... well messing with canvas. I have this script. At one point I had the gradient img objects resizing so the gradient would not get skewed. it was simple. just set the height% at the opposite ratio of the canvas width/height. But I went to make some changes and the next thing i knew that no longer worked. I don't remember how I did it!! I'm going to have to start over if I can't figure it out. Here's the script. Canvas only.
I haven't adapted with excanvas for IE yet, but that's coming when I can figure out how I had the thing working right. It's a css issue. I had thought I put the img objects in divs that were sized and positioned and then set the images to width 100% height= 100%*((canvas.width-canvas.height)/canvas.width) So in my example, the canvas was 100 x 30 and the factor is 7 so it would resize the image 700% and the height would grow by the relative amount to the setting I had it. I'll try to figure it out, but there's the script working somewhat. I want to figure out a way to resize the img objects when the user resizes the page, but I want the img to always maintain aspect ratio. [URL]
<script>
/*ORIGINAL SCRIPT FOUND AT [URL]*/
window.onload = function () {
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 100, 50);
g.addColorStop(0, 'rgba(255, 255, 0, 0.5)');
g.addColorStop(0.5, '#0ff');
g.addColorStop(1, '#00f');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
var data = canvas.toDataURL();
document.getElementById('i').src = data;
document.getElementById('EIMG').src = data;
var canvas2 = document.getElementById('c2');
var ctx2 = canvas2.getContext('2d');
var g2 = ctx2.createLinearGradient(0, 0, 100, 50);
g2.addColorStop(0, 'rgba(255, 0, 255, 0.5)');
g2.addColorStop(0.5, '#0ff');
g2.addColorStop(1, '#00f');
ctx2.fillStyle = g2;
ctx2.fillRect(0, 0, 100, 50);
var data2 = canvas2.toDataURL();
document.getElementById('i2').src = data2;
document.getElementById('DIMG').src = data2; .....
View 3 Replies
View Related
Feb 13, 2011
I'm writing a script that graphs data in different colors and shapes and I'm encountering two problems:(1) I can't specify different colors for the graph I'm rendering. If I use fillStyle="red"; then the entire chart becomes red. It seems to use the last color specified as the color for everything on the chart.(2) The shapes are overlapping in strange ways. The fills are not covering the lines of shapes behind them so it's unclear which shape is in front and which is behind. It's like they aren't being treated as separate shapes but instead one shape where boundaries are unclear. I don't know how else to explain it.
View 2 Replies
View Related
Jul 12, 2011
I want to delete some lines on the canvas that i have created in HTML5 (with the <canvas> tag). I know one solution and that is using clearRect() (give this function the HEIGHT and WIDTH of the canvas and you clears the whole canvas.).But i don't want to clear the whole canvas, i only want to delete a few lines made by the function lineTo().
View 1 Replies
View Related
Mar 16, 2009
I have a menu in which is applied typeface script. Typeface 0.11 version doesn't support hover on links. There is an experimental version but doesn't work very well for me, so i tried to implement hover by myself.
Problem is: hover works pretty well changing canvas context property fillColor and then calling fill(), but the stroke on hovered voice remains on another color. Difficult to explain, so i put some test code online: TEST CODE As you can see, passing with mouse on the menu voices triggers the hover and the element change, but remains bordered in red.
[Code]...
View 5 Replies
View Related
Sep 27, 2010
I am using jquery with the cookie plugin and I have multiple image buttons that can hide/show multiple elements. My question is how can I add a cookie to this code to remember whether each separate element is opened or closed?
The code,
$(document).ready(function() {
// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='<div class="expanddown"></div>';
var hideText='<div class="expandup"></div>';
// initialise the visibility check
var is_visible = false;
// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.toggle').prev().append('<a href="#" class="togglelink">'+hideText+'</a>');
// capture clicks on the toggle links
$('a.togglelink').click(function() {
// switch visibility
is_visible = !is_visible;
// change the link depending on whether the element is shown or hidden
$(this).html( (!is_visible) ? hideText : showText);
// toggle the display - uncomment the next line for a basic "accordion" style
//$('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.toggle').slideToggle('fast');
// return false so any link destination is not followed
return false;
});
});
HTML,
<a class="togglelink" href="#"></a>
<div class="toggle">
Content
</div>
View 6 Replies
View Related
Aug 9, 2006
I heard or read that the next version of HTML will provide long-overdue drawing commands.
Which version of Firefox, Opera or IE supports such new fancy stuff?
View 7 Replies
View Related
Jul 23, 2005
I need to use javascript's graphics API to draw the letters of
the alphabet. If necessary, I can map out all 26 letters myself
and use drawline() to draw them, but I am hoping someone out
there might have a better suggestion. The user will click a spot
on the canvas, and the script will draw one of the letters at
that spot.
View 2 Replies
View Related
Jul 23, 2005
Is there a small graphics library that I can use? All I need to do is
draw a line of a nominated thickness and colour between two specified
points and to, at some later time, "delete" the line?
I've found a few offerings but either they weren't multi-browser
compatible or they were too big for me to consider (20K instead of 2 or 3K).
View 8 Replies
View Related
Jul 31, 2002
An interesting way of drawing a line interactively without the need for any plug-ins....
View 6 Replies
View Related
Oct 6, 2009
i want to let the user draw image or drawings on web page using html canvas element like stuff and then provide them to save that image or drawing on server so that next time they can get it as it was before to edit further.
View 1 Replies
View Related
Nov 19, 2011
We currently have a website that uses the .beforeAfter plugin to switch between two images. In addition we would like to add the possibility to draw a line and/or box using a boxer like option. All our attempts have been unsuccessful so far.
Could anyone tell us if and how it is possible to combine the .beforeAfter option with a drawing line/box one?
For curious users, here is the website we are currently working on:
[URL]
View 3 Replies
View Related
Dec 8, 2010
I want to create a drawing board in an html page were i can draw anything by dragging the mouse. and when i have done the drawing, i want to create an image of that drawing,
i found some examples doing this but so far all were using html 5, my requirement is to support most of the available browsers.
does anyone knows how i can do it.
i found one link which had what i required, [code]...
but in this the only problem is that if i drag my mouse faster, the draw line is discontinuous. i want it to be continuous free flowing colored pixels.
View 1 Replies
View Related
Oct 27, 2009
I'm trying to complete an application drawing of graphs or bar charts
I'm attempting to write a script that reads five numbers between 1 and 30.
For each number read, output XHTML text that displays a line containing that number of adjacent asterisks.
This is code I've come up with so far.
<?xml version = "1.0"encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-w3cDTD XHTML 1.0 StrictEN"
"http:www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http:www.w3.org/1999/xhtml">
[Code].....
View 1 Replies
View Related
Jul 20, 2005
I am doing a form for my site and would like to enable and disable a radio
button set depending on whether one of the choices on an outer radio button
set is checked. How can I refer to all the inputs of the inner radio button
set (they all share a common name) with javascript. I tried
document.getElementsByNames('thename') but it doesn't work. I know this is
because this method returns an array which you must then refer to by a
specific index number, unless there is another way. I would like to refer to
all of them at once and then set their disabled status to false.
View 6 Replies
View Related
Jul 20, 2005
I have a dynamically generated page (PHP), which contains an Explorer
like view of items. I would like to hide multiple <tr>'s by name, but
I can't figure out how thats done.
I have this code to hide one element by id
if (document.getElementById(id)){
document.getElementById(id).style.position = 'relative'
document.getElementById(id).style.display = 'none'
}
Anyone has a cod sample for looping through multiple elements and hide
them?
View 12 Replies
View Related
Apr 24, 2006
The short of it is that I am trying to change the background color of all elements with a particular class name. I know there is no getElementsByClassName (wouldn't it be nice if there were?), but is there a simple way to do it? Alternatively, is there a way to apply changes to multiple id's?
View 3 Replies
View Related
Feb 22, 2010
Is it possible to move multiple divs with absolute positioning down the page simultaneously by the same amount?
View 3 Replies
View Related
Sep 30, 2009
I am working on an application where the user is able to draw using square images placed using absolute positions. The user can draw any shape but it must always be connected. I now need to work out the outline of the shape they created. The only information I have is the x y of the pictures that were placed. Its driving me crazy... I tried to work out a system of looping through all the pictures and seeing if there were any images touching.
My most recent idea was to make the javascript select the images and see if I could get the coordinates of the shape from there... In simple I need a way of merging the images into a shape rather than separate entities.
View 2 Replies
View Related
Jun 15, 2011
I want to draw growing circles like a darts board and like attached picture using jQuery (I prefer) or another javascript library.
View 7 Replies
View Related
Jul 27, 2006
I have written a function to make visible elements with a certain id. however i intended it to be used to make visible multiple elements but it only appears to switch on the first element it comes to with that id. after that it appears to stop. i was wondering how i can adapt this function to make visible multiple elements, will i need a different way of referencing or can it be done through id?
function toggleLayer( layerID ) {
var style2 = document.getElementById( layerID );
if (style2.style.display == "block") {
style2.style.display = "none";
}
else {
style2.style.display = "block";
}
}
View 2 Replies
View Related
Oct 12, 2006
I have a rather old script that uses XMLHttpRequest to retrieve some
html and pops it into a div using innerHTML. I'd like to switch over to
using append child since not only is it standardized, but it'll save me
bandwidth in the long run. Code:
View 2 Replies
View Related
Jun 10, 2009
I've selected multiple tables and tried to use each for applying cornering to each table. Inside the callback function, I try to find the first/last table cells to apply cornering for each corner. However, when there are multiple tables it looks at _all_ the tr elements for the first/last rows. See example code:
// Add cornering to tables
$('table.corner-me').addClass('ui-corner-all').each(function(){
var $table = $(this);
$table.find('tr:first :first-child').addClass('ui-corner-tl');
[Code].....
View 1 Replies
View Related