Computer-Ag am WvS Blog der Computer-AG am Werner von Siemens Gymnasium Berlin

18. Februar 2015

18.2.2015

Angelo, Moritz, Morten und Julian sind da. Johannes kann nicht. Angelo arbeitet am Gras vom PC-GTA.

Robert recherchiert mal wieder wegen App-Entwicklung. Dazu findet sich ein Selfhtml-Thread. Bei der Hamburger Appwerft gibt es einen Artikel zu Phonegap vs. Titanium. Smasshingmagazine hat auch einen Artikel dazu vom März 2014. U.a. hat Titanium Appcelerator das „look and feel“ einer nativen App. Infoworld vergleicht 5 App-Entwicklungs-Umgebungen (sog. MBaas: AnyPresence, Appcelerator, FeedHenry, Kinvey, und Parse). Cordovablogs hat auch einen Beitrag, in dem auch Xamarin erwähnt ist. Die Diskussion geht dann bei Stackoverflow weiter.

Das Thema Websockets kommt dann wieder auf, und auch, dass es das bei Plan9 nicht gibt.

Auf App-Entwicklung gibt es noch einen spezifischen Beitrag zu den Hürden in PhoneGap.

Xamarin ist gemäß Heiseartikel sperrig und teuer.

Angelo ist von seinem Gras genervt und sein Rasterisierer funktioniert auch nicht richtig.

Nächsten Freitag findet statt.

 

 

13. Februar 2015

13.2.2015

Heute sind Morten und Angelo da, immerhin. Wir reden über die Evangelien, Thomas, Judas und das 1. Konzil in Nicaea.

Wir besprechen noch diese Codezeile bzw. die Zeile in der Funktion:

void
drawPixel(int x, int y, Color c)
{
    *( (Uint32*) ( (char*) screen->pixels + x*screen->format->BytesPerPixel + y*screen->pitch ) ) = SDL_MapRGB(screen->format, c.r, c.g, c.b);
}

In der Funktion müsste man eigentlich noch x testen, dass es nicht größer als die maximale Breite ist. Zu deutsch also:

an die Adresse [*] schreibe vier Bytes (gecastet nach (Uint32*)) eines Pointers auf einen Character (char*), nämlich den Pointer screen->pixels plus x Mal die Länge eines Pixels in Bytes plus y Mal die Zeilenlänge. Ob das so stimmt?

Wir rätseln, wann die anderen mal wieder kommen …;

 

 

 

23. Januar 2015

23.1.2015

Morten, Johannes und Angelo sind da. Der Code wird perfektioniert:

 

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <SDL/SDL.h>

typedef struct _Color Color;
struct _Color 
{
    unsigned char r, g, b;
};

typedef struct _Point Point;
struct _Point
{
    int x, y;
};

SDL_Surface *screen;

void
drawPixel(int x, int y, Color c)
{
    *((Uint32*)((char*)screen->pixels + x*screen->format->BytesPerPixel + y*screen->pitch)) = SDL_MapRGB(screen->format, c.r, c.g, c.b);
}

void
drawLine(Point p1, Point p2, Color c)
{
    int dx, dy;
    int incx, incy;
    float m;
    dx = p2.x - p1.x;
    dy = p2.y - p1.y;
    incx = dx>0 ? 1 : -1;
    incy = dy>0 ? 1 : -1;
    if(dx == 0){
        int y;
        for(y = p1.y; y != p2.y; y += incy)
            drawPixel(p1.x, y, c);
        return;
    }

    if(abs(dx)>abs(dy)){
        int x;
        float y;
        m = (float)dy/(float)abs(dx);
        y = p1.y;
        for(x = p1.x; x != p2.x; x += incx){
            drawPixel(x, y+0.5f, c);
            y += m;
        }
    }else{
        int y;
        float x;
        m = (float)dx/(float)abs(dy);
        x = p1.x;
        for(y = p1.y; y != p2.y; y += incy){
            drawPixel(x+0.5f, y, c);
            x += m;
        }
    }
}

void
drawTriWire(Point p1, Point p2, Point p3, Color c)
{
    drawLine(p1, p2, c);
    drawLine(p2, p3, c);
    drawLine(p3, p1, c);
}

