Wednesday, October 28, 2009

PS3 is gaining market!

A few days ago there was a news telling Netflix will be available on Sony PS3.  This a good news for PS3 folks who have been inquiring Netflix when they are going to support PS3, besides XBox 360 which has been available for quite some time.

With more and more features added into PS3, not to count the price has also come down, it is now a good time to have a PS3 console as your center of home entertainment.  For a cost of $299+tax, we can get a powerful station capable of playing Bluray discs, playing games (in hi quality plus in 1080p), playing music CDs or MP3, it can also become a multimedia center to access the internet (browsing, emailing) and now to watch video streaming online.  That's all will cost us $$ more if we buy individual units.

Oh, don't forget to get that Sony Bluetooh remote control.  Nothing can be easier now!

Monday, October 12, 2009

Bresenham Algorithm

#include <stdlib.h>
#include <stdio.h>

//extern int plot(int x, int y);

int plot(int x, int y, int color)
{
    printf("plot(%d, %d, %d)\n", x, y, color);

}


void swap(int *a, int *b)
{
    int tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
    printf("swap %d with %d\n", a, b);

}



int line(int x1, int y1, int x2, int y2, int color)
{
    int steep;
    int deltax, deltay;
    int e, x, y, y_step;

    steep = (abs(y2 - y1) > (x2 - x1));

    if (steep) {
        swap(&x1, &y1);
        swap(&x2, &y2);
    }
    if (x1 > x2) {
        swap(&x1, &x2);
        swap(&y1, &y2);
    }
    deltax = x2 - x1;
    deltay = abs(y2 - y1);
    e = x1;
    y = y1;
    if (y1 < y2) {
        y_step = 1;
    } else
        y_step = -1;
    for (x = x1; x <= x2; x++) {
        if (steep)
            plot(y, x, color);
        else
            plot(x, y, color);
        e += deltay;
        if (2 * e >= deltax) {
            y += y_step;
            e -= deltax;
        }
    }
    return 0;
}


int main()
{
    int x1, x2, y1, y2, color;

    x1 = 0;
    y1 = 0;
    x2 = 50;
    y2 = 65;
    color = 1;

    line(x1, y1, x2, y2, color);
}
~
~