aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2012-11-12 17:19:09 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2012-11-12 17:19:09 +1000
commit1c5ca344e85f23b84ce7cfd4e4ea8630f9c44c82 (patch)
tree185cc378b8ef1f7353cc550e80e3f634e84eba15
parent9566e80854c00de3ac90eb026e8c3196a5e168ad (diff)
downloaduGFX-1c5ca344e85f23b84ce7cfd4e4ea8630f9c44c82.tar.gz
uGFX-1c5ca344e85f23b84ce7cfd4e4ea8630f9c44c82.tar.bz2
uGFX-1c5ca344e85f23b84ce7cfd4e4ea8630f9c44c82.zip
Mandlebrot - remove hardware specifics
Mandlebrot - remove hardware specifics
-rw-r--r--demos/mandelbrot/main.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/demos/mandelbrot/main.c b/demos/mandelbrot/main.c
index 1e35ce9c..6ab19de1 100644
--- a/demos/mandelbrot/main.c
+++ b/demos/mandelbrot/main.c
@@ -23,18 +23,24 @@
#include "gdisp.h"
void mandelbrot(float x1, float y1, float x2, float y2) {
- unsigned int i,j;
+ unsigned int i,j, width, height;
uint16_t iter;
color_t color;
+ float fwidth, fheight;
float sy = y2 - y1;
float sx = x2 - x1;
const int MAX = 512;
- for(i = 0; i < 320; i++) {
- for(j = 0; j < 240; j++) {
- float cy = j * sy / 240.0f + y1;
- float cx = i * sx / 320.0f + x1;
+ width = (unsigned int)gdispGetWidth();
+ height = (unsigned int)gdispGetHeight();
+ fwidth = width;
+ fheight = height;
+
+ for(i = 0; i < width; i++) {
+ for(j = 0; j < height; j++) {
+ float cy = j * sy / fheight + y1;
+ float cx = i * sx / fwidth + x1;
float x=0.0f, y=0.0f, xx=0.0f, yy=0.0f;
for(iter=0; iter <= MAX && xx+yy<4.0f; iter++) {
xx = x*x;