summaryrefslogtreecommitdiff
path: root/tests/image_map_rotate.lua
blob: 7046ccbb340e70aa4b0dd84d5d808bf1312e06eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
local ffi = require("ffi")
local util = require("util")
local levas = util.get_lib("evas")

local variants = {
    "Image Map Rotate",
    "Image Map Solid Rotate",
    "Image Map Nearest Rotate",
    "Image Map Nearest Solid Rotate",
    "Image Map Color Rotate",
    "Image Map Color Solid Rotate",
    "Image Map Color Nearest Rotate",
    "Image Map Color Nearest Solid Rotate",
    "Image Map Color Alpha Rotate",
    "Image Map Color Alpha Solid Rotate",
    "Image Map Color Alpha Nearest Rotate",
    "Image Map Color Alpha Nearest Solid Rotate"
}

local sin, cos = util.sin, util.cos

local images = {
    "logo.png", "image.png", "logo.png", "image.png", "logo.png", "image.png",
    "logo.png", "image.png", "logo.png", "image.png", "logo.png", "image.png"
}

local smooth_scale = {
    1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0
}

local weights = {
    38.2705,
    35.9915,
    31.9500,
    22.6752,
    38.2702,
    37.4459,
    37.2009,
    34.5459,
    38.5043,
    50.0000,
    37.0282,
    55.8886
}

return function(ui, variant)
    return "map.png", variants[variant], weights[variant], function()
        local o_images     = {}
        local itern        = 64
        local slow         = 5.0
        local win_w, win_h = ui.win_w, ui.win_h
        local m, mapcolorf
        if variant >= 9 then
            mapcolorf = function()
                levas.evas_map_point_color_set(m, 0, 255, 255, 255, 255)
                levas.evas_map_point_color_set(m, 1, 255, 0, 0, 255)
                levas.evas_map_point_color_set(m, 2, 0, 0, 255, 255)
                levas.evas_map_point_color_set(m, 3, 0, 0, 0, 0)
            end
        elseif variant >= 5 then
            mapcolorf = function()
                levas.evas_map_point_color_set(m, 0, 255, 255, 255, 255)
                levas.evas_map_point_color_set(m, 1, 255, 0, 0, 255)
                levas.evas_map_point_color_set(m, 2, 0, 0, 255, 255)
                levas.evas_map_point_color_set(m, 3, 0, 255, 0, 255)
            end
        else mapcolorf = function() end end
        ui.func_set(util.del_objs(o_images), function(t, f)
            if not m then m = levas.evas_map_new(4) end
            levas.evas_map_smooth_set(m, smooth_scale[variant])
            for i = 1, itern do
                local w, h = 120, 160
                local x = (win_w / 2) - (w / 2)
                    + sin((f + ((i - 1) * 13)) / (36.7 * slow)) * (w / 2)
                local y = (win_h / 2) - (h / 2)
                    + cos((f + ((i - 1) * 28)) / (43.8 * slow)) * (h / 2)
                levas.evas_map_util_points_populate_from_geometry(m, x, y,
                    w, h, 0)
                mapcolorf()
                levas.evas_map_util_rotate(m, f, x + (w / 2), y + (h / 2))
                local o = o_images[i]
                levas.evas_object_map_enable_set(o, 1)
                levas.evas_object_map_set(o, m)
            end
        end)
        local evas = ui.evas
        local imgpath = util.build_path(images[variant])
        for i = 1, itern do
            local o = levas.evas_object_image_add(evas)
            o_images[i] = o
            levas.evas_object_image_file_set(o, imgpath, nil)
            levas.evas_object_image_fill_set(o, 0, 0, 120, 160)
            levas.evas_object_resize(o, 120, 160)
            levas.evas_object_image_smooth_scale_set(o,
                smooth_scale[variant])
            levas.evas_object_show(o)
        end
    end
end