Bevel 0.1.1

Glimmer Custom Shape

Glimmer DSL for SWT Bevel Custom Shape.

bevel is the Glimmer GUI DSL keyword provided by this gem.

Screenshot

Every square is a bevel custom shape instance with a varying base color.

Actual Use

It is used in Glimmer Tetris.

Setup

Bundler

Add the follwing to Gemfile:

gem 'glimmer-cp-bevel', '~> 0.1.1'

Run bundle install or bundle:

bundle

Direct

Run:

gem install glimmer-cp-bevel

API

First, add this to your Ruby file:

require 'glimmer-cp-bevel'

Then, use this keyword: bevel(options) { properties }

Options (keyword args) are: - :base_color (required): base background color to produce bevel effect for - :size (required): size in pixels for width and height (resulting in bevel squares having that size) - :bevel_pixel_size (optional): adjusts the bevel area - :x (default: 0) (optional): starting location x coordinate within parent - :y (default: 0) (optional): starting location y coordinate within parent

Properties are: - base_color (same as option above)

Example

Glimmer GUI DSL code snippet:

require 'glimmer-cp-bevel'

include Glimmer

shell {
  text 'Glimmer Tetris Icon'
  label {
    text 'Check out the application icon!'
    font height: 20
  }
  icon_block_size = 64
  icon_bevel_size = icon_block_size.to_f / 25.to_f
  icon_bevel_pixel_size = 0.16*icon_block_size.to_f
  icon_size = 8
  icon_pixel_size = icon_block_size * icon_size
  image(icon_pixel_size, icon_pixel_size) {
    icon_size.times { |row|
      icon_size.times { |column|
        colored = row >= 1 && column.between?(1, 6)
        color = colored ? color(([:white] + [:cyan, :blue, :dark_yellow, :yellow, :green, :magenta, :red]).sample) : color(:white)
        x = column * icon_block_size
        y = row * icon_block_size
        bevel(x: x, y: y, base_color: color, size: icon_block_size)
      }
    }
  }
}.open

Produces this Glimmer Tetris icon image:

Contributing to glimmer-cp-bevel

TODO

TODO.md

Change Log

CHANGELOG.md

License

MIT

Copyright © 2021 - Andy Maleh.

Built for Glimmer DSL for SWT (JRuby Desktop Development GUI Framework).