Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #21623

Re: Graphics in Javascript

From danca <cyberdanny@tiscalinet.it>
Newsgroups comp.lang.javascript
Subject Re: Graphics in Javascript
Date 2013-10-16 14:36 +0200
Organization A noiseless patient Spider
Message-ID <l3m195$l8q$3@dont-email.me> (permalink)
References <3382E0A1.348A@sas.dk> <5lvcep$6j4$1@trumpet.uni-mannheim.de> <b4be09db-355c-40bb-abe7-02e57a4b8ab4@googlegroups.com>

Show all headers | View raw


Il 16/10/2013 00:52, dg ha scritto:
> Do you have any sample example? How this can be done in JS?
>
> On Wednesday, May 21, 1997 3:00:00 AM UTC-4, Stefan Koch wrote:
>> In article <3382E0A1.348A@sas.dk>, "Ole B. Hansen" <obh@sas.dk> wrote:
>>> I'm new to Javascript.
>>> Is it possible to create and draw graphics (ex charts etc) directly in
>>> Javascript?? I haven't seen examples on that.
>>> I guess you could create a gif-file in the server proces and reference
>>> it from the HTML page, but I would like to find out, if it is possible
>>> to do it in the client.
>>
>> Hi Ole,
>>
>> you can create images on the client side with JavaScript. But it is quite
>> complicated and slow. So there are really few examples out on the net.
>>
>> This explanation sketches the process (I'll think you'll understand that this
>> IS complicated...):
>>
>> This works like this: A JavaScript program can output data for different
>> MIME-types. Normally if you call document.write() the MIME-type for the output
>> is text/html - which means that the output results in a HTML-page. With the
>> document.open() method you can set the MIME-type like this:
>> document.open("text/plain") - which means for example that the proceding
>> document.write() calls result in a plain ASCII text.
>> With the help of this you can output any format you like (and which the
>> browser can display). Just choose a image format and write out the binary data
>> with the help of document.write(). Of course you'll have to know the *exact*
>> format of the MIME-type you choose. This is the complicated (or better:
>> annoying) part. This means you'll have to write your routines for the image
>> creation all on your own.
>> All the examples I have seen which use this technique use images in the xbm
>> format. Why xbm? These are black and white images. This image format - and
>> this is the important part - contains just the plain image data unpacked. So
>> it is quite easy to create these images - compared to gif's or even jpeg's.
>>
>> Although it is quite common (in some cases) to write routines for creating
>> different image formats - I wouldn't recommend to do it with JavaScript.
>> JavaScript is a scripting language - and you'll see that the image creation
>> process will be quite slow. So if you want to create images you'll better
>> stick to other techniques. For example CGI - i.e. creating the image on the
>> server with the help of some libraries. Or Java - where you can do direct
>> image manipulation like drawing lines, rectangles and so on.
>>
>> I hope this helps,
>> Stefan
>>
>> -----------------------------------------------
>> Stefan Koch   ---   skoch@rumms.uni-mannheim.de
>>    http://rummelplatz.uni-mannheim.de/~skoch/
>>
>> My JavaScript book:
>> http://www.dpunkt.de/javascript/
>>
>> Voodoo's Intro to JavaScript:
>> http://rummelplatz.uni-mannheim.de/~skoch/js/
>
maybe http://raphaeljs.com can be interesting.
HTH
Dan

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: Graphics in Javascript dg <dgurjar@gmail.com> - 2013-10-15 15:52 -0700
  Re: Graphics in Javascript "Christopher J. Henrich" <chenrich@monmouth.com> - 2013-10-15 20:35 -0400
    Re: Graphics in Javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-16 03:17 +0200
      Re: Graphics in Javascript John Harris <niam@jghnorth.org.uk.invalid> - 2013-10-16 14:38 +0100
  Re: Graphics in Javascript danca <cyberdanny@tiscalinet.it> - 2013-10-16 14:36 +0200

csiph-web