Forum Moderators: open

Message Too Old, No Replies

draw paint script

         

chicagolove

4:36 pm on May 7, 2008 (gmt 0)

10+ Year Member



can anyone help me out with this script that im doing for school. its just a simple script where i have five colors available on the screen that you can click and then the inline style tag saves the color you choose, and then by clicking you can draw on the screen. when you refresh the page it will clear the drawings... im just really confused and i dont even know where to begin with this. i have searched online everywhere.

httpwebwitch

12:26 pm on May 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, chicagolove!

OK, first of all, I'm assuming this is all going to be built in DHTML? You'll have to build from scratch. And it's a tricky one - there are many many ways to approach this problem...

Without delving into example code, I can describe some of the ingredients:

First I'd create the 5 <div>, each styled with the paint color, and with an onclick event which assigns that color to a global JS variable.

Listen to the onmousedown event, and start a setInterval() which adds a new 1x1 element at the current mouse X and Y position, and styled with your current brush color. Then onmouseup, clearInterval(). A simple, ultraprimitive stylus.