Sha256: acdc6bc7a63f5360c0523f730b9e0301f02eb6f865582805268a6a31fd6e8f48
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
require_relative '../../lib/squib' # Lots of DSL methods have shorthands that are accepted for # x, y, width, and height parameters. Squib::Deck.new(width: '0.5in', height: '0.25in') do background color: :white # middle for x and y will resolve to half the height text str: 'xymiddle', font: 'Sans Bold 3', hint: :red, x: 'middle', y: :middle # 'center' also works rect width: 30, height: 30, x: :center, y: 'center' # Applies to shapes triangle x1: 20, y1: 20, x2: 60, y2: 20, x3: :middle, y3: :middle # We can also do width-, height-, width/, height/ rect x: 20, y: 5, stroke_color: :green, width: 'deck - 0.1in', height: 10 rect x: 10, y: 50, width: 10, height: 'deck / 3', stroke_color: :purple # And middle+/- rect x: 'middle + 0.1in', y: 'center - 0.1in', width: '0.1in', height: '0.1in', fill_color: :blue # Layouts apply this too. use_layout file: 'shorthands.yml' rect layout: :example # HOWEVER! Shorthands don't combine in an "extends" situation, # e.g. this won't work: # parent: # x: middle # child: # extends: parent # x: += 0.5in # These shorthands are not intended for every xywh parameter or # length parameter, see docs for when they do or do not apply. save_png prefix: 'shorthand_' end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
squib-0.19.0 | samples/units/_shorthands.rb |
squib-0.19.0b | samples/units/_shorthands.rb |
squib-0.19.0a | samples/units/_shorthands.rb |