void
drawHorizontalLine(int y, float x1f, float x2f, Color c) {
    int x1, x2, tmp;
    x1 = (x1f == (int)x1f) ? x1f : x1f+1;
    x2 = (x2f == (int)x2f) ? x2f : x2f+1;
    if(x1 > x2){
        tmp = x1;
        x1 = x2;
        x2 = tmp;
    }
    while(x1 < x2)
        drawPixel(x1++, y, c);
}

void
//~ sortPoints(Point **p) ident mit zeile drunter, for educational purpose only 
sortPoints(Point *p[])
{
#define SWAPPOINT(p,q) { \
        tmp = p;      \
        p = q;     \
        q = tmp;      \
    }
    Point *tmp;
    if(p[0]->y > p[1]->y) 
        SWAPPOINT(p[0], p[1]);
    if(p[0]->y > p[2]->y)
        SWAPPOINT(p[0], p[2]);
    if(p[1]->y > p[2]->y) 
        SWAPPOINT(p[1], p[2]);
#undef SWAPPOINT
}

void
drawTriFlat(Point p1, Point p2, Point p3, Color c)
{
    float dx[3];
    int y;
    float x1, x2;
    Point *p[] = {&p1, &p2, &p3};
    sortPoints(p);
#define D(p,q) (q->y - p->y == 0 ? 0.0f : (float) (q->x - p->x) / (q->y - p->y))
    //~ dx[0] = (float) (p[2]->x - p[0]->x) / (p[2]->y - p[0]->y);
    dx[0] = D(p[0], p[2]);
    dx[1] = D(p[0], p[1]);
    dx[2] = D(p[1], p[2]);
#undef D
    y = p[0]->y;
    x1 = x2 = p[0]->x;
    while(y < p[1]->y){
        drawHorizontalLine(y, x1, x2, c);
        y++;
        x1 += dx[0];
        x2 += dx[1];
    }
    x2 = p[1]->x;
    while(y < p[2]->y){
        drawHorizontalLine(y, x1, x2, c);
        y++;
        x1 += dx[0];
        x2 += dx[2];
    }
}



void
drawRect(Point p1, Point p2, Color rgb)
{
    int i, j;
       for(i = p1.x; i < p2.x; i++)
        for(j = p1.y; j < p2.y; j++)
            drawPixel(i, j, rgb);
}

void
draw(void)
{
    drawRect((Point){40,140}, (Point){50,150}, (Color) {255, 0, 255});
    drawRect((Point){80,140}, (Point){90,150}, (Color) {255, 0, 255});
    drawRect((Point){62,160}, (Point){68,180}, (Color) {10, 123, 233});
    drawRect((Point){40,195}, (Point){90,200}, (Color) {123, 233, 10});
    
//    drawLine((Point){0, 0}, (Point){50, 30});
//    drawLine((Point){0, 0}, (Point){30, 50});
//    drawLine((Point){50, 0}, (Point){50, 50});
        drawTriFlat((Point){30,120}, (Point){100, 120}, (Point){65, 100}, (Color){25, 85, 155});
}

int
main(void)
{
    int running = 1;
    int w = 640;
    int h = 480;
    SDL_Event event;

    SDL_Init(SDL_INIT_VIDEO);

    screen = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE);

    while(running){
        while(SDL_PollEvent(&event))
            if(event.type == SDL_QUIT)
                running = 0;
        SDL_LockSurface(screen);
        draw();
        SDL_UnlockSurface(screen);
        SDL_UpdateRect(screen, 0, 0, 0, 0);
    }

    SDL_Quit();
    return 0;
}

bringt:

 

test3

 

Angelo will keine Kreise machen.

#include 
#include 
#include 
#include <SDL/SDL.h>
#include 
typedef struct _Color Color;
struct _Color 
{
    unsigned char r, g, b;
};

typedef struct _Point Point;
struct _Point
{
    int x, y;
};

SDL_Surface *screen;

void
drawPixel(int x, int y, Color c)
{
    *((Uint32*)((char*)screen->pixels + x*screen->format->BytesPerPixel + y*screen->pitch)) = SDL_MapRGB(screen->format, c.r, c.g, c.b);
}

