On Dec 21, 2007 4:49 PM, Brian Vanderburg II <[EMAIL PROTECTED]> wrote:
> Is there a plugin (or high speed script-fu) that would allow me to enter
> a math expression and from it create the pixel data also given a
> 'viewport range'.
>
> XMin: -1
> XMax 1
> YMin -1
> Ymax: 1
> UseGraient: no
> Expr: red=sin(2*pi*x*y)/2+0.5;green=...,...
>
> or
> UseGradient: yes
Simple gradient application is best done using 'gradient map' filter.
Although since you're running windows, that may be slower.

> Expr: offset=sin(2*pi*x*y)
>
> Or something like that.  I imagine a script-fu could be done that could
> take the viewport, gradient, and expression and somehow execute the
> expression and plot the pixels, but it seems like script-fu would be
> somewhat slow.  I've created my own expression evaluation library which
> would easily provide all the math support I need, but don't know much
> about making GIMP plugins and since I'm only on Windows now I've had
> problems trying to compile glib/gtk under msys/mingw, plus it is C++
> except an older version which is C.
>
> Brian Vanderburg II

I recommend using PyGimp in combination with Numpy.

for example, here is some python source code for the first 'red' example

# it is assumed that x,y are 2d arrays
# like
# x =
# 012
# 012
# 012
#
# y =
# 000
# 111
# 222

red = numpy.sin((2 * pi) * x * y) / 2 +0.5
# calculate green, blue.. here
# ..
# expand the range (0..1) -> (0..255) and convert to 8bit integers
# you would need to account for the possibility of an alpha channel here, too.
result = numpy.hstack ( (red * 255).astype('B'), (green *
255).astype('B'), (blue * 255).astype('B'))

# result.tostring() can now be written to a GIMP pixel region
_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply via email to