Jul 21, 2010

Data types in C++

Though very important I often forgot what are the maximum sizes of various data types.

unsigned long:
--------------
0-2147483648. Highest number 2^31

long:
-----

Jul 8, 2010

Image Magick: Drawing some shapes

I need to draw some primitive shapes like circle, rectangle using image magick.
Here are the c++ codes that draws this shape.
Image img = new Image("100x100","black");

Line:
-----
img->draw( DrawableLine( centroid.first, centroid.second, static_cast(ev_x), static_cast(ev_y) ));

Circle Unfilled:
----------------
img->strokeColor("yellow");
img->fillColor("none");
img->draw(DrawableCircle(centroid.first, centroid.second, centroid.first + 25, centroid.second));

This code draws a circle of radius 25 pixels. The arguments it takes are
center_x, center_y, periemter_x, and periemeter_y.
It calculates the radius from the perimeter coordinates. That is why just provide any point on the circle as perimeter_x,perimeter_y.

To draw a filled circle just remove the second line.


Rectangle:
----------
img->draw(DrawableLine(centroid.first - 25, centroid.second - 25, centroid.first + 25, centroid.second - 25));
img->draw(DrawableLine(centroid.first + 25, centroid.second - 25, centroid.first + 25, centroid.second + 25));
img->draw(DrawableLine(centroid.first + 25, centroid.second + 25, centroid.first - 25, centroid.second + 25));
img->draw(DrawableLine(centroid.first - 25, centroid.second + 25, centroid.first - 25, centroid.second - 25));

Draws a rectangle using the lines from the centroid.
Rectangles can also be drawn using DrawableRectangle(). The arguments are respectively,
upper_left_x, upper_left_y, lower_left_x and lower_left_y
img->draw(DrawableLine(centroid.first - 5, centroid.second - 5, centroid.first + 5, centroid.second + 5));
Magick++

Jul 5, 2010

Richard Hadlee and four words

"Cricinfo legends" covers the legendary kiwi All-rounder Sir Richard Hadlee. He holds the record for highest five-fors in test cricket(36), having best match figure of 9/--,6/--(15 wickets in a match). He is the first man to reach 400 plus test wickets. He took wicket at the last ball in his cricket career. When he retired in 1990, his test wickets scalp was 431 in 86 match with an average of 22.3. A true genuine fast bowling all-rounder. Arguably, the best cricketer of New Zealand, one of the best all-rounder of all time. He says whenever he started his run up with the ball, he kept in my four words. 

  •  Rythm 
  •  Off stamp 
  •  Desire
  •  Lilee 


RYTHM to keep his body and mind relaxed(and thereby remaining fit for the game). Targeted the OFF STAMP so that his accuracy with the ball in pitching over the wicket remains consistent enough. DESIRE to take wickets consistently to push the threat of opposition batsman away as much as possible. Finally, he kept in his mind then in form, another great bowler Dennis Lilee of Australia. To Hadlee, Lilee was the epitome of NOT GIVING UP AT ANY SITUATION NO MATTER HOW HARD THE SITUATION WAS. With these four words he became one of the great fast bowler of all time. Here is the documentary Richard Hadlee

Jul 3, 2010

Mac Software: iTunes Alarm

I was looking for a free alarm software for my Macbook. I found iRooster but it is not free. Finally I found iTunes Alarm today.
Here is the link

Carlo Cipolla's Laws of Stupidity

    "By creating a graph of Cipolla's two factors, we obtain four groups of people. Helpless people contribute to society but are...