first nds demo

Nikolaus Gradwohl2008-08-11T07:13:00+02:00

I got a nintendo DS 2 weeks ago and have hacked my first demo using the arm compilers from devkitPro. To compile the code follow the drunkencoders-Tutorial.

the program initializes the lower screen in a 2d graphics mode, and draws a circle (using the bresenham-algorithm for circles) wherever the screen is touched by the stylus. if the A button is pressed the screen is cleared. No sophisticated doublebuffering, 3d or sound stuff this time - but hey! it's the first program for a nds! and it works! :-)

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

void setPixel( int x, int y, int color ) {
    VRAM_A[x + y * 256] = color;
}

void circle( int mx, int my, int r, int color ) {
    int x = 0;
    int y = r;
    int d = 3 - 2 * r;

    while (x <= y) {
        setPixel( mx  + x, my + y, color );
        setPixel( mx  - x, my + y, color );
        setPixel( mx  - x, my - y, color );
        setPixel( mx  + x, my - y, color );
        setPixel( mx  + y, my + x, color );
        setPixel( mx  - y, my + x, color );
        setPixel( mx  - y, my - x, color );
        setPixel( mx  + y, my - x, color );

        if (d < 0) {
            d = d + 4 * x + 6;
        } else {
            d = d + 4 * ( x - y ) + 10;
            y --;
        }
        x++;
    }
}

int main(void) {
    touchPosition touch;

    videoSetMode(MODE_FB0);
    vramSetBankA(VRAM_A_LCD);

    lcdMainOnBottom();

    while(1) {
        scanKeys();

        if(keysHeld() & KEY_TOUCH) {
            touch=touchReadXY();
            circle( touch.px, touch.py, 20, rand());
        }

        if (keysHeld() & KEY_A) {
            for ( int y = 0; y < 192; y ++ ) {
                for ( int x = 0; x < 256; x ++ ) {
                    setPixel( x, y, 0);
                }
            }
        }
    }
    return 0;
}
read more ...

parallax demo

Nikolaus Gradwohl2008-08-07T06:55:00+02:00

A new processing sketch is online. I have coded a Parallax scrolling demo. All the graphics are drawn by hand - this demo also shows why i'm a coder and not a painter :-)

read more ...

water ripples

Nikolaus Gradwohl2008-07-30T21:34:00+02:00

I have rewritten my Mousetrail processing-sketch to make it look like Water ripples.

read more ...

Povray image

Nikolaus Gradwohl2008-07-24T05:58:00+02:00

While coding my little blob-demo in processing i realized that i had not used povray for a very long time. i have almost forgotten its syntax. Thats why i coded this littly guy :-)

littleguy

#include "colors.inc"

background { color Black }
camera { location <2, 2, -3> look_at  <-1, 1,  2> }
plane { <0,1,0>, -4 texture { pigment { color White }}}

// BODY
sphere { <0,-2,2>,2 texture { pigment { color Green }}}

// HEAD
sphere { <0, 1, 2>, 1 texture { pigment { color Pink }}}

// HAT
sphere { <0, 1.5, 2>, .75 texture { pigment { color Yellow }}}
sphere { <0, 2, 2>,   .5  texture { pigment { color Yellow }}}
sphere { <0, 2.5, 2>, .25 texture { pigment { color Yellow }}}

// NOSE
cone { <0, 1, 2>, 0.25, <0,1,.5>, 0 texture { pigment { color Red }}}

// EYES
sphere { <-0.3,1.3,1.1>,0.1 texture { pigment { color Blue }}}
sphere { <0.3,1.3,1.1>,0.1 texture { pigment { color Blue }}}

light_source {
    <20, 15, -10>
    color White
    area_light <5,0,0>, <0,5,0>, 10,10
    adaptive 1
    jitter
}
read more ...

blob demo

Nikolaus Gradwohl2008-07-21T05:57:00+02:00

And here comes another processing sketch. This time i tried to implement a 2D version of the Blob function from povray.

read more ...

OpenFrameworks Demo

Nikolaus Gradwohl2008-07-20T20:02:00+02:00

this weekend i have written a little c++ program with openframeworks. This is a framework for writing creative programs. it is heavily inspired by processing.

While still in the prerelease state it has some very interesting features and it is realy fun to code with. To get to the download page one has to register for the mailinglist.

To get started copy the emptyExample folder from the apps/examples folder. in the src folder is a empty testApp.cpp and a testApp.h.

the program i have written draws little yellow squares on the screen, that get scared when they hear a sudden loud noise.

my testApp.h looks like this

#ifndef _TEST_APP
#define _TEST_APP


#include "ofMain.h"
#include "ofAddons.h"

class testApp : public ofSimpleApp{

    public:

        void setup();
        void update();
        void draw();

        void keyPressed(int key);
        void keyReleased(int key);
        void mouseMoved(int x, int y );
        void mouseDragged(int x, int y, int button);
        void mousePressed(int x, int y, int button);
        void mouseReleased();
        void audioReceived( float *input, int bufferSize, int nChannels );

        int boom;
};

#endif

my testApp.cpp looks like this

#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
    boom = 0;
    ofSetVerticalSync( true );
    ofSetFrameRate( 25 );
    ofSoundStreamSetup(0,1,this);
}   

//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
    ofBackground( 0,0,0 );
    int sx = 0;
    int sy = 0;
    if (boom>0) {
        ofSetColor(255,0,0);
        boom = boom -2;
    } else {
        ofSetColor(255,255,0);
    }
    ofFill();
    for ( int x=0; x < 11; x++ ) {
        for ( int y = 0; y < 7; y++ ) {
            if ( boom > 0 ) {
                sx = 10 * ofRandomf();
                sy = 10 * ofRandomf();
            }
            ofRect(sx + x*120 + 20, sy + y*120 + 20, 100, 100);
        }
    }
}

//--------------------------------------------------------------
void testApp::keyPressed  (int key){ 
}

//--------------------------------------------------------------
void testApp::keyReleased  (int key){ 
}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}

//--------------------------------------------------------------
void testApp::mouseReleased(){
}

void testApp::audioReceived (float * input, int bufferSize, int nChannels) {
    int count = 0;
    for( int i=0; i<bufferSize; i++ ) {
        if (input[i] > 0.3 || input[i] < -0.3 ) {
            count++;
        } 
    }
    if ( count > 10 ) {
        boom = 25;
    }
}
read more ...

evil mango of death

Nikolaus Gradwohl2008-07-18T10:41:00+02:00

Today i saw a can of "mango pulp" in the kitchen of our office. i have no idea what "mango pulp" is - but im not sure i would like to eat something that looks at me like this >:-]

mango of death

read more ...

Wobbly Dragon Egg

Nikolaus Gradwohl2008-07-14T20:46:00+02:00

I have written a processing sketch again. This time it took me 15 minutes, and it visualizes a wobbly dragon egg

read more ...

Erlang OSC Dispatcher

Nikolaus Gradwohl2008-07-14T07:10:00+02:00

I have started a Project to write and osc message dispatcher in erlang. I want to use it to dispatch the data from my icontrol chuck script to other soundgenerating scripts or visualisation programms.

read more ...

Chuck iControl Projectpage

Nikolaus Gradwohl2008-07-14T06:46:00+02:00

as written before, i have started writing a chuck script that mapps the midi-data from my iControl to OSC events. I now have set up a proper project page for the script.

read more ...