summaryrefslogtreecommitdiff
path: root/tests/text.lua
blob: fc84c20b1311f1db5c7e0f0d63d8aecda0950b76 (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
local ffi = require("ffi")
local ffi_new = ffi.new
local util = require("util")
local levas = util.get_lib("evas")

local variants = {
    "Text Basic", "Text Styles", "Text Styles Different Strings"
}

local strs = {
    "Big", "Smelly", "Fish", "Pants", "Octopus", "Garden", "There", "I", "Am",
    "You", "Are", "Erogenous", "We", "Stick", "Wet", "Fishy", "Fiddly",
    "Family", "Lair", "Monkeys", "Magazine"
}

local sin, cos = math.sin, math.cos

local weights = {
    10.4611,
    86.0290,
    82.0735
}

return function(ui, variant)
    return "text.png", variants[variant], weights[variant], function()
        local itern        = 128
        local slow         = 5
        local o_texts      = {}
        local win_w, win_h = ui.win_w, ui.win_h
        local w, h = ffi_new("Evas_Coord[1]"), ffi_new("Evas_Coord[1]")
        ui.func_set(util.del_objs(o_texts), function(t, f)
            for i = 1, itern do
                local o = o_texts[i]
                levas.evas_object_geometry_get(o, nil, nil, w, h)
                local x = (win_w / 2) - (w[0] / 2)
                    + sin((f + ((i - 1) * 13)) / (36.7 * slow)) * (w[0] / 2)
                local y = (win_h / 2) - (h[0] / 2)
                    + cos((f + ((i - 1) * 28)) / (43.8 * slow)) * (w[0] / 2)
                levas.evas_object_move(o, x, y)
            end
        end)
        local evas = ui.evas
        local st = levas.EVAS_TEXT_STYLE_SHADOW
        if variant == 3 then util.randomseed() end
        for i = 1, itern do
            local o = levas.evas_object_text_add(evas)
            o_texts[i] = o
            levas.evas_object_text_font_set(o, "Vera-Bold", 20)
            if variant == 3 then
                levas.evas_object_text_text_set(o, ("%s %s %s %s."):format(
                    strs[(util.random() % #strs) + 1],
                    strs[(util.random() % #strs) + 1],
                    strs[(util.random() % #strs) + 1],
                    strs[(util.random() % #strs) + 1]))
            else
                levas.evas_object_text_text_set(o, "This is a test string")
            end
            if variant == 1 then
                levas.evas_object_color_set(o, 0, 0, 0, 255)
            else
                levas.evas_object_text_style_set(o, st)
                levas.evas_object_color_set(o, 255, 255, 255, 255)
                levas.evas_object_text_shadow_color_set(o, 0, 0, 0, 24)
                levas.evas_object_text_glow_color_set(o, 100, 80, 40, 100)
                levas.evas_object_text_glow2_color_set(o, 50, 10, 5, 50)
                levas.evas_object_text_outline_color_set(o, 0, 0, 0, 255)
            end
            levas.evas_object_show(o)
            st = st + 1
            if st > levas.EVAS_TEXT_STYLE_FAR_SOFT_SHADOW then
                st = levas.EVAS_TEXT_STYLE_SHADOW
            end
        end
    end
end