Sunday, January 30, 2022

Glimmer DSL for GTK Tetris + Cairo Tutorial

Glimmer DSL for GTK (Ruby GNOME Desktop Development GUI Library) had a few releases in response to an issue requesting a Tetris sample. The project now includes brand new declarative support for Cairo graphics and an implementation of the Tetris game as a sample. Additionally, the majority of Cairo samples mentioned in this Cairo Tutorial blog post by Mohit Sindhwani ("Cairo with Ruby - Samples using RCairo") have been included too. 


Tutorial of using Cairo in Ruby with Glimmer DSL for GTK:


Below is a Glimmer DSL for GTK rewriting of Mohit's tutorial using the much simpler and more maintainable Glimmer DSL for GTK declarative Cairo syntax (instead of the default RCairo imperative syntax).


Tetris Screenshot:


Here is a screenshot of Tetris, written with declarative Cairo code using Glimmer DSL for GTK.

Tetris Glimmer DSL for GTK Code:


Cairo usage is mostly the Glimmer-only `square` and `polygon` shape constructions (not available in standard RCairo).


Happy Glimmering!

No comments: