Browse Source

Moving API.md to README.md and revising documentation

dev
Andy Meneely 12 years ago
parent
commit
244c18bfe3
  1. 1
      .yardopts
  2. 83
      API.md
  3. 99
      README.md
  4. 4
      lib/squib/api/background.rb
  5. 12
      lib/squib/api/image.rb
  6. 4
      lib/squib/api/save.rb
  7. 2
      lib/squib/api/settings.rb
  8. 10
      lib/squib/api/shapes.rb
  9. 6
      lib/squib/api/text.rb
  10. 2
      lib/squib/graphics/save_doc.rb

1
.yardopts

@ -3,5 +3,4 @@
--markup markdown --markup markdown
--api public --api public
- -
API.md
LICENSE.txt LICENSE.txt

83
API.md

@ -1,83 +0,0 @@
# Squib API
The Squib DSL is based on a collection of methods provided to the `Squib::Deck` class. The general philosophy of Squib is to specify as little as possible with layers of defaults, highly flexible input, and good ol' Ruby duck-typing. Ruby does a lot to make Squib useful.
# Squib::Deck and Squib::Card
Squib essentially has two main classes: `Deck` and `Card`. `Deck` is the front-end, and `Card` is the back-end. The contract of `Deck` is to do the various manipulations of options and then delegate the operation to `Card` to do the low-level graphical operations.
For most users, I recommending solely using `Deck` methods. If you want to roll up your sleeves and get your hands messy, you can access the Cairo or Pango contexts the directly via the `Card` class. The API documentation doesn't really cover these, however, so you're on your own there.
# Specifying Parameters
Squib is all about sane defaults and shorthand specification. Arguments are almost always using hashes, which look a lot like [Ruby 2.0's named parameters](http://www.ruby-doc.org/core-2.0.0/doc/syntax/calling_methods_rdoc.html#label-Keyword+Arguments). This means you can specify your parameters in any order you please. All parameters are optional. For example `x` and `y` default to 0 (i.e. the upper-left corner of the card). Any parameter that is specified in the command overrides any Squib defaults, `config.yml` settings, or layout rules.
# Specifying Ranges
Most public `Deck` methods allow a `range` to be specified as a first parameter. This parameter is used to access an internal `Array` of `Squib::Cards`. This can be an actual Ruby range, or anything that implements `#each` (thus can be an `Enumerable`). Integers are also supported for changing one card only. Negatives work from the back of the deck. Here are some examples from `samples/ranges.rb` found [here](https://github.com/andymeneely/squib/tree/master/samples/ranges.rb)
{include:file:samples/ranges.rb}
Note: you MUST use named parameters rather than positional parameters. For example: `save :png` will lead to an error like this:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/api/save.rb:12:in `save': wrong number of arguments (2 for 0..1) (ArgumentError)
from deck.rb:22:in `block in <main>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `instance_eval'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `initialize'
from deck.rb:18:in `new'
from deck.rb:18:in `<main>'
Instead, you must name the parameters: `save format: :png`
# Pixels and Other Units
By default, Squib thinks in pixels. This decision was made so that we can have pixel-perfect layouts without automatically scaling everything, even though working in units is sometimes easier. To convert, we provide the `Deck#inch` method, as shown in `samples/units.rb` found [here](https://github.com/andymeneely/squib/tree/master/samples/units.rb)
{include:file:samples/units.rb}
# Specifying Colors
Colors can be specified in a wide variety of ways, mostly in a hex-string. Take a look at the examples from `samples/colors.rb`, found [here](https://github.com/andymeneely/squib/tree/master/samples/colors.rb)
{include:file:samples/colors.rb}
Under the hood, Squib uses the `rcairo` [color parser](https://github.com/rcairo/rcairo/blob/master/lib/cairo/color.rb) to accept a variety of color specifications, along with over [300 pre-defined constants](https://github.com/rcairo/rcairo/blob/master/lib/cairo/colors.rb).
# Specifying Files
All files opened for reading or writing (e.g. for `png` and `xlsx`) are opened relative to the current directory. Files opened for writing (e.g. for `save_png`) will be overwritten without warning.
# Custom Layouts
Working with x-y coordinates all the time can be tiresome, and ideally everything in a game prototype should be data-driven and easily changed. For this, many Squib methods allow for a `layout` to be set. In essence, layouts are a way of setting default values for any argument given to the command.
To use a layout, set the `layout:` option on a `Deck.new` command to point to a YAML file. Any command that allows a `layout` option can be set with a Ruby symbol or String, and the command will then load the specified `x`, `y`, `width`, and `height`. The individual command can also override these options.
Note: YAML is very finnicky about having tabs in the file. Use two spaces for indentation instead.
Layouts will override Squib's defaults, but are overriden by anything specified in the command itself. Thus, the order of precedence looks like this:
* Use what the command specified
* If anything was not yet specified, use what was given in a layout (if a layout was specified in the command and the file was given to the Deck)
* If still anything was not yet specified, use what was given in Squib's defaults.
Layouts also allow for a special `extends` field that will copy all of the settings from another entry. Only a single level of extends are supported currently (contact the developer if you want multiple levels).
See the `use_layout` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/)
{include:file:samples/use_layout.rb}
# Configuration File
Squib supports various configuration properties that can be specified in an external file. The `config:` option in `Deck.new` can specify an optional configuration file in YML format. The properties there are intended to be immutable for the life of the Deck. The options include:
* `progress_bars` (Boolean, default: false). When set to `true`, long-running operations will show a progress bar on the command line.
* `dpi` (Integer, default: 300). Used in calculations when units are used (e.g. for PDF rendering and unit conversion).
* `hint` (ColorString, default: nil). Text hints are used to show the boundaries of text boxes. Can be enabled/disabled for individual commands, or set globally with the `set` command. This setting is overriden by `set` and individual commands.
* `custom_colors` (Hash of Colors, default: {}). Defines globally-available colors available to the deck that can be specified in commands.
The following sample demonstrates the config file.
See the `custom_config` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/)
{include:file:samples/custom_config.rb}

99
README.md

@ -69,19 +69,108 @@ The central file here is `deck.rb`. Here's a basic example of a deck to work fro
{include:file:samples/basic.rb basic.rb} {include:file:samples/basic.rb basic.rb}
## Learning Squib # Learning Squib
After going over this README, here are some other places to go learn Squib: After going over this README, here are some other places to go learn Squib:
* The YARD-generated API documentation [for the latest Squib gem](http://rubydoc.info/gems/squib/) is a method-by-method reference. I recommend starting with the `API` file, and looking at the `Deck` class. If you are following Squib master, see [the latest version](http://rubydoc.info/github/andymeneely/squib/frames) * The YARD-generated API documentation [for the latest Squib gem](http://rubydoc.info/gems/squib/) is a method-by-method reference. The `Deck` class is the main class to look at. If you are following Squib master, see [the latest version](http://rubydoc.info/github/andymeneely/squib)
* The `samples` directory in the [source repository](https://github.com/andymeneely/squib) has lots of examples * The `samples` directory in the [source repository](https://github.com/andymeneely/squib) has lots of examples. To run them, you will need to clone the repository and run them with Squib installed.
* Junk Land (link TBD) is my own creation that's uses Squib for both black-and-white print-and-play and full color. * Junk Land (link TBD) is my own creation that's uses Squib for both black-and-white print-and-play and full color.
## Development ## Viewing this README
If you're viewing this on Github, you might see some confusing tags like `{include:file:...}` - these are directives for Yard to show the embedded examples. These can be found on RubyDoc.info:
* The [latest Gem release]((http://rubydoc.info/gems/squib/))
* The [master branch](http://rubydoc.info/github/andymeneely/squib) of this repository
## Squib API
The Squib DSL is based on a collection of methods provided to the `Squib::Deck` class. The general philosophy of Squib is to specify as little as possible with layers of defaults, highly flexible input, and good ol' Ruby duck-typing. Ruby does a lot to make Squib useful.
Squib essentially has two main classes: `Deck` and `Card`. `Deck` is the front-end, and `Card` is the back-end. The contract of `Deck` is to do the various manipulations of options and then delegate the operation to `Card` to do the low-level graphical operations.
For most users, I recommending solely using `Deck` methods. If you want to roll up your sleeves and get your hands messy, you can access the Cairo or Pango contexts the directly via the `Card` class. The API documentation doesn't really cover these, however, so you're on your own there.
## Specifying Parameters
Squib is all about sane defaults and shorthand specification. Arguments are almost always using hashes, which look a lot like [Ruby 2.0's named parameters](http://www.ruby-doc.org/core-2.0.0/doc/syntax/calling_methods_rdoc.html#label-Keyword+Arguments). This means you can specify your parameters in any order you please. All parameters are optional. For example `x` and `y` default to 0 (i.e. the upper-left corner of the card). Any parameter that is specified in the command overrides any Squib defaults, `config.yml` settings, or layout rules.
## Specifying Ranges
Most public `Deck` methods allow a `range` to be specified as a first parameter. This parameter is used to access an internal `Array` of `Squib::Cards`. This can be an actual Ruby range, or anything that implements `#each` (thus can be an `Enumerable`). Integers are also supported for changing one card only. Negatives work from the back of the deck. Here are some examples from `samples/ranges.rb` found [here](https://github.com/andymeneely/squib/tree/master/samples/ranges.rb)
{include:file:samples/ranges.rb}
Note: you MUST use named parameters rather than positional parameters. For example: `save :png` will lead to an error like this:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/api/save.rb:12:in `save': wrong number of arguments (2 for 0..1) (ArgumentError)
from deck.rb:22:in `block in <main>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `instance_eval'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `initialize'
from deck.rb:18:in `new'
from deck.rb:18:in `<main>'
Instead, you must name the parameters: `save format: :png`
## Pixels and Other Units
By default, Squib thinks in pixels. This decision was made so that we can have pixel-perfect layouts without automatically scaling everything, even though working in units is sometimes easier. To convert, we provide the `Deck#inch` method, as shown in `samples/units.rb` found [here](https://github.com/andymeneely/squib/tree/master/samples/units.rb)
{include:file:samples/units.rb}
## Specifying Colors
Colors can be specified in a wide variety of ways, mostly in a hex-string. Take a look at the examples from `samples/colors.rb`, found [here](https://github.com/andymeneely/squib/tree/master/samples/colors.rb)
{include:file:samples/colors.rb}
Under the hood, Squib uses the `rcairo` [color parser](https://github.com/rcairo/rcairo/blob/master/lib/cairo/color.rb) to accept a variety of color specifications, along with over [300 pre-defined constants](https://github.com/rcairo/rcairo/blob/master/lib/cairo/colors.rb).
## Specifying Files
All files opened for reading or writing (e.g. for `png` and `xlsx`) are opened relative to the current directory. Files opened for writing (e.g. for `save_png`) will be overwritten without warning.
## Custom Layouts
Working with x-y coordinates all the time can be tiresome, and ideally everything in a game prototype should be data-driven and easily changed. For this, many Squib methods allow for a `layout` to be set. In essence, layouts are a way of setting default values for any argument given to the command.
To use a layout, set the `layout:` option on a `Deck.new` command to point to a YAML file. Any command that allows a `layout` option can be set with a Ruby symbol or String, and the command will then load the specified `x`, `y`, `width`, and `height`. The individual command can also override these options.
Note: YAML is very finnicky about having tabs in the file. Use two spaces for indentation instead.
Layouts will override Squib's defaults, but are overriden by anything specified in the command itself. Thus, the order of precedence looks like this:
* Use what the command specified
* If anything was not yet specified, use what was given in a layout (if a layout was specified in the command and the file was given to the Deck)
* If still anything was not yet specified, use what was given in Squib's defaults.
Layouts also allow for a special `extends` field that will copy all of the settings from another entry. Only a single level of extends are supported currently (contact the developer if you want multiple levels).
See the `use_layout` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/)
{include:file:samples/use_layout.rb}
## Configuration File
Squib supports various configuration properties that can be specified in an external file. The `config:` option in `Deck.new` can specify an optional configuration file in YML format. The properties there are intended to be immutable for the life of the Deck. The options include:
* `progress_bars` (Boolean, default: false). When set to `true`, long-running operations will show a progress bar on the command line.
* `dpi` (Integer, default: 300). Used in calculations when units are used (e.g. for PDF rendering and unit conversion).
* `hint` (ColorString, default: nil). Text hints are used to show the boundaries of text boxes. Can be enabled/disabled for individual commands, or set globally with the `set` command. This setting is overriden by `set` and individual commands.
* `custom_colors` (Hash of Colors, default: {}). Defines globally-available colors available to the deck that can be specified in commands.
The following sample demonstrates the config file.
See the `custom_config` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/)
{include:file:samples/custom_config.rb}
# Development
Squib is currently in pre-release alpha, so the API is still maturing. If you are using Squib, however, I'd love to hear about it! Feel free to [file a bug or feature request](https://github.com/andymeneely/squib/issues). Squib is currently in pre-release alpha, so the API is still maturing. If you are using Squib, however, I'd love to hear about it! Feel free to [file a bug or feature request](https://github.com/andymeneely/squib/issues).
## Contributing # Contributing
Squib is an open source tool, and I would love participation. If you want your code integrated: Squib is an open source tool, and I would love participation. If you want your code integrated:

4
lib/squib/api/background.rb

@ -4,8 +4,8 @@ module Squib
# @example # @example
# background color: :white # background color: :white
# #
# @option range [Enumerable] (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts range [Enumerable] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option color [String] (:black) the color the font will render to. See {file:API.md#label-Specifying+Colors Specifying Colors} # @option opts color [String] (:black) the color the font will render to. See {file:README.md#Specifying_Colors Specifying Colors}
# @return [nil] nothing # @return [nil] nothing
# @api public # @api public
def background(opts = {}) def background(opts = {})

12
lib/squib/api/image.rb

@ -8,11 +8,11 @@ module Squib
# @example # @example
# png file: 'img.png', x: 50, y: 50 # png file: 'img.png', x: 50, y: 50
# #
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option opts file [String, Array] ('') file(s) to read in. If it's a single file, then it's use for every card in range. If the parameter is an Array of files, then each file is looked up for each card. If any of them are nil or '', nothing is done. See {file:API.md#Specifying+Files Specifying Files} # @option opts file [String, Array] ('') file(s) to read in. If it's a single file, then it's use for every card in range. If the parameter is an Array of files, then each file is looked up for each card. If any of them are nil or '', nothing is done. See {file:README.md#Specifying_Files Specifying Files}
# @option opts x [Integer] (0) the x-coordinate to place # @option opts x [Integer] (0) the x-coordinate to place
# @option opts y [Integer] (0) the y-coordinate to place # @option opts y [Integer] (0) the y-coordinate to place
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:API.md#label-Custom+Layouts Custom Layouts} # @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
# @option opts alpha [Decimal] (1.0) the alpha-transparency percentage used to blend this image # @option opts alpha [Decimal] (1.0) the alpha-transparency percentage used to blend this image
# @return [nil] Returns nil # @return [nil] Returns nil
# @api public # @api public
@ -32,14 +32,14 @@ module Squib
# @example # @example
# svg 1..2, 'icon.svg', '#stone', x: 50, y:50 # svg 1..2, 'icon.svg', '#stone', x: 50, y:50
# #
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option opts file [String, Array] ('') file(s) to read in. If it's a single file, then it's use for every card in range. If the parameter is an Array of files, then each file is looked up for each card. If any of them are nil or '', nothing is done. See {file:API.md#Specifying+Files Specifying Files} # @option opts file [String, Array] ('') file(s) to read in. If it's a single file, then it's use for every card in range. If the parameter is an Array of files, then each file is looked up for each card. If any of them are nil or '', nothing is done. See {file:README.md#Specifying_Files Specifying Files}
# @option opts id [String] (nil) if set, then only render the SVG element with the given id. Prefix '#' is optional. Note: the x-y coordinates are still relative to the SVG document's page # @option opts id [String] (nil) if set, then only render the SVG element with the given id. Prefix '#' is optional. Note: the x-y coordinates are still relative to the SVG document's page
# @option opts x [Integer] (0) the x-coordinate to place # @option opts x [Integer] (0) the x-coordinate to place
# @option opts y [Integer] (0) the y-coordinate to place # @option opts y [Integer] (0) the y-coordinate to place
# @option opts width [Integer] (:native) the pixel width that the image should scale to. SVG scaling is done with vectors, so the scaling should be smooth. When set to `:native`, uses the DPI and units of the loaded SVG document. # @option opts width [Integer] (:native) the pixel width that the image should scale to. SVG scaling is done with vectors, so the scaling should be smooth. When set to `:native`, uses the DPI and units of the loaded SVG document.
# @option opts height [Integer] (:native) the pixel width that the image should scale to. SVG scaling is done with vectors, so the scaling should be smooth. When set to `:native`, uses the DPI and units of the loaded SVG document. # @option opts height [Integer] (:native) the pixel width that the image should scale to. SVG scaling is done with vectors, so the scaling should be smooth. When set to `:native`, uses the DPI and units of the loaded SVG document.
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:API.md#label-Custom+Layouts Custom Layouts} # @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
# @return [nil] Returns nil # @return [nil] Returns nil
# @api public # @api public
def svg(opts = {}) def svg(opts = {})

4
lib/squib/api/save.rb

@ -3,7 +3,7 @@ module Squib
# Saves the given range of cards to either PNG or PDF # Saves the given range of cards to either PNG or PDF
# #
# @option opts [Enumerable] range (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts [Enumerable] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist. # @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist.
# @option opts [Symbol] format (:png) the format that this will be rendered too. Options `:pdf, :png`. Array of both is allowed: `[:pdf, :png]` # @option opts [Symbol] format (:png) the format that this will be rendered too. Options `:pdf, :png`. Array of both is allowed: `[:pdf, :png]`
# @option opts [String] prefix (card_) the prefix of the file name to be printed # @option opts [String] prefix (card_) the prefix of the file name to be printed
@ -21,7 +21,7 @@ module Squib
# @example # @example
# save range: 1..8, dir: '_pnp', prefix: 'bw_' # save range: 1..8, dir: '_pnp', prefix: 'bw_'
# #
# @option opts [Enumerable] range (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts [Enumerable] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist. # @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist.
# @option opts [String] prefix (card_) the prefix of the file name to be printed. # @option opts [String] prefix (card_) the prefix of the file name to be printed.
# @return [nil] Returns nothing # @return [nil] Returns nothing

2
lib/squib/api/settings.rb

@ -9,7 +9,7 @@ module Squib
# hint text: :cyan # hint text: :cyan
# hint text: :cyan, progress_bar: true # hint text: :cyan, progress_bar: true
# #
# @param [String] text the color of the text hint. To turn off use nil or :off. @see API.md # @param [String] text the color of the text hint. To turn off use nil or :off. @see README.md
# @param [Boolean] progress_bar enable progress bars on long-running operations # @param [Boolean] progress_bar enable progress bars on long-running operations
# @return [nil] Returns nothing # @return [nil] Returns nothing
# @api public # @api public

10
lib/squib/api/shapes.rb

@ -6,7 +6,7 @@ module Squib
# @example # @example
# rect x: 0, y: 0, width: 825, height: 1125, radius: 25 # rect x: 0, y: 0, width: 825, height: 1125, radius: 25
# #
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option opts x [Integer] (0) the x-coordinate to place # @option opts x [Integer] (0) the x-coordinate to place
# @option opts y [Integer] (0) the y-coordinate to place # @option opts y [Integer] (0) the y-coordinate to place
# @option opts width [Integer] the width of the rectangle. # @option opts width [Integer] the width of the rectangle.
@ -17,7 +17,7 @@ module Squib
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle # @option opts fill_color [String] ('#0000') the color with which to fill the rectangle
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle # @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke # @option opts stroke_width [Decimal] (2.0) the width of the outside stroke
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:API.md#label-Custom+Layouts Custom Layouts} # @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
# @return [nil] intended to be void # @return [nil] intended to be void
# @api public # @api public
def rect(opts = {}) def rect(opts = {})
@ -35,7 +35,7 @@ module Squib
# @example # @example
# circle x: 0, y: 0, radius: 100 # circle x: 0, y: 0, radius: 100
# #
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option opts x [Integer] (0) the x-coordinate to place # @option opts x [Integer] (0) the x-coordinate to place
# @option opts y [Integer] (0) the y-coordinate to place # @option opts y [Integer] (0) the y-coordinate to place
# @option opts radius [Integer] (100) radius of the circle # @option opts radius [Integer] (100) radius of the circle
@ -59,7 +59,7 @@ module Squib
# @example # @example
# triangle :x1 => 0, :y1 => 0, :x2 => 50, :y2 => 50, :x3 => 0, :y3 => 50 # triangle :x1 => 0, :y1 => 0, :x2 => 50, :y2 => 50, :x3 => 0, :y3 => 50
# #
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option opts x1 [Integer] (0) the x-coordinate to place # @option opts x1 [Integer] (0) the x-coordinate to place
# @option opts y1 [Integer] (0) the y-coordinate to place # @option opts y1 [Integer] (0) the y-coordinate to place
# @option opts x2 [Integer] (50) the x-coordinate to place # @option opts x2 [Integer] (50) the x-coordinate to place
@ -85,7 +85,7 @@ module Squib
# @example # @example
# triangle :x1 => 0, :y1 => 0, :x2 => 50, :y2 => 50 # triangle :x1 => 0, :y1 => 0, :x2 => 50, :y2 => 50
# #
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option opts x1 [Integer] (0) the x-coordinate to place # @option opts x1 [Integer] (0) the x-coordinate to place
# @option opts y1 [Integer] (0) the y-coordinate to place # @option opts y1 [Integer] (0) the y-coordinate to place
# @option opts x2 [Integer] (50) the x-coordinate to place # @option opts x2 [Integer] (50) the x-coordinate to place

6
lib/squib/api/text.rb

@ -10,7 +10,7 @@ module Squib
# text str: 'hello' # text str: 'hello'
# text str: 'hello', x: 50, y:50, align: center # text str: 'hello', x: 50, y:50, align: center
# #
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges} # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
# @option opts str [String, Array] ('') the string to be rendered. Must support `#to_s`. If the card responds to `#each`, it's mapped out one at a time across the cards. # @option opts str [String, Array] ('') the string to be rendered. Must support `#to_s`. If the card responds to `#each`, it's mapped out one at a time across the cards.
# @option opts font [String] (Arial 36 or whatever was set with `set`) the Font description string, including family, styles, and size. # @option opts font [String] (Arial 36 or whatever was set with `set`) the Font description string, including family, styles, and size.
# (e.g. `'Arial bold italic 12'`) # (e.g. `'Arial bold italic 12'`)
@ -19,11 +19,11 @@ module Squib
# See the {file:samples/text-options.rb samples/text.rb} as well. # See the {file:samples/text-options.rb samples/text.rb} as well.
# @option opts x [Integer] (0) the x-coordinate to place # @option opts x [Integer] (0) the x-coordinate to place
# @option opts y [Integer] (0) the y-coordinate to place # @option opts y [Integer] (0) the y-coordinate to place
# @option opts color [String] (:black) the color the font will render to. See {file:API.md#label-Specifying+Colors Specifying Colors} # @option opts color [String] (:black) the color the font will render to. See {file:README.md#Specifying_Colors Specifying Colors}
# @option opts markup: [Boolean] (false) Enable markup parsing of `str` using the HTML-like Pango Markup syntax, defined [here](http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup) and [here](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html). # @option opts markup: [Boolean] (false) Enable markup parsing of `str` using the HTML-like Pango Markup syntax, defined [here](http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup) and [here](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html).
# @option opts width [Integer, :native] (:native) the width of the box the string will be placed in. Stretches to the content by default. # @option opts width [Integer, :native] (:native) the width of the box the string will be placed in. Stretches to the content by default.
# @option opts height [Integer, :native] the height of the box the string will be placed in. Stretches to the content by default. # @option opts height [Integer, :native] the height of the box the string will be placed in. Stretches to the content by default.
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:API.md#label-Custom+Layouts Custom Layouts} # @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
# @option opts wrap [:none, :word, :char, :word_char, true, false] (:word_char) When height is set, determines the behavior of how the string wraps. The `:word_char` option will break at words, but then fall back to characters when the word cannot fit. # # @option opts wrap [:none, :word, :char, :word_char, true, false] (:word_char) When height is set, determines the behavior of how the string wraps. The `:word_char` option will break at words, but then fall back to characters when the word cannot fit. #
# Options are `:none, :word, :char, :word_char`. Also: `true` is the same as `:word_char`, `false` is the same as `:none`. Default `:word_char` # Options are `:none, :word, :char, :word_char`. Also: `true` is the same as `:word_char`, `false` is the same as `:none`. Default `:word_char`
# @option opts align [:left, right, :center] (:left) The alignment of the text # @option opts align [:left, right, :center] (:left) The alignment of the text

2
lib/squib/graphics/save_doc.rb

@ -6,7 +6,7 @@ module Squib
# @example # @example
# save_pdf file: 'deck.pdf', margin: 75, gap: 5, trim: 37 # save_pdf file: 'deck.pdf', margin: 75, gap: 5, trim: 37
# #
# @option opts file [String] the name of the PDF file to save. # @option opts file [String] the name of the PDF file to save. See {file:README.md#Specifying_Files Specifying Files}
# @option opts dir [String] (_output) the directory to save to. Created if it doesn't exist. # @option opts dir [String] (_output) the directory to save to. Created if it doesn't exist.
# @option opts margin [Integer] (75) the margin around the outside of the page # @option opts margin [Integer] (75) the margin around the outside of the page
# @option opts gap [Integer] (0) the space in pixels between the cards # @option opts gap [Integer] (0) the space in pixels between the cards

Loading…
Cancel
Save