samples/text_options.rb in squib-0.0.5 vs samples/text_options.rb in squib-0.0.6

- old
+ new

@@ -1,6 +1,6 @@ -#!/usr/bin/env ruby +# encoding: UTF-8 require 'squib' data = {'name' => ['Thief', 'Grifter', 'Mastermind'], 'level' => [1,2,3]} longtext = "This is left-justified text.\nWhat do you know about tweetle beetles? well... \nWhen tweetle beetles fight, it's called a tweetle beetle battle. And when they battle in a puddle, it's a tweetle beetle puddle battle. AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle. AND... When beetles battle beetles in a puddle paddle battle and the beetle battle puddle is a puddle in a bottle... ..they call this a tweetle beetle bottle puddle paddle battle muddle. AND... When beetles fight these battles in a bottle with their paddles and the bottle's on a poodle and the poodle's eating noodles... ...they call this a muddle puddle tweetle poodle beetle noodle bottle paddle battle." @@ -26,14 +26,25 @@ font: 'Impact 36', font_size: [16, 20, 24] text str: 'This text has fixed width, fixed height, center-aligned, middle-valigned, and has a red hint', hint: :red, x: 65, y: 400, - width: 300, height: 200, + width: 300, height: 125, align: :center, valign: 'MIDDLE', #case-insenstive strings allowed too. font: 'Arial 18' - text str: 'Ellipsization!\nThe ultimate question of life, the universe, and everything to life and everything is 42', + extents = text str: 'Ink extent return value', + x: 65, y: 550, + font: 'Sans Bold', font_size: [16, 20, 24] + margin = 10 + # Extents come back as an array of hashes, which can get split out like this + ws = extents.inject([]) { |arr, ext| arr << ext[:width] + 10; arr } + hs = extents.inject([]) { |arr, ext| arr << ext[:height] + 10; arr } + rect x: 65 - margin/2, y: 550 - margin/2, + width: ws, height: hs, + radius: 10, stroke_color: :black + + text str: "Ellipsization!\nThe ultimate question of life, the universe, and everything to life and everything is 42", hint: :green, font: 'Arial 22', x: 450, y: 400, width: 280, height: 180, ellipsize: true