In the RGB model, The red, green, and blue components of a color are constrained to fall between zero and some maximum value. When all components are at their maximum amount, white light is produced. If all components have an equal value less than 100%, a gray tone is produced. The colors produced by the RGB model are very naturally arranged in a cube: if the red, green, and blue components of a color are plotted along the x, y, and z axes respectively, then a specific color can be located by its coordinates in a three dimensional space.

This RGB cube is very straightforward, but its geometry does not reveal the “colorfulness” or “darkness” of a color in a natural way. An alternate way to describe colors is with the hue, saturation and value (HSV) model. This model is usually geometrically described as a cone, where colors toward the point of the cone are dark (low value), and colors further out are brighter (higher value). Colors toward the central axis of the cone are grayer (lower saturation) than the colors located towards the outer surface of the cone (higher saturation). (We should mention, however, that saturation does not entirely coincide with human perception of “colorfulness.”) Rotating around the axis of the cone changes the hue of the color. Hue can be thought of as the main descriptor of a color independent of its intensity or grayness.

Convert RGB to HSV
Max = maximum {R,G,B}
Min = minimum {R,G,B}
Value = Max
Saturation = (Max – Min) / Value
If Max = R and G ≥ B:
Hue = 60*(G – B)/(Max – Min)
If Max = R and B > G:
Hue = 300 + 60*(B – G)/(Max – Min)
If Max = G:
Hue = 120 + 60*(B – R)/(Max – Min)
If Max = B:
Hue = 240 + 60*(R – G)/(Max – Min)
Tags: 3d, flash, game
Posted in RIA Technology | No Comments »
I just found a great new tool, webkit2png. Just download the file, pull up a terminal window, and type something like:
python webkit2png http://blog.eood.cn
Then you get a full screen picture of my blog.
Tags: png, Python
Posted in Life & Work | No Comments »
How to use Drupal theme variables?
Add the following codes into themplt.php
<?php
yourthemename_preprocess_page(&$variables) {
$variables['happyday'] = 'Happy ' . format_date(time(), 'custom', 'l') . '!';
}
?>
And display the variables in page.tpl.php:
<?php
print $happyday;
?>
Tags: Druapl, theme
Posted in Frontend Design | No Comments »
Complex themes have many different block regions, some regions will only appear on certain pages or when viewing nodes of certain types. One very common use-case is
to have both a page.tpl.php, and a page-front.tpl.php, each of which print out different regions.
How to define block regions in Drupal? Simply add a couple lines in your theme’s .info file:
regions[ad_top] = Ad Top
regions[ad_bottom] = Ad Bottom
regions[front_sidebar] = Front Sidebar
regions[sidebar_ad] = Sidebar Ad
regions[content] = Content
regions[feature_a] = Feature A
regions[feature_b] = Feature B
regions[feature_c] = Feature C
regions[feature_d] = Feature D
And then in your *.tpl.php file, wherever you want the region to appear, simply print out its machine-readable name.
<?php
print $feature_a;
?>
Setting the block’s visibility settings (on the block’s configuration form) to not show up on pages that do not have the region it’s assigned to printed. For example, setting any blocks assigned to the Feature A region to only show up on the <front> page.
Hiding the visibility of the block by some other means; for example, by limiting it to a role using the checkboxes on the block configuration form (or content types in Drupal 7), or installing a contributed module that implements hook_db_rewrite_sql() on the block list.
Tags: Drupal, theme
Posted in Frontend Design | No Comments »
The author of Concurrent Programming in Java: Design Principles and Patterns
The author of Java Concurrency in Practice
Fork Join Framework
Synchronizer Framework
Doug Lea
Tags: java
Posted in IT Reviews | No Comments »