28 changed files with 99 additions and 32 deletions
@ -0,0 +1,28 @@
|
||||
Specifying Colors & Gradients |
||||
============================= |
||||
|
||||
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). The above sample will generate a table of such constants. |
||||
|
||||
Additionally, in most places where colors are allowed, you may also supply a string that defines a gradient. Squib supports two flavors of gradients: linear and radial. Gradients are specified by supplying some xy coordinates, which are relative to the card (not the command). Each stop must be between 0.0 and 1.0, and you can supply as many as you like. Colors can be specified as above (in any of the hex notations or built-in constant). If you add two (or more) colors at the same stop, then the gradient keeps the colors in the in order specified and treats it like sharp transition. |
||||
|
||||
The format for gradient strings look like this: |
||||
|
||||
Linear: |
||||
``` |
||||
(x1,y1)(x2,y2) color1@stop1 color2@stop2 |
||||
``` |
||||
The xy coordinates define the angle of the gradient. |
||||
|
||||
Radial: |
||||
``` |
||||
(x1,y1,radius1)(x2,y2,radius2) color1@stop1 color2@stop2 |
||||
``` |
||||
The coordinates specify an inner circle first, then an outer circle. |
||||
|
||||
Check out the following sample from `samples/gradients.rb`, found [here](https://github.com/andymeneely/squib/tree/master/samples/colors.rb) |
||||
|
||||
{include:file:samples/gradients.rb} |
||||
@ -0,0 +1,17 @@
|
||||
Parameters are Options |
||||
====================== |
||||
|
||||
Squib is all about sane defaults and shorthand specification. Arguments to DSL methods 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. |
||||
|
||||
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` |
||||
Loading…
Reference in new issue