void
drawLine(Point p1, Point p2, Color c)
{
    int dx, dy;
    int incx, incy;
    float m;
    dx = p2.x - p1.x;
    dy = p2.y - p1.y;
    incx = dx>0 ? 1 : -1;
    incy = dy>0 ? 1 : -1;
    if(dx == 0){
        int y;
        for(y = p1.y; y != p2.y; y += incy)
            drawPixel(p1.x, y, c);
        return;
    }

    if(abs(dx)>abs(dy)){
        int x;
        float y;
        m = (float)dy/(float)abs(dx);
        y = p1.y;
        for(x = p1.x; x != p2.x; x += incx){
            drawPixel(x, y+0.5f, c);
            y += m;
        }
    }else{
        int y;
        float x;
        m = (float)dx/(float)abs(dy);
        x = p1.x;
        for(y = p1.y; y != p2.y; y += incy){
            drawPixel(x+0.5f, y, c);
            x += m;
        }
    }
}

void
drawTriWire(Point p1, Point p2, Point p3, Color c)
{
    drawLine(p1, p2, c);
    drawLine(p2, p3, c);
    drawLine(p3, p1, c);
}

void
drawHorizontalLine(int y, float x1f, float x2f, Color c) {
    int x1, x2, tmp;
    x1 = (x1f == (int)x1f) ? x1f : x1f+1;
    x2 = (x2f == (int)x2f) ? x2f : x2f+1;
    if(x1 > x2){
        tmp = x1;
        x1 = x2;
        x2 = tmp;
    }
    while(x1 < x2)         drawPixel(x1++, y, c); } void //~ sortPoints(Point **p) ident mit zeile drunter, for educational purpose only  sortPoints(Point *p[]) { #define SWAPPOINT(p,q) { \         tmp = p;      \         p = q;     \         q = tmp;      \     }     Point *tmp;     if(p[0]->y > p[1]->y) 
        SWAPPOINT(p[0], p[1]);
    if(p[0]->y > p[2]->y)
        SWAPPOINT(p[0], p[2]);
    if(p[1]->y > p[2]->y) 
        SWAPPOINT(p[1], p[2]);
#undef SWAPPOINT
}

void
drawTriFlat(Point p1, Point p2, Point p3, Color c)
{
    float dx[3];
    int y;
    float x1, x2;
    Point *p[] = {&p1, &p2, &p3};
    sortPoints(p);
#define D(p,q) (q->y - p->y == 0 ? 0.0f : (float) (q->x - p->x) / (q->y - p->y))
    //~ dx[0] = (float) (p[2]->x - p[0]->x) / (p[2]->y - p[0]->y);
    dx[0] = D(p[0], p[2]);
    dx[1] = D(p[0], p[1]);
    dx[2] = D(p[1], p[2]);
#undef D
    y = p[0]->y;
    x1 = x2 = p[0]->x;
    while(y < p[1]->y){
        drawHorizontalLine(y, x1, x2, c);
        y++;
        x1 += dx[0];
        x2 += dx[1];
    }
    x2 = p[1]->x;
    while(y < p[2]->y){
        drawHorizontalLine(y, x1, x2, c);
        y++;
        x1 += dx[0];
        x2 += dx[2];
    }
}



void
drawRect(Point p1, Point p2, Color rgb)
{
    int i, j;
   	for(i = p1.x; i < p2.x; i++)
		for(j = p1.y; j < p2.y; j++)
			drawPixel(i, j, rgb);
}

void 
drawCircle(Point center, int radius, Color c) {
    Point p;
    int x;
    int y;
    for(x = 0; x < radius; x++){
        y = sqrt(radius*radius - x*x);
        drawLine((Point) {center.x + x, center.y + y}, (Point) {center.x + x, center.y - y}, c); 
        drawLine((Point) {center.x - x, center.y + y}, (Point) {center.x - x, center.y - y}, c); 
    }

}

