POV-Ray : Newsgroups : povray.general : A JavaScript Raytracer : Re: A JavaScript Raytracer Server Time
6 Aug 2024 02:24:39 EDT (-0400)
  Re: A JavaScript Raytracer  
From: Timon Christl
Date: 13 Jun 2002 10:35:04
Message: <3d08ad98$1@news.povray.org>
On Sun, 9 Jun 2002 18:44:17 -0400, Slime wrote
> Made this myself from knowledge I've gained from POV-Ray, and my matrix
> algebra class last semester didn't hurt either.
> 
> Beware: it's 100s of times slower than povray, and pretty darn limited =) I
> don't plan on expanding it any further; I just wanted to prove to myself
> that I *could* do it.
> 
> http://www.slimeland.com/experiments/raytrace.html

The rendered image is displayed with an aspect ratio of about 4 to 1 in
my Mozilla, and it gets worse if a smaller font is used. The reason for
this is: you are using spans with a space character inside as pixels.
Mozilla, being a modern, standards-conforming browser, calculates the
width of each span as the width of a space in the selected font. In
other words, each span is 1 pixel high, but several pixels wide.

A much better way would be this one: Use a table with cellpadding="0"
and cellspacing="0", and one cell for each pixel. Put a transparent
image in each cell, in it, make it 1x1 in size and make sure you use
style="display:block" for that image. This style is crucial for the
concept to work, see the second entry on
http://www.mozilla.org/docs/web-developer/faq.html for the reason why.
The background color of each cell should then be set to the desired
color of the pixel. An example for this technique can be found on

http://www.fmi.uni-passau.de/~christl/testtab.html

This example works with Mozilla (and thus, Netscape 6/7), Opera and IE
(at least IE for Solaris, I don't have a windows machine around while
I'm typing this).

-- 
Timon Christl <me### [at] christltimonde>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.