Update layouts of some Ruby sheets

This commit is contained in:
Rico Sta. Cruz 2017-10-15 14:27:15 +08:00
parent 52852bf6d4
commit f2cf246e4e
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
4 changed files with 173 additions and 82 deletions

View File

@ -1,29 +1,54 @@
---
title: Chunky PNG
category: Ruby libraries
layout: 2017/sheet
---
### Loading
image = ChunkyPNG::Image.from_file('filename.png')
```ruby
image = ChunkyPNG::Image.from_file('file.png')
```
#### Alternate ways
```ruby
image = ChunkyPNG::Image.from_blob(File.read('file.png'))
image = ChunkyPNG::Image.from_io(io)
```
Loads from `file.png`.
### Saving
```ruby
image.save('filename.png')
```
#### Alternate ways
```ruby
File.open('newfile.png', 'wb') { |io| image.write(io) }
binary_string = image.to_blob
```
Writes an image to `newfile.png`.
### Drawing
```ruby
image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128)
image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f'))
```
### Canvas
```ruby
crop(x, y, w, h)
```
### Transforms
```ruby
new_image = image.flip_horizontally.rotate_right
```

View File

@ -1,53 +1,77 @@
---
title: PSD.rb
category: Ruby libraries
layout: 2017/sheet
intro: |
[PSD.rb](https://github.com/layervault/psd.rb) parses Photoshop documents in Ruby.
---
### Opening
```ruby
psd = PSD.new(file, parse_layer_images: true)
psd.parse!
```
### Traversing
```ruby
# Gets the root node.
# A #<Node> can be a Group or a Layer.
node = psd.tree
```
```ruby
node.root
node.descendants
node.ancestors
node.siblings
node.subtree
```
```ruby
node.descendant_groups
node.descendant_layers
```
### Layer info
```ruby
node.name #=> "Layer 2"
```
```ruby
node.top #=> 3
node.left #=> 3
node.bottom
node.right
```
```ruby
# Note: these are interchanged (?)
node.width
node.height
```
```ruby
node.visible?
node.hidden?
```
```ruby
node.layer?
node.group?
```
```ruby
node.blending_mode #=> "normal"
node.opacity #=> 0..255
node.fill_opacity #=> 0..255
```
### Layer text
```ruby
node.text #=> (Hash)
node.text[:value] #=> "Text here"
node.text[:font][:name] #=> "Arial"
@ -59,22 +83,30 @@ category: Ruby libraries
node.text[:right]
node.text[:bottom]
node.text[:transform] #=> (Hash)
```
### Layer effects
```ruby
fx = node.info[:object_effects]
```
```ruby
fx.data['Scl '] # ?
fx.data['GrFl'] # Gradient fill
```
### Layer mask
```ruby
node.mask["mask_size"] == 0 # No mask
node.mask["mask_size"] == 20 # Has mask
node.mask["top"]
node.mask["left"]
node.mask["bottom"]
node.mask["right"]
```
### Reference
* https://github.com/layervault/psd.rb
* [layervault/psd.rb](https://github.com/layervault/psd.rb) _(github.com)_

View File

@ -1,9 +1,12 @@
---
title: rack-test
category: Ruby libraries
layout: 2017/sheet
---
```rb
### Methods
```ruby
get 'url'
post 'url', 'name' => 'john'
put
@ -11,7 +14,9 @@ patch
delete
options
head
```
```ruby
authorize 'user', 'pass'
env 'rack.session', csrf: 'token'
header 'Content-Type', 'text/html'

69
ronn.md
View File

@ -1,27 +1,36 @@
---
title: Ronn
category: Ruby libraries
layout: 2017/sheet
intro: |
Ronn generates Man pages. See [ronn(1)](http://rtomayko.github.io/ronn/ronn.1.html), [ronn-format(7)](http://rtomayko.github.com/ronn/ronn-format.7.html). Also see it on GitHub: [rtomayko/ronn](https://github.com/rtomayko/ronn).
---
Ronn generates Man pages. See [ronn(1)](http://rtomayko.github.io/ronn/ronn.1.html), [ronn-format(7)](http://rtomayko.github.com/ronn/ronn-format.7.html). Also see it on GitHub: [rtomayko/ronn](https://github.com/rtomayko/ronn).
{:.center.brief-intro}
## Getting started
{: .-left-reference}
```sh
### Installation
#### Installation
```
gem install ronn
```
{:.light}
```sh
#### Usage
```
ronn foo.1.md # creates foo.1.html
ronn -r foo.1.md # creates foo.1 (--roff)
ronn -r -h foo.1.md # builds --roff and --html
ronn -m foo.1.md # view as manpage
```
{:.light}
## Basic template
Ronn is a Ruby gem.
```markdown
### Basic template
```
name(1) -- short, single-sentence description
=============================================
@ -61,9 +70,21 @@ ronn-format(7), ronn(1)
## Formatting tags
### Inline
#### Bold
```
Bold: `code` **strong**
Underline: <variable> _emphasis_ *emphasis*
`code`
**strong**
```
#### Underline
```
<variable>
_emphasis_
*emphasis*
```
### Linking
@ -71,13 +92,18 @@ Underline: <variable> _emphasis_ *emphasis*
```
Manual references: sh(1) markdown(7)
Sections: [STANDARDS][], [SEE ALSO][], [DIFFERENT TEXT][#SEE-ALSO]
URL: [URL link](http://github.com/rstacruz)
URL: <http://github.com>
```
#### URL links
```
[URL link](http://github.com/rstacruz)
<http://github.com>
```
## Frequently-used sections
```markdown
```
## SYNOPSIS
## DESCRIPTION
## OPTIONS
@ -95,7 +121,7 @@ URL: <http://github.com>
## Other CLI options
```sh
```
--pipe # write to stdout
--server, -S # serve in http://localhost:1207
@ -141,23 +167,26 @@ Place manual files in `man/xxx.1.md`, then in package.json:
```
## JavaScript version
See [marked-man](https://github.com/kapouer/marked-man).
```sh
### marked-man
```
npm install -g marked-man
marked-man foo.1.md > foo.1
```
{:.light}
### Differences
See [marked-man](https://github.com/kapouer/marked-man).
#### Differences
* No definition lists
* Can't use `<br>`
### Mantastic
[mantastic](http://mantastic.herokuapp.com/) is a hosted service.
```
curl -F page=@mymanpage.md http://mantastic.herokuapp.com
```
[mantastic](http://mantastic.herokuapp.com/) is a hosted service. It's not available at the time of writing, I don't know if it'll be back.