void
draw(void)
{
    drawCircle((Point){65, 170}, 45, (Color) {128, 128, 0});
    drawRect((Point){40,140}, (Point){50,150}, (Color) {255, 0, 255});
    drawRect((Point){80,140}, (Point){90,150}, (Color) {255, 0, 255});
    drawRect((Point){62,160}, (Point){68,180}, (Color) {10, 123, 233});
    drawRect((Point){40,195}, (Point){90,200}, (Color) {123, 233, 10});
    
//    drawLine((Point){0, 0}, (Point){50, 30});
//    drawLine((Point){0, 0}, (Point){30, 50});
//    drawLine((Point){50, 0}, (Point){50, 50});
        drawTriFlat((Point){30,120}, (Point){100, 120}, (Point){65, 100}, (Color){25, 85, 155});
}

int
main(void)
{
	int running = 1;
	int w = 640;
	int h = 480;
	SDL_Event event;

	SDL_Init(SDL_INIT_VIDEO);

	screen = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE);

	while(running){
		while(SDL_PollEvent(&event))
			if(event.type == SDL_QUIT)
				running = 0;
		SDL_LockSurface(screen);
		draw();
		SDL_UnlockSurface(screen);
		SDL_UpdateRect(screen, 0, 0, 0, 0);
	}

	SDL_Quit();
	return 0;
}

chinese

Nächste Woche ist nicht.

 

Angelo orientiert sich nach dem GS UsersManual für die PS2.

21. Januar 2015

21.1.2015

Morten ist da. Wir reden über Windows ultimate. Und Ableton.

Jetzt sieht der Code so aus:

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <SDL/SDL.h>

typedef struct _Color Color;
struct _Color 
{
    unsigned char r, g, b;
};

typedef struct _Point Point;
struct _Point
{
    int x, y;
};

SDL_Surface *screen;

void
drawPixel(int x, int y, Color c)
{
    *((Uint32*)((char*)screen->pixels + x*screen->format->BytesPerPixel + y*screen->pitch)) = SDL_MapRGB(screen->format, c.r, c.g, c.b);
}

void
drawLine(Point p1, Point p2, Color c)
{
    int dx, dy;
    int incx, incy;
    float m;
    dx = p2.x - p1.x;
    dy = p2.y - p1.y;
    incx = dx>0 ? 1 : -1;
    incy = dy>0 ? 1 : -1;
    if(dx == 0){
        int y;
        for(y = p1.y; y != p2.y; y += incy)
            drawPixel(p1.x, y, c);
        return;
    }

    if(abs(dx)>abs(dy)){
        int x;
        float y;
        m = (float)dy/(float)abs(dx);
        y = p1.y;
        for(x = p1.x; x != p2.x; x += incx){
            drawPixel(x, y+0.5f, c);
            y += m;
        }
    }else{
        int y;
        float x;
        m = (float)dx/(float)abs(dy);
        x = p1.x;
        for(y = p1.y; y != p2.y; y += incy){
            drawPixel(x+0.5f, y, c);
            x += m;
        }
    }
}

void
drawTriWire(Point p1, Point p2, Point p3, Color c)
{
    drawLine(p1, p2, c);
    drawLine(p2, p3, c);
    drawLine(p3, p1, c);
}

void
drawRect(Point p1, Point p2, Color rgb)
{
    int i, j;
       for(i = p1.x; i < p2.x; i++)
        for(j = p1.y; j < p2.y; j++)
            drawPixel(i, j, rgb);
}

void
draw(void)
{
    drawRect((Point){40,40}, (Point){50,50}, (Color) {255, 0, 255});
    drawRect((Point){80,40}, (Point){90,50}, (Color) {255, 0, 255});
    drawRect((Point){62,60}, (Point){68,80}, (Color) {10, 123, 233});
    drawRect((Point){40,95}, (Point){90,100}, (Color) {123, 233, 10});
    
//    drawLine((Point){0, 0}, (Point){50, 30});
//    drawLine((Point){0, 0}, (Point){30, 50});
//    drawLine((Point){50, 0}, (Point){50, 50});
        drawTriWire((Point){10,10}, (Point){100, 70}, (Point){30, 150}, (Color){255, 255, 255});
}

