Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old October 5th, 2008, 12:00 PM   #1
New Member
 

Join Date: Oct 2008
Location: UK
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 DrOtter is on a distinguished road
Vector Based Drawing Script

Hi everybody - hopefully somebody will be able to help me with this...
I've written a very basic drawing script (see below). The problem is I want to implement vector based drawing, so that each stroke drawn is saved as a vector, and that when you click erase on the line, the whole line disappears. I'm probably not veyr good at explaining it, but an example of what I'm talking about is the msn mesenger handwriting tool.
Another example is on this site.
So - does anybody have any ideas on how to implement this? I'm lost for ideas at the moment, so any help would be much appreciated!
Thanks

Code:
<html>
 <head>
  <script type="application/x-javascript">
  
var pressed = false;
document.onmousemove=mouseMove;
document.onmouseup=mouseUp;
document.onmousedown=mouseDown;

function mouseUp() {
    pressed = false;
}

function mouseDown() {
    pressed = true;
}

function mouseMove(event) {
    var canvas = document.getElementById("canvas");
    var ctx = canvas.getContext("2d");

    ev = event || window.event;

    if (pressed) {
        ctx.fillStyle = "rgb(255,0,0)";
        ctx.fillRect (ev.pageX-canvas.offsetLeft, ev.pageY-canvas.offsetTop, 2, 2);
    }
}

  </script>
 </head>
 <style>
 #canvas {
    border: 1px solid black;
 }
 </style>
 <body>
   <canvas id="canvas" width="300" height="300"></canvas>
 </body>
</html>
DrOtter is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nifty little Script for CSS selection based on Browser and OS robbied72 Classic ASP 20 June 18th, 2008 12:39 PM
script to simulate a windows based FTP cyberseed PHP 3 October 15th, 2007 10:49 AM
Problem with browser based script viewing Andrew1986 Classic ASP 12 October 1st, 2007 04:42 AM
can't convert table-based to css-based layout markus HTML, XHTML and CSS 21 April 25th, 2007 06:50 PM
ReWriting URL's for IIS (script based) Rob Classic ASP 3 July 20th, 2004 09:46 AM


Search Engine Optimization by vBSEO 3.2.0 RC8