samples: better units example
parent
1cd168c998
commit
7c66644955
|
|
@ -1,28 +0,0 @@
|
|||
require 'squib'
|
||||
|
||||
Squib::Deck.new do
|
||||
background color: '#ddd'
|
||||
|
||||
# We can use our DSL-method to use inches
|
||||
# Computed using @dpi (set to 300 by default)
|
||||
bleed = inches(0.125)
|
||||
cut_width = inches(2.5)
|
||||
cut_height = inches(3.5)
|
||||
rect x: bleed, y: bleed, radius: 25,
|
||||
width: cut_width, height: cut_height
|
||||
|
||||
# We can also use cm this way
|
||||
cm(2)
|
||||
|
||||
# Or we can use a string ending with cm or in
|
||||
# (even cleaner in Yaml since we don't need quotes!)
|
||||
safe_margin = '0.25in'
|
||||
safe_width = '2.25in'
|
||||
safe_height = '3.25in'
|
||||
rect x: safe_margin, y: safe_margin,
|
||||
width: safe_width, height: safe_height, radius: 25
|
||||
|
||||
rect x: '4cm', y: '4 cm ', width: 100, height: 100
|
||||
|
||||
save prefix: 'units_', format: :png
|
||||
end
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
require 'squib'
|
||||
|
||||
Squib::Deck.new(width: '1.5in', height: '1.5in') do
|
||||
background color: '#ddd'
|
||||
|
||||
# We can use our DSL-method to use inches
|
||||
# Computed using @dpi (set to 300 by default)
|
||||
bleed = inches(0.125)
|
||||
cut = inches(1.25)
|
||||
rect x: bleed, y: bleed,
|
||||
width: cut, height: cut,
|
||||
dash: '0.5mm 0.5mm' # yes, units are in dashes too
|
||||
|
||||
# other units too
|
||||
cm(2) # We can also use cm this way
|
||||
cm(2) + inches(2) # We can mix units too
|
||||
|
||||
# Or we can use a string ending with cm or in
|
||||
safe_margin = '0.25 in' #you can have a space too
|
||||
safe_width = '1 in'
|
||||
safe_height = '1.0 in ' # trailing space is ok too
|
||||
rect x: safe_margin, y: safe_margin,
|
||||
width: safe_width, height: safe_height,
|
||||
radius: '2 mm '
|
||||
|
||||
# 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
|
||||
|
||||
save prefix: 'units_', format: :png
|
||||
end
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
base:
|
||||
x: .25 in
|
||||
y: 0.751in
|
||||
|
||||
example:
|
||||
extends: base
|
||||
x: += 5mm # we can mix units on adding
|
||||
y: -= 5mm
|
||||
width: 1.25in
|
||||
height: 300 # pixels
|
||||
|
|
@ -7,21 +7,21 @@ cairo: save([])
|
|||
cairo: translate([37.5, 37.5])
|
||||
cairo: rotate([0])
|
||||
cairo: translate([-37.5, -37.5])
|
||||
cairo: rounded_rectangle([37.5, 37.5, 750.0, 1050.0, 25, 25])
|
||||
cairo: rounded_rectangle([37.5, 37.5, 375.0, 375.0, 0, 0])
|
||||
cairo: set_source_color(["#0000"])
|
||||
cairo: fill_preserve([])
|
||||
cairo: set_source_color(["black"])
|
||||
cairo: set_line_width([2.0])
|
||||
cairo: set_line_join([0])
|
||||
cairo: set_line_cap([0])
|
||||
cairo: set_dash([[]])
|
||||
cairo: set_dash([[5.905511805, 5.905511805]])
|
||||
cairo: stroke([])
|
||||
cairo: restore([])
|
||||
cairo: save([])
|
||||
cairo: translate([75.0, 75.0])
|
||||
cairo: rotate([0])
|
||||
cairo: translate([-75.0, -75.0])
|
||||
cairo: rounded_rectangle([75.0, 75.0, 675.0, 975.0, 25, 25])
|
||||
cairo: rounded_rectangle([75.0, 75.0, 300.0, 300.0, 23.62204722, 23.62204722])
|
||||
cairo: set_source_color(["#0000"])
|
||||
cairo: fill_preserve([])
|
||||
cairo: set_source_color(["black"])
|
||||
|
|
@ -32,17 +32,21 @@ cairo: set_dash([[]])
|
|||
cairo: stroke([])
|
||||
cairo: restore([])
|
||||
cairo: save([])
|
||||
cairo: translate([472.4409444, 472.4409444])
|
||||
cairo: rotate([0])
|
||||
cairo: translate([-472.4409444, -472.4409444])
|
||||
cairo: rounded_rectangle([472.4409444, 472.4409444, 100, 100, 0, 0])
|
||||
cairo: set_source_color(["#0000"])
|
||||
cairo: fill_preserve([])
|
||||
cairo: set_source_color(["black"])
|
||||
cairo: set_line_width([2.0])
|
||||
cairo: set_line_join([0])
|
||||
cairo: set_line_cap([0])
|
||||
cairo: set_dash([[]])
|
||||
cairo: stroke([])
|
||||
cairo: translate([134.05511805, 166.24488195])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Hello."])
|
||||
pango: width=([384000.0])
|
||||
pango: height=([307200])
|
||||
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
|
||||
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
|
||||
pango: alignment=([#<Pango::Layout::Alignment left>])
|
||||
pango: justify=([false])
|
||||
cairo: move_to([0, 0])
|
||||
cairo: move_to([0, 0])
|
||||
cairo: show_pango_layout([MockDouble])
|
||||
pango: ellipsized?([])
|
||||
cairo: restore([])
|
||||
surface: write_to_png(["_output/units_00.png"])
|
||||
|
|
@ -53,7 +53,7 @@ describe 'Squib samples' do
|
|||
shapes/_draw_shapes.rb
|
||||
text_options.rb
|
||||
tgc_proofs.rb
|
||||
units.rb
|
||||
units/_units.rb
|
||||
).each do |sample|
|
||||
it "has not changed for #{sample}", slow: true do
|
||||
log = StringIO.new
|
||||
|
|
|
|||
Loading…
Reference in New Issue