Exemplo n.º 1
0
void MoSyncStub::drawRect(MARect *rect, uint8 color) {
	int x1 = rect->left;
	int y1 = rect->top;
	int x2 = rect->left + rect->width - 1;
	int y2 = rect->top + rect->height - 1;
	assert(x1 >= 0 && x2 < _screenW && y1 >= 0 && y2 < _screenH);

	setMoSyncColor(color);
	maLine(x1, y1, x2, y1);
	maLine(x2, y1, x2, y2);
	maLine(x2, y2, x1, y2);
	maLine(x1, y2, x1, y1);
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: Felard/MoSync
int MAMain() {
	int x=0, y=0, dx=1, dy=1;
	int scrW, scrH;
	int srcW, srcH;
	{
		int srcSize = maGetImageSize(SIMG);
		srcW = EXTENT_X(srcSize);
		srcH = EXTENT_Y(srcSize);
	}
	maCreateDrawableImage(TIMG, srcW,srcH);
	maSetDrawTarget(TIMG);

	maSetColor(0);	//black
	maFillRect(0,0, srcW,srcH);
	maDrawImage(SIMG, 0,0);
	maSetColor(0xff0000);	//red
	maLine(0,0, srcW,srcH);
	maLine(srcW,0, 0,srcH);

	maSetDrawTarget(HANDLE_SCREEN);
	{
		int scrSize = maGetScrSize();
		scrW = EXTENT_X(scrSize);
		scrH = EXTENT_Y(scrSize);
	}
	while(1) {
		//int then = maGetMilliSecondCount();

		maSetColor(0);	//black
		maFillRect(0,0, scrW,scrH);

		maDrawImage(TIMG, x, y);
		if((dx > 0 && x + srcW > scrW) || (dx < 0 && x < 0)) {
			dx = -dx;
		}
		if((dy > 0 && y + srcH > scrH) || (dy < 0 && y < 0)) {
			dy = -dy;
		}
		x += dx;
		y += dy;
		maUpdateScreen();
		/*{
		int now = maGetMilliSecondCount();
		int time_padding = 10 - (now - then);
		if(time_padding > 0)
		maSleep(time_padding);
		}*/
	}
}
Exemplo n.º 3
0
VALUE method_maLine(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2) {
	//printf("maLine");
	int a = NUM2INT(x1);
	int b = NUM2INT(y1);
	int c = NUM2INT(x2);
	int d = NUM2INT(y2);
	maLine(a, b, c, d);
	return Qnil;
}
Exemplo n.º 4
0
/**
 * Render line object.
 */
void LineObject::render(int width, int height, int znear, int zfar, int xOff, int yOff) {

	int thickness = 2;
	maSetColor(mColor);

	for(int i = 0; i < mCurLines; i++) {
		Vector& p1 = mTransformed[mLines[i].i1];
		Vector& p2 = mTransformed[mLines[i].i2];
		int az = (p1.mZ+p2.mZ)>>1;
		if(az<znear) continue;
		if(az>zfar) continue;
		int x1,y1;
		int x2,y2;
		PROJECT_POINT(x1, y1, p1, width, height);
		PROJECT_POINT(x2, y2, p2, width, height);
		for(int j = thickness-1; j >= 0; j--) {
			maLine(x1-j, y1, x2-j, y2);
			maLine(x1+j, y1, x2+j, y2);
			maLine(x1, y1-j, x2, y2-j);
			maLine(x1, y1+j, x2, y2+j);
		}
	}
}
Exemplo n.º 5
0
Arquivo: t8.c Projeto: Felard/MoSync
int MAMain() {
	const MAExtent scrSize = maGetScrSize();
	const int scrHeight = EXTENT_Y(scrSize);
	const int scrWidth = EXTENT_X(scrSize);
start:	maSetColor(0x808080);
	maFillRect(0, 0, scrWidth, scrHeight);

	maSetColor(0xffffff);
#ifdef STDTEST
	maLine(50, 50, 100, 100);
	maUpdateScreen();
	maLine(50, -50, 100, -100);
	maUpdateScreen();
	maLine(-50, 50, -100, 100);
	maUpdateScreen();
	maLine(-50, -50, -100, -100);
	maUpdateScreen();
	maLine(-10, 20, 20, -10);	//5
	maUpdateScreen();
	maLine(-1, 1, 1, -1);	//6-7
	maUpdateScreen();
	maLine(-20, 10, 10, -20);	//8
	maUpdateScreen();
	maLine(-40, 40, 50, -100);	//9
	maUpdateScreen();
	maLine(172, 226, 176, 205);	//crash test dummy
	maUpdateScreen();
	maLine(-5, 1, 2, -1);
	maUpdateScreen();
#else	//Line pixel test
	maLine(1, 1, 1, 5);
	maUpdateScreen();
	maSetColor(0x00ffff);
	maLine(1, 2, 3, 2);
	maUpdateScreen();
	maSetColor(0xff00ff);
	maLine(2, 3, 0, 3);
	maUpdateScreen();
	maSetColor(0xff80ff);
	maLine(0, 4, 2, 4);
	maUpdateScreen();
	maSetColor(0xffffff);
	maLine(4, 5, 4, 1);
	maUpdateScreen();
#endif

	//Freeze
	while(1) {
		maWait(0);
		MAEvent event;
		if(maGetEvent(&event)) {
			if(event.type == EVENT_TYPE_CLOSE)
				break;
			if(event.type == EVENT_TYPE_KEY_PRESSED) {
				if(event.key == MAK_0)
					break;
			}
		}
		goto start;
	}
	return 0;
}
Exemplo n.º 6
0
	void renderCursor(int h, int w)
	{
		maLine(w, h, w+8, h);
		maUpdateScreen();
	}
void VisueelScherm::update()
{
	//update waarden vam weerdata
	this->weerData->update();

	//stel draw target in op onze tekening
	maSetDrawTarget( this->diagramTekening );

	//teken een staaf diagram

	//legenda
	//teken blokje en text met zonneschijn, neerslag en temperatuur
	maSetColor(0xffffff);
	maDrawText(10, 10, "Legenda");
	maDrawText(10, 25, "Zonneschijn");
	maDrawText(10, 40, "Neerslag");
	maDrawText(10, 55, "Temperatuur");

	//zonneschijn
	maSetColor(0xffff00);
	maFillRect(100, 25, 15, 15);

	//neerslag
	maSetColor(0x0000ff);
	maFillRect(100, 40, 15, 15);

	//temperatuur
	maSetColor(0xff0000);
	maFillRect(100, 55, 15, 15);

	//teken 10-stap lijnen
	maSetColor(0xffffff);

	//grid-lijnen
	for(int i=100; i<=200; i+=10)
	{
		maLine(20, i, 200, i);
	}

	//teken de staven van zonneschijn, neerslag en minimum temperatuur

	// Zonneschijn
	maSetColor(0xffff00);
	maFillRect(30, 100+(100-this->weerData->zonneschijn[0]), 10, this->weerData->zonneschijn[0]); //vandaag
	maFillRect(45, 100+(100-this->weerData->zonneschijn[1]), 10, this->weerData->zonneschijn[1]); //morgen
	maFillRect(60, 100+(100-this->weerData->zonneschijn[2]), 10, this->weerData->zonneschijn[2]); //overmorgen

	// Neerslag
	maSetColor(0x0000ff);
	maFillRect(85, 100+(100-this->weerData->neerslag[0]), 10, this->weerData->neerslag[0]); //vandaag
	maFillRect(100, 100+(100-this->weerData->neerslag[1]), 10, this->weerData->neerslag[1]); //morgen
	maFillRect(115, 100+(100-this->weerData->neerslag[2]), 10, this->weerData->neerslag[2]); //overmorgen

	// Temperatuur
	maSetColor(0xff0000);
	maFillRect(140, 100+(100-this->weerData->minimumtemperatuur[0]), 10, this->weerData->minimumtemperatuur[0]); //vandaag
	maFillRect(155, 100+(100-this->weerData->minimumtemperatuur[1]), 10, this->weerData->minimumtemperatuur[1]); //morgen
	maFillRect(170, 100+(100-this->weerData->minimumtemperatuur[2]), 10, this->weerData->minimumtemperatuur[2]); //overmorgen

	//altijd draw target na tekenen teruggeven naar scherm!
	maSetDrawTarget( HANDLE_SCREEN );

	//update de image met de nieuwe tekening
	this->diagramImage->setResource( this->diagramTekening );
}
Exemplo n.º 8
0
static void soft_line(int x1, int y1, int x2, int y2) {
	maLine(sCurrentOffset.x + x1, sCurrentOffset.y + y1, sCurrentOffset.x + x2, sCurrentOffset.y + y2);
}