Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Client Scripting
Expertise: Beginner
Mar 11, 1999



Application Security Testing: An Integral Part of DevOps

Drawing With JavaScript

It seems to me that you should be able to draw images in JavaScript by positioning single-pixel GIF images according to a given algorithm. First, how would you generate a single-pixel GIF file? Second, can you place such an image at a location with plus-or-minus one-pixel accuracy?

You certainly can "draw" with JavaScript by creating HTML on the fly and manipulating the display of single-pixel GIF images via their HEIGHT and WIDTH attributes. Placing images with pixel accuracy, although difficult, is doable using tables and/or Cascading Style Sheets (CSS). The real question, though, is whether or not you really need to do this. The most you should expect from such a technique is Etch-A-Sketch type of drawings and anything beyond a few simple lines gets very complicated in a hurry. Creating the images on the fly on your Web server will not only prove much easier, it will also be compatible with all browsers.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date