int
main(void)
{
    int running = 1;
    int w = 640;
    int h = 480;
    SDL_Event event;

    SDL_Init(SDL_INIT_VIDEO);

    screen = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE);

    while(running){
        while(SDL_PollEvent(&event))
            if(event.type == SDL_QUIT)
                running = 0;
        SDL_LockSurface(screen);
        draw();
        SDL_UnlockSurface(screen);
        SDL_UpdateRect(screen, 0, 0, 0, 0);
    }

    SDL_Quit();
    return 0;
}

 

Und das Resutlat so:

 

 

c2

Nächste Mal dann Ausfüllen von Dreiecken, 3D-Rotation und Kreise …;

Morten bastelt daran rum, wie ein Spiel unter Windows startet …;

Diesen Freitag ist noch einmal, dann zwei Wochen Pause.

 

16. Januar 2015

16.1.2015

Filed under: Allgemein,Lernserver,Schulnetzwerk,Termine — admin @ 15:46

Morten, Johannes und Willi sind da. Die Rechner fahren sehr langsam hoch, weil da jetzt Android-Studio installiert ist (sagte und Frau Spyra).

Angelo demonstrierte letzt Mal noch Syntaxhighlighting:

Morten, Johannes und Willi reden über Minecraftserver. Und darüber, mit welcher Tastenkombination sich neue Fenster im Browser öffnen lassen bzw. neue Tabs (strg-T). Mit strg-N geht ein neues Fenster auf. Mit strg-Shift-N geht das zuletzt geschlossene Fenster wieder auf mit der Seite, die dort zuletzt aufgerufen war. Angelo kommt auch.

Wir wollen was mit SDL machen. Geht auch in der TTY-Konsole.

Dieser Code …

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <SDL/SDL.h>

void
draw(SDL_Surface *screen)
{
    int i, j;
#define P(x,y) ((Uint32*)((char*)screen->pixels + x*screen->format->BytesPerPixel + y*screen->pitch))

    for (i=40; i<50; i++) {
        for (j=40; j<50; j++) {
            *P(i,j) = SDL_MapRGB(screen->format, 255, 0, 255);
        }
    }
    for (i=80; i<90; i++) {
        for (j=40; j<50; j++) {
            *P(i,j) = SDL_MapRGB(screen->format, 255, 0, 255);
        }
    }
    for (i=62; i<68; i++) {
        for (j=60; j<80; j++) {
            *P(i,j) = SDL_MapRGB(screen->format, 10, 123, 233);
        }
    }
    for (i=40; i<90; i++) {
        for (j=95; j<100; j++) {
            *P(i,j) = SDL_MapRGB(screen->format, 123, 233, 10);
        }
    }
#undef P
}

int
main(void)
{
    int running = 1;
    int w = 140;
    int h = 140;
    SDL_Surface *screen;
    SDL_Event event;

    SDL_Init(SDL_INIT_VIDEO);

    screen = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE);


    while (running) {
        while(SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT) {
                running = 0;
            }
        }
        SDL_LockSurface(screen);
        draw(screen);
        SDL_UnlockSurface(screen);
        SDL_UpdateRect(screen, 0, 0, 0, 0);
    }

    SDL_Quit();
    return 0;
}

 

… macht das, wenn man ihn mit cc src.c -lSDL kompiliert:

 

sdl-test

Moritz war auch da. Nächste Woche noch ganz normal, dann zwei Wochen Pause, eine Woche ist Robert weg, dann sind Winterferien.

14. Januar 2015

14.1.2015

Heute ist Tag der offenen Tür. Deshalb vermutlich nicht ganz so lange. Morten hat Probleme mit Pidgin und MSN. Wir reden über Abmahnung. S.a. Infos zu Waldorf Frommer. Angelo nutzt übrigens nicht Pidgin sondern BitlBee. Das übersetzt auf IRC. Angelo arbeitet dann mit Tmux. Damit kann man Terminalsessions teilen und splitten. Angelo nutzt QEmu um Windows laufen zu lassen. Das kann emulieren und virtualisieren (aber auf FreeBSD kann es nur emulieren, das Kernelmodul für Virutalisierung gibt es da noch nicht). Wir sprechen über die Ausnahmlosigkeit der Lautgesetze (Junggrammatiker Ende des 19. Jahrhunderts). Kurz schrammen wir noch am rheinischen Fächer vorbei.

