Created
April 17, 2018 19:39
-
-
Save lauromoura/821b7325685ae22549a49cffd1b4c4fc to your computer and use it in GitHub Desktop.
Perspective tentative with EFL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define EFL_EO_API_SUPPORT | |
#define EFL_BETA_API_SUPPORT | |
#include <Eolian.h> | |
#include <Elementary.h> | |
double previous = 0; | |
static void | |
on_slide(void *data, Eo *obj, void *event_info) | |
{ | |
double val = elm_slider_value_get(obj); | |
EINA_LOG_ERR("Slider callback to %f", val); | |
double delta = val - previous; | |
previous = val; | |
Eo *img = (Eo*) data; | |
int w, h; | |
EINA_SIZE2D(w, h) = efl_gfx_size_get(img); | |
efl_gfx_map_rotate_3d(img, 0, 360*delta, 0, img, 0.5, 0.5, 0); | |
} | |
EAPI_MAIN int | |
elm_main(int argc, char *argv[]) | |
{ | |
Evas_Object *win; | |
win = elm_win_util_standard_add("Perspective", "Perspective"); | |
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); | |
Eo *box = efl_add(EFL_UI_BOX_CLASS, win); | |
Eo *slider = efl_add(EFL_UI_SLIDER_CLASS, box); | |
efl_pack_end(box, slider); | |
Eo *image = efl_add(EFL_UI_IMAGE_CLASS, box); | |
elm_image_file_set(image, "./image.jpg", NULL); | |
evas_object_resize(image, 250, 250); | |
efl_pack_end(box, image); | |
double px = 0; | |
double py = 0.5; | |
double z0 = 0; | |
double foc = 1024; | |
efl_gfx_map_perspective_3d(image, NULL, px, py, z0, foc); | |
evas_object_smart_callback_add(slider, "changed", on_slide, image); | |
elm_win_resize_object_add(win, box); | |
efl_gfx_size_set(win, EINA_SIZE2D(250, 400)); | |
evas_object_show(image); | |
evas_object_show(slider); | |
evas_object_show(box); | |
evas_object_show(win); | |
elm_run(); | |
} | |
ELM_MAIN() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment