Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   drawing in javascript (http://www.velocityreviews.com/forums/t155277-drawing-in-javascript.html)

David Landy 10-13-2003 01:38 PM

drawing in javascript
 
how can i create an inline color image in javascript? the code snippet
below (which was posted on this group in 2000) shows how to do a
single-bit image -- how can this be extended to eg 8-bit color depth?

thanks for any help you can give.

david

> <script language="javascript">
> <!--
> var trash = "#define a_width 16\n#define a_height 16\nstatic "+
> "char a_bits[] = {0x00,0x01,0xe0,0x0f,0x10,0x10,0xf8,0x3f,"+
> "0x10,0x10,0x50,0x15,0x50,0x15,0x50,0x15,0x50,0x15 ,"+
> "0x50,0x15,0x50,0x15,0x50,0x15,0x50,0x15,0x10,0x10 ,"+
> "0xe0,0x0f,0x00,0x00};";
> // -->
> </script>
> </head>
> <body>
> <img src="javascript:trash" alt="">
> ...it's just a small trashcan .
> </body>
>
> chan555
>
>


Toby A Inkster 10-13-2003 05:00 PM

Re: drawing in javascript
 
David Landy wrote:

> how can i create an inline color image in javascript?


What browsers is it important for this to work in? If IE isn't important,
perhaps the "data:" URL scheme might be your friend. For example:

<a href="data:text/plain,Hello%20World">greeting</a>

See http://www.ietf.org/rfc/rfc2397.txt for more details.

If this on its own isn't an option (for example, IE support is required),
it is probably possible to use the above scheme and then use some
JavaScript to decode the "data:" URL and display it in Internet Explorer.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?id=132


David Landy 10-14-2003 11:53 PM

Re: drawing in javascript
 
Many thanks Toby.

Sadly IE is my main target audience ;-)

Any idea how to decode the data: and turn it into an image source?

David.

Toby A Inkster <UseTheAddressInMySig@deadspam.com> wrote in message news:<pan.2003.10.13.17.00.31.798613@goddamn.co.uk >...
> David Landy wrote:
>
> > how can i create an inline color image in javascript?

>
> What browsers is it important for this to work in? If IE isn't important,
> perhaps the "data:" URL scheme might be your friend. For example:
>
> <a href="data:text/plain,Hello%20World">greeting</a>
>
> See http://www.ietf.org/rfc/rfc2397.txt for more details.
>
> If this on its own isn't an option (for example, IE support is required),
> it is probably possible to use the above scheme and then use some
> JavaScript to decode the "data:" URL and display it in Internet Explorer.



All times are GMT. The time now is 10:03 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.