Various updates.

This commit is contained in:
Rico Sta. Cruz 2014-06-09 15:12:20 +08:00
parent 0524caea00
commit 1e0f9716ef
4 changed files with 63 additions and 28 deletions

View File

@ -2,7 +2,7 @@
<html lang="en" class="{{ page.html_class }}"> <html lang="en" class="{{ page.html_class }}">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title></title> <title>{{ page.title }} cheatsheet</title>
<link href="assets/style.css" rel="stylesheet" /> <link href="assets/style.css" rel="stylesheet" />
</head> </head>
<body> <body>

View File

@ -3,27 +3,27 @@ title: Chunky PNG
layout: default layout: default
--- ---
Loading ### Loading
image = ChunkyPNG::Image.from_file('filename.png') image = ChunkyPNG::Image.from_file('filename.png')
image = ChunkyPNG::Image.from_blob(File.read('file.png')) image = ChunkyPNG::Image.from_blob(File.read('file.png'))
image = ChunkyPNG::Image.from_io(io) image = ChunkyPNG::Image.from_io(io)
Saving ### Saving
image.save('filename.png') image.save('filename.png')
File.open('newfile.png', 'wb') { |io| image.write(io) } File.open('newfile.png', 'wb') { |io| image.write(io) }
binary_string = image.to_blob binary_string = image.to_blob
Drawing ### Drawing
image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128) image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128)
image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f')) image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f'))
Canvas ### Canvas
crop(x, y, w, h) crop(x, y, w, h)
Transforms ### Transforms
new_image = image.flip_horizontally.rotate_right new_image = image.flip_horizontally.rotate_right

View File

@ -3,19 +3,23 @@ title: CSS flexbox
layout: default layout: default
--- ---
Basic
.container { .container {
display: flex; display: flex;
} }
.container > div { .container.vertical {
flex: 0 0 40px; flex-direction: column;
flex: 0 1 auto;
/* grow shrink basis */
} }
Full .container > div {
flex: /* grow, shrink, basis */;
flex: 0 0 40px; /* fixed width */
flex: 0 1 auto; /* dynamic width */
order: 1;
}
### Full reference
.container { .container {
display: flex; display: flex;
@ -23,16 +27,16 @@ Full
flex-direction: row; /* ltr - default */ flex-direction: row; /* ltr - default */
flex-direction: row-reverse; /* rtl */ flex-direction: row-reverse; /* rtl */
flex-direction: column; /* top-bottom */ flex-direction: column; /* top-bottom */
flex-direction: column-reverse; /* bottom-top */ flex-direction: column-reverse; /* bottom-top */
flex-wrap: nowrap; /* one-line */ flex-wrap: nowrap; /* one-line */
flex-wrap: wrap; /* multi-line */ flex-wrap: wrap; /* multi-line */
align-items: flex-start; /* vertical alignment - default */ align-items: flex-start; /* vertically-align to top */
align-items: flex-end; align-items: flex-end; /* vertically-align to bottom */
align-items: center; align-items: center; /* vertically-align to center */
align-items: stretch; /* same height on all (default) */
justify-content: flex-start; /* horizontal alignment - default */ justify-content: flex-start; /* horizontal alignment - default */
justify-content: flex-end; justify-content: flex-end;
@ -45,6 +49,8 @@ Full
flex-grow: 0; flex-grow: 0;
} }
## Tricks
### Vertical center ### Vertical center
.container { .container {
@ -69,6 +75,8 @@ Full
### Mobile layout ### Mobile layout
A fixed-heighttop bar and a dynamic-height content area.
.container { .container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -83,3 +91,29 @@ Full
flex: 1 0 auto; flex: 1 0 auto;
} }
### Table-like
This creates columns that have different widths, but size accordingly according
to the circumstances.
.container {
display: flex;
}
/* the 'px' values here are just suggested percentages */
.container > .checkbox { flex: 1 0 20px; }
.container > .subject { flex: 1 0 400px; }
.container > .date { flex: 1 0 120px; }
### Vertical
Vertically-center all items.
.container {
align-items: center;
}
### References
* [MDN: Using CSS flexbox](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes)
* [Ultimate flexbox cheatsheet](http://www.sketchingwithcss.com/samplechapter/cheatsheet.html)

View File

@ -3,10 +3,6 @@ title: Harvey.js
layout: default layout: default
--- ---
### Harvey
http://harvesthq.github.io/harvey/harvey.js
### Usage ### Usage
Harvey.attach('(min-width: 600px)', { Harvey.attach('(min-width: 600px)', {
@ -17,3 +13,8 @@ layout: default
off: function () { off: function () {
} }
}) })
### References
* http://harvesthq.github.io/harvey/harvey.js