<VRTDataset rasterXSize="256" rasterYSize="256">
  <VRTRasterBand dataType="Byte" band="1" subClass="VRTDerivedRasterBand">
    <ColorInterp>Gray</ColorInterp>
    <PixelFunctionType>mandelbrot</PixelFunctionType>
    <PixelFunctionLanguage>Python</PixelFunctionLanguage>
    <PixelFunctionCode><![CDATA[
def mandelbrot(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize, raster_ysize, r, gt, **kwargs):
    scale_y = 1.0 * (out_ar.shape[0] - 2 * r) / ysize
    scale_x = 1.0 * (out_ar.shape[1] - 2 * r) / xsize
    for j in range( out_ar.shape[0]):
        y0 = 2.0 * (yoff + j / scale_y) / raster_ysize - 1
        for i in range(out_ar.shape[1]):
            x0 = 3.5 * (xoff + i / scale_x) / raster_xsize - 2.5
            x = 0.0
            y = 0.0
            iteration = 0
            max_iteration = 100
            x2 = 0.0
            y2 = 0.0
            while x2 + y2 < 4 and iteration < max_iteration:
                y = 2*x*y + y0
                x = x2 - y2 + x0
                x2 = x * x
                y2 = y * y
                iteration += 1

            out_ar[j][i] = iteration * 255 / max_iteration
]]>
    </PixelFunctionCode>
  </VRTRasterBand>
</VRTDataset>