9. Januar 2015

9.1.2015

Filed under: Allgemein,Computer,Lernserver,Schulnetzwerk,Termine,Tisch — admin @ 15:42

Es stürmt. Frau Spyra kam und wir sprachen über die Installation von Android Studio. Überlegung war, eine Portable Version zu benutzen. Außerdem haben wir herausgefunden, was eine Denic-Mitgliedschaft kostet. Nächste und übernächste Woche findet die AG noch statt, die Woche vor den Winterferien, am 28. und 30. Januar, nicht. Moritz programmiert einen Downloadmanager für xdcc in C bzw. in C++. Johannes versucht eine virtuelle Maschine von Windows-XP zu installieren. Robert versucht seine FritzBox von außerhalb zu konfigurieren.

7. Januar 2015

7.1.2015

Morten und Angelo sind da. Frau Kannenberg kam auch, wir haben über Photoshop und grafische Tools gesprochen. Da findet sich bei Photoshop ein Online-Tool. Angelo kann von der PS2 Gebäude auslesen und mit seinem selbst programmierten Grafiktool darstellen lassen. Canvas-Tests liegen im Homefolder von rob bei public_html (s.a. hier). Mortens Arbeiten bezgüglich Datenbank hatten wir hoffentlich schon verlinkt. Roberts Test hoffentlich auch. Morten und Angelo zocken bissel GTA. Am Freitag findet AG statt, normal.

12. Dezember 2014

12.12.2014

Filed under: Allgemein,Computer,Tagesberichte,Termine,Tisch — admin @ 16:14

Morten ist da und arbeitet weiter mit PHP und HTML. Angelo ist auch da, mit seinem GTA-Viewer. Willi ist auch da. Moritz auch. Johannes ist auch da und will was mit AJAX machen – der Weihnachtsmann hier ist übrigens mit AJAX.


getStatus = function() {
var startStopPage = "laufen.js.php?checkMyTurn";
var	myAjax=new XMLHttpRequest();
	myAjax.open("GET",startStopPage,true);
	myAjax.onreadystatechange=function()  {
		if (myAjax.readyState==4 && myAjax.status==200)     {
			if ("start" == myAjax.responseText.toString() && finished == 0) {
				status = "start";
				move();
			} else {
				status = "stop";
				setTimeout("getStatus()",1000);
			}
		}
	}
	myAjax.send(null);
}

Wir reden über Cubricks Clockwork Orange und 2001. Nächstes Mal ist nur Freitag. Dann auch das letzte mal in diesem Jahr. Mit Weihnachtsmann.

 

 

 

weihnachtsmann

3. Dezember 2014

3.12.2014

Angelo und Morten sind da. Angelo demonstriert seine GTA-Reflexionen. Robert probiert mit dem Zendframework-DB-Adapter. Test hier.

<pre>
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once 'Zend/Loader/StandardAutoloader.php';
$loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
//~ use Zend\Mail\Message;
//~ $message = new Message();
echo "test12";
$configArray = array(
    'driver' => 'PDO_MySQL',
    'database' => 'XXX',
    'username' => 'XXX',
    'password' => 'XXX'
 );
 
 $configArray = array(
    'driver' => 'Mysqli',
    'database' => 'exen',
    'username' => 'notexen',
    'password' => 'correcthorsebatterystable'
 );
$adapter = new Zend\Db\Adapter\Adapter($configArray);
//$stmt= $adapter->query('SELECT * FROM `exen_liste_new`WHERE *');
//var_dump($stmt);
//~ $res = stmt->execute();
//~ $row = $res->current();
//~ var_dump($row);
$sql = 'SELECT * FROM `exen_liste_new` WHERE 1';
$statement = $adapter->createStatement($sql);
$results = $statement->execute();
var_dump($results->current());
$results->next();
var_dump($results->current());
//~ var_dump($results->toArray());

Das alles für Frau Trümer-Portella. Angelo ist nicht komplett ausgelastet. Am Freitag arbeiten wir „was richtiges“.



	
« Newer PostsOlder Posts »