refactoring to get middle/center, possibly more
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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
|
||||
|
||||
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'
|
||||
|
||||
# Layouts apply this too.
|
||||
use_layout file: 'shorthands.yml'
|
||||
rect layout: :example
|
||||
|
||||
# The x and y coordinates can also be "centered", assuming the
|
||||
|
||||
# HOWEVER! Shorthands don't combine in an "extends" situation,
|
||||
# e.g. this won't work:
|
||||
# parent:
|
||||
# x: middle
|
||||
# child:
|
||||
# extends: parent
|
||||
# x: += 0.5in
|
||||
|
||||
save_png prefix: 'shorthand_'
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
example:
|
||||
x: 0.15in
|
||||
y: middle
|
||||
stroke_color: blue
|
||||
width: 30
|
||||
height: 30
|
||||
|
||||
@@ -23,10 +23,15 @@ Squib::Deck.new(width: '1.5in', height: '1.5in') do
|
||||
width: safe_width, height: safe_height,
|
||||
radius: '2 mm '
|
||||
|
||||
# Angles are also automatically converted to radians if you use deg
|
||||
svg file: '../spanner.svg',
|
||||
x: 100, y: 100, width: 40, height: 40, angle: '30deg'
|
||||
|
||||
# We can also do stuff in layout. Check out the yml file...
|
||||
# (even cleaner in Yaml since we don't need quotes!)
|
||||
use_layout file: 'using_units.yml'
|
||||
text str: 'Hello.', layout: :example
|
||||
svg file: '../spanner.svg', layout: :angled
|
||||
|
||||
save prefix: 'units_', format: :png
|
||||
end
|
||||
|
||||
@@ -8,3 +8,10 @@ example:
|
||||
y: -= 5mm
|
||||
width: 1.25in
|
||||
height: 300 # pixels
|
||||
|
||||
angled:
|
||||
x: 220
|
||||
y: 300
|
||||
width: 30
|
||||
height: 30
|
||||
angle: 100deg
|
||||
Reference in New Issue
Block a user