summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING2
-rw-r--r--src/callbacks.c42
-rw-r--r--src/efractal.h9
-rw-r--r--src/formula.c16
-rw-r--r--src/main.c20
-rw-r--r--src/utils.c13
6 files changed, 53 insertions, 49 deletions
diff --git a/COPYING b/COPYING
index b239b11..d809778 100644
--- a/COPYING
+++ b/COPYING
@@ -1,6 +1,6 @@
1Copyright notice for eFractal: 1Copyright notice for eFractal:
2 2
3Copyright (C) 2013 Jerome Pinot <ngc891@gmail.com> 3Copyright (C) 2013-2014 Jerome Pinot <ngc891@gmail.com>
4 4
5All rights reserved. 5All rights reserved.
6 6
diff --git a/src/callbacks.c b/src/callbacks.c
index 48ecfb0..4269346 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * efractal: an EFL fractal generator 2 * efractal: an EFL fractal generator
3 * Copyright (C) 2013 Jerome Pinot <ngc891@gmail.com> 3 * Copyright (C) 2013-2014 Jerome Pinot <ngc891@gmail.com>
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
@@ -27,14 +27,14 @@
27 27
28#include "efractal.h" 28#include "efractal.h"
29 29
30/* quit the main program */ 30/* Quit the main program */
31void 31void
32quit(void) 32quit(void)
33{ 33{
34 ecore_main_loop_quit(); 34 ecore_main_loop_quit();
35} 35}
36 36
37/* react to key press */ 37/* React to key press */
38void 38void
39key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) 39key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
40{ 40{
@@ -43,7 +43,6 @@ key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_
43 char *key; 43 char *key;
44 char buf[256]; 44 char buf[256];
45 45
46
47 ev = (Evas_Event_Key_Down *)event_info; 46 ev = (Evas_Event_Key_Down *)event_info;
48 key = ev->keyname; 47 key = ev->keyname;
49 48
@@ -57,9 +56,10 @@ key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_
57 } 56 }
58} 57}
59 58
60/* update pointer coordinate on move */ 59/* Update pointer coordinate on move */
61void 60void
62mouse_over(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) 61mouse_over(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__,
62 void *event_info)
63{ 63{
64 double x, y; 64 double x, y;
65 char buffer[256]; 65 char buffer[256];
@@ -70,7 +70,9 @@ mouse_over(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *even
70 x=map->xmin+map->delta*(double)ev->cur.canvas.x; 70 x=map->xmin+map->delta*(double)ev->cur.canvas.x;
71 y=map->ymin+map->delta*(double)ev->cur.canvas.y; 71 y=map->ymin+map->delta*(double)ev->cur.canvas.y;
72 72
73 snprintf(buffer, sizeof(buffer), "Position: (%#+.10G;%#+.10G) ; x ∈ [%#+.10G;%#+.8G] ; y ∈ [%#+.10G;%#+.10G]", x, y, map->xmin, map->xmax, map->ymin, map->ymax); 73 snprintf(buffer, sizeof(buffer), "Position: (%#+.10G;%#+.10G) ;"
74 " x ∈ [%#+.10G;%#+.8G] ; y ∈ [%#+.10G;%#+.10G]",
75 x, y, map->xmin, map->xmax, map->ymin, map->ymax);
74 evas_object_text_text_set(win.txt, buffer); 76 evas_object_text_text_set(win.txt, buffer);
75 evas_object_image_data_update_add(win.img, 0, 0, WIDTH, HEIGHT); 77 evas_object_image_data_update_add(win.img, 0, 0, WIDTH, HEIGHT);
76 evas_object_focus_set(win.img, EINA_TRUE); 78 evas_object_focus_set(win.img, EINA_TRUE);
@@ -78,7 +80,8 @@ mouse_over(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *even
78 80
79/* LMB zoom in, RMB zoom out */ 81/* LMB zoom in, RMB zoom out */
80void 82void
81mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) 83mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__,
84 void *event_info)
82{ 85{
83 Evas_Event_Mouse_Down *ev; 86 Evas_Event_Mouse_Down *ev;
84 intptr_t i; 87 intptr_t i;
@@ -91,21 +94,22 @@ mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *even
91 94
92 /* left click */ 95 /* left click */
93 if (ev->button == 1) 96 if (ev->button == 1)
94 { 97 map->delta = map->delta/2;
95 map->delta = map->delta/2; 98
96 } 99 /* right click */
97 if (ev->button == 3) 100 if (ev->button == 3)
98 { 101 map->delta = map->delta*2;
99 map->delta = map->delta*2; 102
100 } 103 map->xmin = x - WIDTH * map->delta/2;
101 map->xmin = x - WIDTH*map->delta/2; 104 map->xmax = x + WIDTH * map->delta/2;
102 map->xmax = x + WIDTH*map->delta/2; 105 map->ymin = y - HEIGHT * map->delta/2;
103 map->ymin = y - HEIGHT*map->delta/2; 106 map->ymax = y + HEIGHT * map->delta/2;
104 map->ymax = y + HEIGHT*map->delta/2; 107
105 for (i = 1; i<=ecore_thread_max_get();i++) 108 for (i = 1; i<=ecore_thread_max_get();i++)
106 ecore_thread_run((void*)draw, NULL, NULL, (void *)i); 109 ecore_thread_run((void*)draw, NULL, NULL, (void *)i);
110
107 evas_object_focus_set(win.img, EINA_TRUE); 111 evas_object_focus_set(win.img, EINA_TRUE);
108 112
109} 113}
110 114
111/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */ 115/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */
diff --git a/src/efractal.h b/src/efractal.h
index f2a5d41..02f304c 100644
--- a/src/efractal.h
+++ b/src/efractal.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * efractal: an EFL fractal generator 2 * efractal: an EFL fractal generator
3 * Copyright (C) 2013 Jerome Pinot <ngc891@gmail.com> 3 * Copyright (C) 2013-2014 Jerome Pinot <ngc891@gmail.com>
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
@@ -47,13 +47,11 @@
47#define HEIGHT 750 47#define HEIGHT 750
48#define DEPTH 256 48#define DEPTH 256
49 49
50#define COPYRIGHT "Copyright © 2013 Jérôme Pinot <ngc891@gmail.com>" 50#define COPYRIGHT "Copyright © 2013-2014 Jérôme Pinot <ngc891@gmail.com>"
51 51
52#define BLACK 0xff000000 52#define BLACK 0xff000000
53#define WHITE 0xffffffff 53#define WHITE 0xffffffff
54 54
55/* starting coordinates */
56
57void quit(void); 55void quit(void);
58void key_down(void *data, Evas *e, Evas_Object *o, void *event_info); 56void key_down(void *data, Evas *e, Evas_Object *o, void *event_info);
59void mouse_over(void *data, Evas *e, Evas_Object *o, void *event_info); 57void mouse_over(void *data, Evas *e, Evas_Object *o, void *event_info);
@@ -79,7 +77,6 @@ typedef struct map_struct {
79 double delta; 77 double delta;
80} map_struct; 78} map_struct;
81 79
82
83#endif 80#endif
84 81
85/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */ 82/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */
diff --git a/src/formula.c b/src/formula.c
index 6102ae8..13714e7 100644
--- a/src/formula.c
+++ b/src/formula.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * efractal: an EFL fractal generator 2 * efractal: an EFL fractal generator
3 * Copyright (C) 2013 Jerome Pinot <ngc891@gmail.com> 3 * Copyright (C) 2013-2014 Jerome Pinot <ngc891@gmail.com>
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,7 @@ static int mandelbrot3(double x0, double y0);
36static int mandelbrot4(double x0, double y0); 36static int mandelbrot4(double x0, double y0);
37static int julia(double x, double y); 37static int julia(double x, double y);
38 38
39/* draw the fractal */ 39/* Daw the fractal */
40void 40void
41draw(void *data, Ecore_Thread *thread __UNUSED__) 41draw(void *data, Ecore_Thread *thread __UNUSED__)
42{ 42{
@@ -46,20 +46,20 @@ draw(void *data, Ecore_Thread *thread __UNUSED__)
46 uint32_t jmin, jmax; 46 uint32_t jmin, jmax;
47 intptr_t zone = (intptr_t)data; 47 intptr_t zone = (intptr_t)data;
48 48
49 /* no thread, render all */ 49 /* No thread, render all */
50 if (zone == 0) 50 if (zone == 0)
51 { 51 {
52 jmin = 0; 52 jmin = 0;
53 jmax = HEIGHT; 53 jmax = HEIGHT;
54 } 54 }
55 /* thread support, slide the screen vertically */ 55 /* Thread support, slide the screen vertically */
56 else 56 else
57 { 57 {
58 jmin = (zone-1)*HEIGHT/max; 58 jmin = (zone-1)*HEIGHT/max;
59 jmax = zone*HEIGHT/max; 59 jmax = zone*HEIGHT/max;
60 } 60 }
61 61
62 /* add the points */ 62 /* Add the points */
63 for (j=jmin;j<jmax;j++) 63 for (j=jmin;j<jmax;j++)
64 { 64 {
65 for (i=0;i<WIDTH;i++) 65 for (i=0;i<WIDTH;i++)
@@ -77,7 +77,7 @@ draw(void *data, Ecore_Thread *thread __UNUSED__)
77 evas_object_focus_set(win.img, EINA_TRUE); 77 evas_object_focus_set(win.img, EINA_TRUE);
78} 78}
79 79
80/* wrapper to call the right formula */ 80/* Wrapper to call the right formula */
81static int 81static int
82formula(char *set, double x, double y) 82formula(char *set, double x, double y)
83{ 83{
@@ -163,8 +163,6 @@ mandelbrot4(double x0, double y0)
163 return i; 163 return i;
164} 164}
165 165
166
167
168/* 3: Julia set */ 166/* 3: Julia set */
169static int 167static int
170julia(double x, double y) 168julia(double x, double y)
@@ -186,4 +184,4 @@ julia(double x, double y)
186 return i; 184 return i;
187} 185}
188 186
189/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */ 187/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */
diff --git a/src/main.c b/src/main.c
index 1e675ae..6f48fa5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * efractal: an EFL fractal generator 2 * efractal: an EFL fractal generator
3 * Copyright (C) 2013 Jerome Pinot <ngc891@gmail.com> 3 * Copyright (C) 2013-2014 Jerome Pinot <ngc891@gmail.com>
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
@@ -29,8 +29,11 @@
29 29
30uint32_t *ptr = NULL; 30uint32_t *ptr = NULL;
31uint32_t palette[256]; 31uint32_t palette[256];
32
33/* Default */
32map_struct map = { "mandelbrot", -2.0, -1.2, 0.8, 1.2, (0.8-(-2.0))/WIDTH }; 34map_struct map = { "mandelbrot", -2.0, -1.2, 0.8, 1.2, (0.8-(-2.0))/WIDTH };
33 35
36/* Options */
34static const Ecore_Getopt optdesc = { 37static const Ecore_Getopt optdesc = {
35 "eFractal", 38 "eFractal",
36 "%prog [options]", 39 "%prog [options]",
@@ -71,7 +74,7 @@ main(int argc, char **argv)
71 ECORE_GETOPT_VALUE_NONE 74 ECORE_GETOPT_VALUE_NONE
72 }; 75 };
73 76
74 /* parse command line options */ 77 /* Parse command line options */
75 args = ecore_getopt_parse(&optdesc, values, argc, argv); 78 args = ecore_getopt_parse(&optdesc, values, argc, argv);
76 if (args < 0) 79 if (args < 0)
77 { 80 {
@@ -83,7 +86,7 @@ main(int argc, char **argv)
83 goto end; 86 goto end;
84 } 87 }
85 88
86 /* return map list */ 89 /* Return map list */
87 if (list == EINA_TRUE) 90 if (list == EINA_TRUE)
88 { 91 {
89 snprintf(buf, sizeof(buf), "%s/maps", PACKAGE_DATA_DIR); 92 snprintf(buf, sizeof(buf), "%s/maps", PACKAGE_DATA_DIR);
@@ -91,7 +94,8 @@ main(int argc, char **argv)
91 eina_file_dir_list(buf, EINA_FALSE, list_maps, NULL); 94 eina_file_dir_list(buf, EINA_FALSE, list_maps, NULL);
92 goto end; 95 goto end;
93 } 96 }
94 /* get the palette from the map file */ 97
98 /* Get the palette from the map file */
95 snprintf(buf, sizeof(buf), "%s/maps/%s.map", PACKAGE_DATA_DIR, theme); 99 snprintf(buf, sizeof(buf), "%s/maps/%s.map", PACKAGE_DATA_DIR, theme);
96 if (isfile(buf) == EINA_TRUE) 100 if (isfile(buf) == EINA_TRUE)
97 { 101 {
@@ -123,7 +127,7 @@ main(int argc, char **argv)
123 if (ecore_evas_ecore_evas_get(win.canvas) != win.ee) 127 if (ecore_evas_ecore_evas_get(win.canvas) != win.ee)
124 printf("Something wrong!\n"); 128 printf("Something wrong!\n");
125 129
126 /* initialize the image */ 130 /* Initialize the image */
127 ptr = (uint32_t*)malloc(WIDTH*HEIGHT*sizeof(uint32_t)); 131 ptr = (uint32_t*)malloc(WIDTH*HEIGHT*sizeof(uint32_t));
128 memset(ptr, WHITE, WIDTH*HEIGHT*4); 132 memset(ptr, WHITE, WIDTH*HEIGHT*4);
129 win.img = evas_object_image_filled_add(win.canvas); 133 win.img = evas_object_image_filled_add(win.canvas);
@@ -133,8 +137,7 @@ main(int argc, char **argv)
133 ecore_evas_object_associate(win.ee, win.img, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); 137 ecore_evas_object_associate(win.ee, win.img, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
134 evas_object_show(win.img); 138 evas_object_show(win.img);
135 139
136 140 /* Add text block */
137 /* add text block */
138 win.txt = evas_object_text_add(win.canvas); 141 win.txt = evas_object_text_add(win.canvas);
139 evas_object_text_style_set(win.txt, EVAS_TEXT_STYLE_OUTLINE_SHADOW); 142 evas_object_text_style_set(win.txt, EVAS_TEXT_STYLE_OUTLINE_SHADOW);
140 evas_object_color_set(win.txt, 255, 255, 255, 255); 143 evas_object_color_set(win.txt, 255, 255, 255, 255);
@@ -163,4 +166,5 @@ main(int argc, char **argv)
163end: 166end:
164 return 0; 167 return 0;
165} 168}
166/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */ 169
170/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */
diff --git a/src/utils.c b/src/utils.c
index 74a0201..edef65c 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * efractal: an EFL fractal generator 2 * efractal: an EFL fractal generator
3 * Copyright (C) 2013 Jerome Pinot <ngc891@gmail.com> 3 * Copyright (C) 2013-2014 Jerome Pinot <ngc891@gmail.com>
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
@@ -27,21 +27,22 @@
27 27
28#include "efractal.h" 28#include "efractal.h"
29 29
30/* list installed map names */ 30/* List installed map names */
31void 31void
32list_maps(const char *name, const char *path __UNUSED__, void *data __UNUSED__) 32list_maps(const char *name, const char *path __UNUSED__, void *data __UNUSED__)
33{ 33{
34 char str[PATH_MAX]; 34 char str[PATH_MAX];
35 35
36 strncpy(str, name, sizeof(str)); 36 strncpy(str, name, sizeof(str));
37 /* remove the trailing .map */ 37
38 /* Remove the trailing .map */
38 if (strlen(str) >= 4) 39 if (strlen(str) >= 4)
39 str[strlen(str) - 4] = '\0'; 40 str[strlen(str) - 4] = '\0';
40 41
41 printf(" %s\n", str); 42 printf(" %s\n", str);
42} 43}
43 44
44/* check if a file exist and is readable */ 45/* Check if a file exist and is readable */
45Eina_Bool 46Eina_Bool
46isfile(const char* file) 47isfile(const char* file)
47{ 48{
@@ -60,7 +61,7 @@ isfile(const char* file)
60 return EINA_TRUE; 61 return EINA_TRUE;
61} 62}
62 63
63/* convert an ARGB color code in hexa */ 64/* Convert an ARGB color code in hexa */
64uint32_t 65uint32_t
65argb2hex(uint32_t a, uint32_t r, uint32_t g, uint32_t b) 66argb2hex(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
66{ 67{
@@ -71,4 +72,4 @@ argb2hex(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
71 return (a + r + g + b); 72 return (a + r + g + b);
72} 73}
73 74
74/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */ 75/* vim: set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 : */