summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Pinot <ngc891@gmail.com>2013-11-06 21:00:38 +0900
committerJerome Pinot <ngc891@gmail.com>2013-11-06 21:00:38 +0900
commit9e8a61347259fb8279ac7debfa150fb7feeac4af (patch)
tree92952238cb990a20d44cb942354fa50abc79b2c6
parent3969666fc054cdb315ad4fc3df8d4d0157eb3b8e (diff)
Fix up the zoom ratio.
-rw-r--r--src/callbacks.c24
-rw-r--r--src/efractal.h3
-rw-r--r--src/formula.c2
-rw-r--r--src/main.c2
4 files changed, 13 insertions, 18 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index d0d2eae..a198289 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -58,8 +58,8 @@ mouse_over(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *even
58 map_struct *map = (map_struct*)data; 58 map_struct *map = (map_struct*)data;
59 59
60 ev = (Evas_Event_Mouse_Move *)event_info; 60 ev = (Evas_Event_Mouse_Move *)event_info;
61 x=map->xmin+map->dx*(double)ev->cur.canvas.x; 61 x=map->xmin+map->delta*(double)ev->cur.canvas.x;
62 y=map->ymin+map->dy*(double)ev->cur.canvas.y; 62 y=map->ymin+map->delta*(double)ev->cur.canvas.y;
63 63
64 snprintf(buffer, sizeof(buffer), "Position: (%#+.10G;%#+.10G) ; x ∈ [%#+.10G;%#+.8G] ; y ∈ [%#+.10G;%#+.10G]", x, y, map->xmin, map->xmax, map->ymin, map->ymax); 64 snprintf(buffer, sizeof(buffer), "Position: (%#+.10G;%#+.10G) ; x ∈ [%#+.10G;%#+.8G] ; y ∈ [%#+.10G;%#+.10G]", x, y, map->xmin, map->xmax, map->ymin, map->ymax);
65 evas_object_text_text_set(win.txt, buffer); 65 evas_object_text_text_set(win.txt, buffer);
@@ -77,26 +77,22 @@ mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *even
77 map_struct *map = (map_struct*)data; 77 map_struct *map = (map_struct*)data;
78 78
79 ev = (Evas_Event_Mouse_Down *)event_info; 79 ev = (Evas_Event_Mouse_Down *)event_info;
80 x=map->xmin+map->dx*(double)ev->canvas.x; 80 x=map->xmin+map->delta*(double)ev->canvas.x;
81 y=map->ymin+map->dy*(double)ev->canvas.y; 81 y=map->ymin+map->delta*(double)ev->canvas.y;
82 82
83 /* left click */ 83 /* left click */
84 if (ev->button == 1) 84 if (ev->button == 1)
85 { 85 {
86 map->xmin = x - (map->xmax-map->xmin)/4; 86 map->delta = map->delta/2;
87 map->xmax = x + (map->xmax-map->xmin)/4;
88 map->ymin = y - (map->ymax-map->ymin)/4;
89 map->ymax = y + (map->ymax-map->ymin)/4;
90 } 87 }
91 if (ev->button == 3) 88 if (ev->button == 3)
92 { 89 {
93 map->xmin = x - (map->xmax-map->xmin); 90 map->delta = map->delta*2;
94 map->xmax = x + (map->xmax-map->xmin);
95 map->ymin = y - (map->ymax-map->ymin);
96 map->ymax = y + (map->ymax-map->ymin);
97 } 91 }
98 map->dx = (map->xmax-map->xmin)/WIDTH; 92 map->xmin = x - WIDTH*map->delta/2;
99 map->dy = (map->ymax-map->ymin)/HEIGHT; 93 map->xmax = x + WIDTH*map->delta/2;
94 map->ymin = y - HEIGHT*map->delta/2;
95 map->ymax = y + HEIGHT*map->delta/2;
100 for (i = 1; i<=ecore_thread_max_get();i++) 96 for (i = 1; i<=ecore_thread_max_get();i++)
101 ecore_thread_run((void*)draw, NULL, NULL, (void *)i); 97 ecore_thread_run((void*)draw, NULL, NULL, (void *)i);
102 evas_object_focus_set(win.img, EINA_TRUE); 98 evas_object_focus_set(win.img, EINA_TRUE);
diff --git a/src/efractal.h b/src/efractal.h
index d4d0c0c..1e0d69d 100644
--- a/src/efractal.h
+++ b/src/efractal.h
@@ -75,8 +75,7 @@ typedef struct map_struct {
75 double ymin; 75 double ymin;
76 double xmax; 76 double xmax;
77 double ymax; 77 double ymax;
78 double dx; 78 double delta;
79 double dy;
80} map_struct; 79} map_struct;
81 80
82 81
diff --git a/src/formula.c b/src/formula.c
index ead4557..6102ae8 100644
--- a/src/formula.c
+++ b/src/formula.c
@@ -64,7 +64,7 @@ draw(void *data, Ecore_Thread *thread __UNUSED__)
64 { 64 {
65 for (i=0;i<WIDTH;i++) 65 for (i=0;i<WIDTH;i++)
66 { 66 {
67 color = formula(map.set, map.xmin+i*map.dx, map.ymin+j*map.dy); 67 color = formula(map.set, map.xmin+i*map.delta, map.ymin+j*map.delta);
68 if (color == DEPTH) 68 if (color == DEPTH)
69 ptr[WIDTH*j+i]=BLACK; 69 ptr[WIDTH*j+i]=BLACK;
70 for (k=0;k<DEPTH;k++) 70 for (k=0;k<DEPTH;k++)
diff --git a/src/main.c b/src/main.c
index 75b4018..c5a188f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -29,7 +29,7 @@
29 29
30uint32_t *ptr = NULL; 30uint32_t *ptr = NULL;
31uint32_t palette[256]; 31uint32_t palette[256];
32map_struct map = { "mandelbrot", -2.0, -1.2, 0.8, 1.2, (0.8-(-2.0))/WIDTH, (1.2-(-1.2))/HEIGHT }; 32map_struct map = { "mandelbrot", -2.0, -1.2, 0.8, 1.2, (0.8-(-2.0))/WIDTH };
33 33
34static const Ecore_Getopt optdesc = { 34static const Ecore_Getopt optdesc = {
35 "eFractal", 35 "eFractal",