> ## Content Index
> Fetch the complete content index at: https://blogs.remobjects.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# “Project Cooper” Mandelbrot set calculation
- URL: https://blogs.remobjects.com/2011/06/24/project-cooper-mandelbrot-set-calculation/
- Published: 2011-06-24T14:16:00.000Z
- Updated: 2018-08-22T06:17:45.000Z
- Author: brian-long
- Tags: #Import 2026-08-17 20:17

I’ve had a couple of people ask me on separate occasions to show some [“Project Cooper”](http://blog.blong.com/2011/05/native-android-development-for-delphi.html?ref=blogs.remobjects.com) code. I’ve not posted any thus far, as the product is quite early in its beta cycle and very few people have access to it. When it has matured and is in more hands I have plans to write lots more on the subject, but since I’ve been asked, I thought I’d post a simple project.

The ever-popular [Mandelbrot set](http://en.wikipedia.org/wiki/Mandelbrot%5Fset?ref=blogs.remobjects.com) is the subject of this little demo, and it’s just a simple console application, completely bypassing the Android support, just building an app that runs on the Java VM.

unit Mandelbrot;

interface

type  
ConsoleApp = class  
public  
class method Main(args: array of string);  
end;

implementation

class method ConsoleApp.Main(args: array of string);  
const  
cols = 78;  
lines = 30;  
chars = " .,:;=|iI+hHOE#$-";  
maxIter = Length(chars);  
begin  
var minRe := -2.0;  
var maxRe := 1.0;  
var minIm := -1.0;  
var maxIm := 1.0;  
var im := minIm;  
while im <= maxIm do  
begin  
var re := minRe;  
while re <= maxRe do  
begin  
var zr := re;  
var zi := im;  
var n: Integer := -1;  
while n < maxIter-1do  
begin  
Inc(n);  
var a := zr \* zr;  
var b := zi \* zi;  
if a + b > 4.0 then  
Break;  
zi := 2 \* zr \* zi + im;  
zr := a - b + re;  
end;  
system.out.print(chars.charAt(n));  
re := re + ((maxRe - minRe) / cols);  
end;  
system.out.println;  
im := im + ((maxIm - minIm) / lines)  
end;  
//Press ENTER to continue  
<//system.out.println>("Press ENTER to exit");  
system.in.read();  
end;

end.

Simple, huh? When built I get a Mandelbrot.jar file that weighs in at 1,754 bytes.

This is what it looks like running in a Windows command prompt:

[](http://lh5.ggpht.com/-zrBItERpO64/TgR%5F7FaAlII/AAAAAAAAAtw/J25DHFQhaik/s1600-h/Mandelbrot%5FWindows%25255B2%25255D.png?ref=blogs.remobjects.com)

And here is the same code (same binary, after all, it’s running on the cross-platform Java VM) running on Ubuntu Linux in a terminal window (note – this thumbnail looks pretty ghastly, but if you click it to see the original file, it looks a bit more presentable there):

[](http://lh3.ggpht.com/-B5MsOT3i5EI/TgR%5F8dqNtaI/AAAAAAAAAt4/4KIpb%5FwFYVA/s1600-h/Mandelbrot%25255B2%25255D.gif?ref=blogs.remobjects.com)

Yeah, ok, so fair enough it’s not much of an example, but it is code!

Before signing off I’ll mention another demo, which I’ve got some screenshots of, but without any code to show from currently. Jim McKeeth from RemObjects has been playing around with [jMonkeyEngine 3](http://jmonkeyengine.com/?ref=blogs.remobjects.com), a gaming platform supporting a rendering loop, all the graphics and object support you’d expect and the obligatory physics engine. It’s a set of Java libraries, so he followed one of the tutorials using “Project Cooper” and got the expected application out at the end. A wall, with a moveable camera point of you that allows you to fire a cannonball. All this is from a source file with around 250 lines in it, code and white space.

[](http://lh4.ggpht.com/-a2v95GRtVq8/TgSAAT--T2I/AAAAAAAAAuA/eXusBfjNj-8/s1600-h/JME1%25255B2%25255D.png?ref=blogs.remobjects.com)

[](http://lh3.ggpht.com/-gIVuK2FQDXQ/TgSADjo0IeI/AAAAAAAAAuI/iv9Anf1vbcw/s1600-h/JME2%25255B2%25255D.png?ref=blogs.remobjects.com)

[](http://lh6.ggpht.com/-gUb5b-7NzbY/TgSAHqDr-aI/AAAAAAAAAuQ/SpuLyGOERz0/s1600-h/JME3%25255B2%25255D.png?ref=blogs.remobjects.com)

jMonkeyEngine has a goal to work on as many platforms as possible, and I’d read that they were planning Android support. At the time of writing, jMonkeyEngine 3 is at Alpha 4\. The Android support is so preliminary that it isn’t in the main build yet, but I pulled it down from their [nightly build area](http://jmonkeyengine.com/nightly/?ref=blogs.remobjects.com). The goal is to take the same source file as in the regular project above, and slip it into an Android harness with minimal code changes (preferably none). It worked out pretty well – here are a couple of screenshots from my phone:

[](http://lh3.ggpht.com/-KcWhI0j7-gM/TgSAKKKOzGI/AAAAAAAAAuY/4YgFyUvAT%5Fw/s1600-h/JME%5FA%5F1%25255B5%25255D.png?ref=blogs.remobjects.com)