An Edje compiler in Ruby

Posted at 2005-02-05

I'm currently working on an Edje compiler written in Ruby, called Redact.

What's special about it? Redact doesn't parse EDC code like the official Edje compiler, edje_cc, does. Instead, Redact sources are Ruby code as well. This gives you much more power when designing and developing Edjes compared to edje_cc.

Redact isn't publically available yet, but here's a 'port' of Ben Rockwood's crossfade Edje to Redact:

include Redact

EDJE.collections("crossfade") do |c|
    c.parts("background") do |p|
        p.mouse_events = true
        p.description.color = "#ffffff"
    end

    c.parts("rect_red") do |p|
        p.mouse_events = true

        p.description do |d|
            d.color = "#00ff0000"
            d.rel[1].set_rel(1.0, 0.0)
        end

        p.description("default", 1.0) do |d|
            d.color = "#ff"
            d.rel[1].set_rel(1.0, 0.4)
        end
    end

    c.parts("rect_green") do |p|
        p.mouse_events = true

        p.description do |d|
            d.color = "#ff000080"
            d.rel[0].set_rel(0.0, 1.0)
        end

        p.description("default", 1.0) do |d|
            d.color = "#00ff"
            d.rel[0].set_rel(0.0, 0.6)
        end
    end

    c.parts("text", Part::TYPE_TEXT) do |p|
        p.description do |d|
            d.color = "#00"

            d.text = "cuddletech"
            d.font = "Vera"
            d.font_size = 12
            d.fit_x = true
            d.fit_y = false
        end
    end

    c.programs("animate") do |p|
        p.signal = "mouse,clicked,1"
        p.source = "background"
        p.targets << ProgramTarget.new(c.parts("rect_red"))
        p.targets << ProgramTarget.new(c.parts("rect_green"))
        p.tween_mode = Program::TWEEN_MODE_ACCELERATE
        p.tween_time = 1.0
    end
end

Yummy! :)

Tags , ,

Older posts: 1 2 3