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 }}">
<head>
<meta charset="UTF-8" />
<title></title>
<title>{{ page.title }} cheatsheet</title>
<link href="assets/style.css" rel="stylesheet" />
</head>
<body>

View File

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

View File

@ -3,19 +3,23 @@ title: CSS flexbox
layout: default
---
Basic
.container {
display: flex;
}
.container > div {
flex: 0 0 40px;
flex: 0 1 auto;
/* grow shrink basis */
.container.vertical {
flex-direction: column;
}
Full
.container > div {
flex: /* grow, shrink, basis */;
flex: 0 0 40px; /* fixed width */
flex: 0 1 auto; /* dynamic width */
order: 1;
}
### Full reference
.container {
display: flex;
@ -23,16 +27,16 @@ Full
flex-direction: row; /* ltr - default */
flex-direction: row-reverse; /* rtl */
flex-direction: column; /* top-bottom */
flex-direction: column-reverse; /* bottom-top */
flex-wrap: nowrap; /* one-line */
flex-wrap: wrap; /* multi-line */
align-items: flex-start; /* vertical alignment - default */
align-items: flex-end;
align-items: center;
align-items: flex-start; /* vertically-align to top */
align-items: flex-end; /* vertically-align to bottom */
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-end;
@ -45,6 +49,8 @@ Full
flex-grow: 0;
}
## Tricks
### Vertical center
.container {
@ -59,16 +65,18 @@ Full
### Reordering
.container > .top {
order: 1;
}
.container > .bottom {
order: 2;
}
.container > .top {
order: 1;
}
.container > .bottom {
order: 2;
}
### Mobile layout
A fixed-heighttop bar and a dynamic-height content area.
.container {
display: flex;
flex-direction: column;
@ -83,3 +91,29 @@ Full
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
---
### Harvey
http://harvesthq.github.io/harvey/harvey.js
### Usage
Harvey.attach('(min-width: 600px)', {
@ -17,3 +13,8 @@ layout: default
off: function () {
}
})
### References
* http://harvesthq.github.io/harvey/harvey.js