[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: Writing an image format**
**From**: Luiz Henrique de Figueiredo <lhf@...>
**Date**: Tue, 26 Oct 2010 20:26:16 -0200

> I am looking for a simple way to generate and write a color image to disk.
The simplest format is the Netpbm family of formats:
http://en.wikipedia.org/wiki/Netpbm_format
Easy to generate from Lua. Here's a Lua program for generating a gray-scale
picture of the Mandelbrot set (Mandelbrot died earlier this month).
--lhf
local N=256
print("P2\n",N,N,255)
for i=1,N do
local y=2-4*(i-1)/(N-1)
for j=1,N do
local x=-2+4*(j-1)/(N-1)
local xc,yc=x,y
local X,Y=0,0
local p=0
for n=1,255 do
X,Y = X^2-Y^2+xc, 2*X*Y+yc
if X^2+Y^2>4 then p=n break end
end
print(p)
end
end