//wordt elke "tick" aangeroepen om het winterlandschap, sneeuwman en sneeuwvlokken te tekenen void SneeuwLandschap::draw() { //kleur de lucht blauw maSetColor( 0x0055ff ); maFillRect( 0, 0, screenWidth, screenHeight ); //maak sneeuw op de grond, a.d.h.v. sneeuwHoogte maSetColor( 0xffffff ); maFillRect( 0, screenHeight - this->sneeuwHoogte, screenWidth, this->sneeuwHoogte ); //TODO: teken de sneeuwman sneeuwMan->draw(); //TODO: teken alle sneeuwvlokken for(int i = 0; i <this->sneeuwVlokArray.size();i++) { this->sneeuwVlokArray[i]->draw(); if(this->sneeuwVlokArray[i]->isDead()) { delete sneeuwVlokArray[i]; sneeuwVlokArray.remove(i); } } }
/** * This function will be called whenever the moblet has nothing else to do, * drawing rectangles with the touchIds where the fingers touches the * screen. The amount of touches possible on a device is platform dependent. * * In the MoRE emulator you can simulate multitouch by right-clicking the screen. * This will simulate two touches, mirrored around the center of the screen. * Each of these two touches will be marked with a blue circle. */ void idle() { // Clear the screen by drawing a black rectangle covering the visible area. maSetColor(0); int screenSize = maGetScrSize(); maFillRect(0, 0, EXTENT_X(screenSize), EXTENT_Y(screenSize)); // Loop through all the current touches and draw for each a rectangle // and the touch id. for(MAUtil::Map<int, MAPoint2d>::Iterator iterator = mTouches.begin(); iterator != mTouches.end(); iterator++) { MAPoint2d point = iterator->second; int touchId = iterator->first; char touchStr[16]; sprintf(touchStr, "%d", touchId); // Draw a red rectangle, centred around the touch position maSetColor(0xff0000); maFillRect(point.x - (MARKER_SIZE/2), point.y - (MARKER_SIZE/2), MARKER_SIZE, MARKER_SIZE); // Draw the touch id to the top-left of each red rectangle. maSetColor(0xffffff); maDrawText(point.x + (MARKER_SIZE/2), point.y - (MARKER_SIZE/2), touchStr); } maUpdateScreen(); }
void TestMoblet::testLoadWithName() { mShowing = 2; maSetColor(0x000000); MAExtent size = maGetScrSize(); maFillRect(0,0,EXTENT_X(size),EXTENT_Y(size) ); maSetColor(0xCD5555); int top = 0; maDrawText(10,top,"--------- Test maFontLoadWithName(test each name from list) --------- "); top += 20; for (int i=0; i<fontNames.size(); i++) { top += 20; int handle = maFontLoadWithName(fontNames[i].c_str(), 15); if ( handle == RES_FONT_NAME_NONEXISTENT ) { message = "Font nonexistent: " + fontNames[i]; maDrawText(10,top, message.c_str()); } else { maFontSetCurrent(handle); message = "Font " + fontNames[i] + " has handle = " + MAUtil::integerToString(handle); maDrawText(10, top, message.c_str()); } } maDrawText(10, top+40, "Tap screen to test maFontLoadDefault for some combinations"); maUpdateScreen(); }
int renderCurrent() { int h = 1; MAExtent e = maGetScrSize(); Dimensions screen; screen.width = EXTENT_X(e); screen.height = EXTENT_Y(e); maSetClipRect(0, 0, screen.width, screen.height); maSetColor(BLACK); maFillRect(0, 0, screen.width, screen.height); maSetColor(0xffffff); sprintf(buff, "Write the following string"); mExtent = maGetTextSize(buff); maDrawText(1,h,buff); h+= EXTENT_Y(mExtent); sprintf(buff, "%s", matchString.c_str()); mExtent = maGetTextSize(buff); maDrawText(1,h,buff); h+=EXTENT_Y(mExtent); sprintf(buff, "end"); mExtent = maGetTextSize(buff); maDrawText(screen.width - EXTENT_X(mExtent),screen.height-EXTENT_Y(mExtent),buff); return h; }
//tekent een sneeuwman void SneeuwMan::draw() { // lichaam sneeuwpop bestaat uit drie delen maSetColor(0xE8E8E8); maFillRect(this->positionX - 25, this->positionY - 50, 50, 50); //onder maFillRect(this->positionX - 20, this->positionY - 90, 40, 40); // midden maFillRect(this->positionX - 15, this->positionY - 120, 30, 30); // boven (hoofd) // ogen sneeuwpop bestaat uit twee delen maSetColor(0x000000); maFillRect(this->positionX - 10, this->positionY - 115, 5, 5); // oog links maFillRect(this->positionX + 5, this->positionY - 115, 5, 5); // oog rechts // mond van de sneeuwpop bestaat uit 7 delen maSetColor(0xFC0011); maFillRect(this->positionX - 10, this->positionY - 105, 3, 3); // mond hoek 1 maFillRect(this->positionX - 7, this->positionY - 102, 3, 3); // mond hoek 2 maFillRect(this->positionX - 4, this->positionY - 99, 3, 3); // mond recht maFillRect(this->positionX - 1, this->positionY - 99, 3, 3); // mond recht maFillRect(this->positionX + 2, this->positionY - 99, 3, 3); // mond recht maFillRect(this->positionX + 4, this->positionY - 102, 3, 3); // mond hoek 3 maFillRect(this->positionX + 7, this->positionY - 105, 3, 3); // mond hoek 4 // scherm updaten //maUpdateScreen(); }
void KeyBaseCase::showErrorScreen(int errorCode) { MAExtent e = maGetScrSize(); Dimensions screen; screen.width = EXTENT_X(e); screen.height = EXTENT_Y(e); maSetClipRect(0, 0, screen.width, screen.height); maSetColor(BLACK); maFillRect(0, 0, screen.width, screen.height); int oldCol = maSetColor(0xff0000); const char* testName = name.c_str(); maDrawText(4, 0, testName); int testNameHeight = EXTENT_Y(maGetTextSize(testName)); if(FUNC_OUT_OF_MEMORY_ALLOC == errorCode) maDrawText(4, testNameHeight+2, "Out of Memory"); else if(FUNC_OUT_OF_MEMORY_RESOURCE == errorCode) maDrawText(4, testNameHeight+2, "Couldn't create resource"); else if(FUNC_SYSCALL_ERROR == errorCode) maDrawText(4, testNameHeight+2, "A syscall wasn't called correctly"); else if(FUNC_SYSCALL_NOT_SUPPORTED == errorCode) maDrawText(4, testNameHeight+2, "Unsupported feature"); else maDrawText(4, testNameHeight+2, "Unknown error!"); maDrawText(4, testNameHeight*2+4, "press key or screen to continue"); maUpdateScreen(); maSetColor(oldCol); }
//wordt elke "tick" aangeroepen om het winterlandschap, sneeuwman en sneeuwvlokken te tekenen void SneeuwLandschap::draw() { //kleur de lucht blauw maSetColor( 0x0055ff ); maFillRect( 0, 0, screenWidth, screenHeight ); //maak sneeuw op de grond, a.d.h.v. sneeuwHoogte maSetColor( 0xffffff ); maFillRect( 0, screenHeight - this->sneeuwHoogte, screenWidth, this->sneeuwHoogte ); //teken de sneeuwman sneeuwMan->draw(); //Teken alle sneeuwvlokken, laat ze vallen en verwijder ze for (int i= 0; i<sneeuwVlokArray.size(); i++) { // zolang de grond nog niet geraakt is... if (!sneeuwVlokArray[i]->isDead(grond)) { // laat sneeuw vallen sneeuwVlokArray[i]->fall(5); // check of sneeuw grond heeft geraakt sneeuwVlokArray[i]->isDead(grond); // teken de sneeuw sneeuwVlokArray[i]->draw(); } // als grond is geraakt else { // verwijder sneeuwvlok uit de array sneeuwVlokArray.remove(i); } } }
//sneeuwvlok tekenen void SneeuwVlok::draw(){ if(this->crazyMode){ maSetColor(rand() % 999999 + 1); }else{ maSetColor(0xffffff); } maFillRect(this->positionX, positionY, this->size, this->size); maFillRect(this->positionX, positionY, this->size, this->size); }
void clearScreen(int color) { MAExtent e = maGetScrSize(); Dimensions screen; screen.width = EXTENT_X(e); screen.height = EXTENT_Y(e); maSetClipRect(0, 0, screen.width, screen.height); int oldCol = maSetColor(color); maFillRect(0, 0, screen.width, screen.height); maSetColor(oldCol); }
void TestMoblet::testLoadDefault() { mShowing = 3; maSetColor(0x000000); MAExtent size = maGetScrSize(); maFillRect(0,0,EXTENT_X(size),EXTENT_Y(size) ); maSetColor(0xCD5555); int top = 0; maDrawText(10,top,"--------- Test maFontLoadDefault ---------"); top += 20; maDrawText(10,top,"Test Monospace Normal -10"); testFont(FONT_TYPE_MONOSPACE,FONT_STYLE_NORMAL,-10,top); top += 20; maDrawText(10, top, "Test Monospace Bold 15"); testFont(FONT_TYPE_MONOSPACE, FONT_STYLE_BOLD, 15, top); top += 20; maDrawText(10, top, "Test Monospace Italic 15"); testFont(FONT_TYPE_MONOSPACE, FONT_STYLE_ITALIC, 15, top); top += 20; maDrawText(10, top, "Test SansSerif Normal 15"); testFont(FONT_TYPE_SANS_SERIF, FONT_STYLE_NORMAL, 15, top); top += 20; maDrawText(10, top, "Test SansSerif Bold 15"); testFont(FONT_TYPE_SANS_SERIF, FONT_STYLE_BOLD, 15, top); top += 20; maDrawText(10, top, "Test SansSerif Italic 15"); testFont(FONT_TYPE_SANS_SERIF, FONT_STYLE_ITALIC, 15, top); top += 20; maDrawText(10, top, "Test Serif Normal 15"); testFont(FONT_TYPE_SERIF, FONT_STYLE_NORMAL, 15, top); top += 20; maDrawText(10, top, "Test Serif Bold 15"); testFont(FONT_TYPE_SERIF, FONT_STYLE_BOLD, 15, top); top += 20; maDrawText(10, top, "Test Serif Italic 15"); testFont(FONT_TYPE_SERIF, FONT_STYLE_ITALIC, 15, top); maDrawText(10, top+40, "Tap screen to EXIT"); maUpdateScreen(); }
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); }*/ } }
int main() { char bigAssBuffer[BIGASSBUFFERSIZE]; char* hello = "HTTP GET test"; Extent screenSize, textSize; screenSize = maGetScrSize(); //Draw centered text println(""); textSize = maDrawText(0, 0, hello); maSetColor(0); maFillRect(0, 0, EXTENT_X(textSize), EXTENT_Y(textSize)); //erase test text maDrawText((EXTENT_X(screenSize) - EXTENT_X(textSize)) / 2, 0, hello); maUpdateScreen(); println("Connecting..."); int res = maHttpGet("link.astando.se" "/guido/LvRouting.asmx/GenerateRouteGuido?fromX=100502&fromY=77476&toX=100591&toY=77368", //"wap.mopix.se/test/test.comb", bigAssBuffer, BIGASSBUFFERSIZE); printiln("Got %i bytes", res); println(bigAssBuffer); println("PAK to quit"); PAKAndRelease(); maExit(0); }
VALUE method_maSetColor(VALUE self, VALUE color) { //printf("maSetColor"); int x = NUM2INT(color); //printf("worked"); maSetColor(x); return Qnil; }
// Tekent een SneeuwVlok void SneeuwVlok::draw() { // Stel de kleur in op wit #ffffff maSetColor(0xffffff); // Teken de sneeuwvlok maFillRect(this->positionX, this->positionY, this->size, this->size); }
/* * ctor */ TestMoblet::TestMoblet() { mShowing = 1; maSetColor(0xC1FFC1); int top = 10; maDrawText(10,top, "--------- Display number of fonts with current font ---------"); nrFonts = maFontGetCount(); MAUtil::String tempNrFonts; char buf1[10]; char buf2[256]; itoa(nrFonts,buf1, 10); tempNrFonts += buf1; tempNrFonts += " fonts."; top += 20; maDrawText(10,top,tempNrFonts.c_str()); maSetColor(0x00FFFF); top+=40; maDrawText(10,top,"--------- Display list of fonts with default font size --------- "); MAUtil::String tempFont; int getNameError; for ( int i=0; i<nrFonts; i++) { char buf[256]; getNameError = maFontGetName(i, buf, 256); if ( getNameError >= 0 ) { top += 20; fontNames.add(buf); maDrawText(10,top, buf); } else { top += 20; message = "Font on index:" + MAUtil::integerToString(i) + "returned error:" + MAUtil::integerToString(getNameError); maDrawText(10, top, message.c_str()); } } maDrawText(10, top+40, "Tap screen to test maLoadWithName for each font"); maUpdateScreen(); }
//wordt elke "tick" aangeroepen om het winterlandschap, sneeuwman en sneeuwvlokken te tekenen void SneeuwLandschap::draw() { //kleur de lucht blauw maSetColor( 0x0B0B3B ); maFillRect( 0, 0, screenWidth, screenHeight ); //maak sneeuw op de grond, a.d.h.v. sneeuwHoogte maSetColor( 0xffffff ); maFillRect( 0, screenHeight - this->sneeuwHoogte, screenWidth, this->sneeuwHoogte ); //Teken de sneeuwman this->sneeuwMan->draw(); //Teken alle sneeuwvlokken for(int i = 0;i<vlokjes.size();i++){ vlokjes[i]->draw(); }; }
/** * Create a colored image. * @param color The color of the image (a hex value). * @param width The width of the image. * @param height The height of the image. * @return Handle to the image. The image needs to be * deallocated with maDestoryObject. */ MAHandle ScreenColorList::createColorImage(int color, int width, int height) { MAHandle image = maCreatePlaceholder(); maCreateDrawableImage(image, width, height); MAHandle previousDrawTarget = maSetDrawTarget(image); maSetColor(color); maFillRect(0, 0, width, height); maSetDrawTarget(previousDrawTarget); return image; }
void Widget::draw(bool forceDraw) { if(!mEnabled && !forceDraw) return; //Engine &engine = Engine::getSingleton(); //bool res = engine.pushClipRectIntersect(mBounds.x, mBounds.y, // mBounds.width, mBounds.height); Gfx_pushMatrix(); Gfx_translate(mRelX, mRelY); BOOL res = Gfx_intersectClipRect(0, 0, mBounds.width, mBounds.height); if(res) { if(isDirty() || forceDraw) { drawBackground(); } //MAUI_LOG("Widget::draw, paddingLeft= %d, paddingTop = %d", mPaddingLeft, mPaddingTop); Gfx_translate(mPaddingLeft, mPaddingTop); BOOL res = Gfx_intersectClipRect(0, 0, mPaddedBounds.width, mPaddedBounds.height); #if 0 // debug drawings if(mFocused) { maSetColor(0x00ff00); Gfx_line(0, 0, mBounds.width-1, 0); Gfx_line(mPaddedBounds.width-1, 0, mPaddedBounds.width-1, mPaddedBounds.height-1); Gfx_line(0, mPaddedBounds.height-1, mPaddedBounds.width-1, mPaddedBounds.height-1); Gfx_line(0, 0, 0, mPaddedBounds.height-1); } #endif Gfx_translate(getTranslationX(), getTranslationY()); if(res) { if(isDirty() || forceDraw) { drawWidget(); } Vector_each(Widget*, it, mChildren) (*it)->draw(); } // This commented out to match removal of above intersectClipRect() call. Gfx_popClipRect(); setDirty(false); } Gfx_popMatrix(); //engine.popClipRect(); Gfx_popClipRect(); }
void TestMoblet::testFont (int family, int style, int size, int top) { MAHandle font = maFontLoadDefault(family,style,size); if ( font == RES_FONT_INVALID_SIZE) { maSetColor(0xCD3333); maDrawText(200,top,"Invalid size"); maSetColor(0xC1FFC1); } else if( font == RES_FONT_NO_TYPE_STYLE_COMBINATION) { maSetColor(0xCD3333); maDrawText(200,top,"No type style combination"); maSetColor(0xC1FFC1); } else { maFontSetCurrent(font); MAUtil::String message = "Ok, handle: " + MAUtil::integerToString(font); maDrawText(200, top, message.c_str()); } }
int AnimatedConnWait() { int startTime = maGetMilliSecondCount(); int res; #ifdef ANIMATED int lPos = gPos; int i=0; int screenWidth = EXTENT_X(maGetScrSize()); maSetColor(0); maFillRect(0, lPos, screenWidth - 1, gTextHeight); printlnf("a%i",i++); #endif //ANIMATED while(1) { EVENT event; #ifdef ANIMATED gPos = lPos; maSetColor(0); maFillRect(0, lPos, screenWidth - 1, gTextHeight); printlnf("b%i",i++); #else maWait(0); #endif //ANIMATED if(maGetEvent(&event)) { if(event.type == EVENT_TYPE_CLOSE || (event.type == EVENT_TYPE_KEY_PRESSED && event.key == MAK_0)) { maExit(0); } else if(event.type == EVENT_TYPE_CONN) { res = event.conn.result; break; } } } printlnf("w%i", maGetMilliSecondCount() - startTime); return res; }
/** * Method that draws display data to the screen. */ void drawScreen() { MAExtent screenSize = maGetScrSize(); int width = EXTENT_X(screenSize); int height = EXTENT_Y(screenSize); int x = 20; int y = height / 2; char orientationText[128]; if (width > height) // Landscape { // Set the background color. maSetColor(0x000099); // Set text. sprintf(orientationText, "Landscape %d %d", width, height); } else // Portrait { // Set the background color. maSetColor(0x009900); // Set text. sprintf(orientationText, "Portrait %d %d", width, height); } // Fill background maFillRect(0, 0, width, height); // Use white to display the text. maSetColor(0xFFFFFF); // Draw the text. maDrawText(x, y, orientationText); // Redraw the screen. maUpdateScreen(); }
//De teken methode zorgt ervoor dat de sneeuwman ook daadwerkelijk getekend word. void SneeuwMan::draw() { //Kleur wordt op lichtgrijs gezet. maSetColor(0xC0C0C0); //De 2 grijze vlakken worden getekend. maFillRect( this->positionX, this->positionY -40, 50, 40); maFillRect( this->positionX + 10, this->positionY - 70 , 30, 30); //De kleur wordt op zwart gezet. maSetColor(0x000000); //Zijn ogen, mond, ogen, en knoopjes worden getekend. maFillRect( this->positionX, this->positionY - 105, 50, 35); maFillRect( this->positionX + 20, this->positionY -40, 7, 7); maFillRect( this->positionX + 20, this->positionY -25, 7, 7); maFillRect( this->positionX + 20, this->positionY -10, 7, 7); maFillRect( this->positionX + 15, this->positionY -65, 5, 5); maFillRect( this->positionX + 30, this->positionY -65, 5, 5); maFillRect( this->positionX + 22, this->positionY -55, 5, 5); }
//------------------------------------------------------------------------- void AppFrame::draw( bool forceDraw ) //------------------------------------------------------------------------- { Layout::draw( forceDraw ); if ( mMessage.length( ) > 0 ) { // draw message, if any maSetColor( MessageBackColor.val( ) ); if ( mProgress < 0 ) { mMsgSkin->draw( mFillBounds.x, mFillBounds.y, mFillBounds.width, mFillBounds.height, WidgetSkin::/*eType::*/SELECTED ); mFont->drawBoundedString( mMessage.c_str( ), mTextBounds.x, mTextBounds.y, mTextBounds ); } else { Gfx_fillRect( mProgressBounds.x, mProgressBounds.y, mProgressBounds.width, mProgressBounds.height ); maSetColor( MessageForeColor.val( ) ); Gfx_fillRect( mProgressBounds.x, mProgressBounds.y, (int)( mProgressBounds.width * mProgress ), mProgressBounds.height ); } } }
/* * @brief Displays the sensor values * or an error message if the sensor cannot register. */ void drawSensorOutput() { //clean the screen maSetColor(BG_COLOR); maFillRect(0, 0, gScreenWidth, gScreenHeight); //set output text color maSetColor(TEXT_COLOR); int posY = 0; for (int i=1; i<=SENSOR_TYPES; i++) { drawSensorStatus(i, 0, posY); posY += OFFSET_Y; // skip is sensor couldn't register if (gSensorError[i] != 0) continue; drawSensorValue(i, 0, posY); posY += OFFSET_Y; } }
//wordt elke "tick" aangeroepen om het winterlandschap, sneeuwman en sneeuwvlokken te tekenen void SneeuwLandschap::draw() { //kleur de lucht blauw maSetColor(0x0055ff); maFillRect(0, 0, screenWidth, screenHeight); //maak sneeuw op de grond, a.d.h.v. sneeuwHoogte maSetColor(0xffffff); maFillRect(0, screenHeight - this->sneeuwHoogte, screenWidth, this->sneeuwHoogte); this->sneeuwMan->draw(); for(int i = 0; i < this->sneeuwVlokArray.size(); i++) { SneeuwVlok* vlok = this->sneeuwVlokArray[i]; if(vlok->isDead()) { this->sneeuwVlokArray.remove(i); delete vlok; }else{ vlok->draw(); } } }
void DisplayConsole(void) { int n, index; if (gConsoleDisplay == 0) return; maSetClipRect(0, 0, EXTENT_X(sConsole.screenSize), EXTENT_Y(sConsole.screenSize)); if(gConsoleDrawBackground) { maSetColor(gConsoleBackgroundColor); maFillRect(0, 0, EXTENT_X(sConsole.screenSize), EXTENT_Y(sConsole.screenSize)); } maSetColor(gConsoleTextColor); for (n = 0; n < sConsole.height; n++) { index = (n + sConsole.firstLine) % sConsole.height; maDrawTextW(0, n * sConsole.fontHeight, sConsole.lines[index].line); } maUpdateScreen(); }
int MAMain() { Extent screenSize; int midX, midY; int width, height; int scrW, scrH; screenSize = maGetScrSize(); scrW = EXTENT_X(screenSize); scrH = EXTENT_Y(screenSize); midX = scrW >> 1; midY = scrH >> 1; #ifdef RECT_SIZE_TEST width = 1; height = 1; #else //normal color test width = midX - 2; height = midY / 2 - 2; #endif maSetColor(0x800080); //deep purple maFillRect(0, 0, scrW, scrH); maSetColor(RGB(255, 0, 0)); //RED maFillRect(1, 1, width, height); maSetColor(RGB(255, 255, 0)); //YELLA maFillRect(1+width+2, 1, width, height); maSetColor(RGB(0, 255, 0)); //GREEN maFillRect(1, 1+height+2, width, height); maSetColor(RGB(0, 255, 255)); //TORQUOISE maFillRect(1+width+2, 1+height+2, width, height); maSetColor(RGB(0, 0, 255)); //BLUE maFillRect(1, 1+(height+2)*2, width, height); maSetColor(RGB(255, 0, 255)); //PURPLE maFillRect(1+width+2, 1+(height+2)*2, width, height); maSetColor(RGB(255, 255, 255)); //WHITE maFillRect(1, 1+(height+2)*3, width, height); maSetColor(0); //BLACK maFillRect(1+width+2, 1+(height+2)*3, width, height); maUpdateScreen(); FREEZE; }
bool Graphics::construct(const char *font, const char *boldFont) { logEntered(); _surface = SDL_GetWindowSurface(_window); SDL_GetWindowSize(_window, &_w, &_h); bool result = false; if (loadFonts(font, boldFont)) { _screen = new Canvas(); if (_screen && _screen->create(getWidth(), getHeight())) { _drawTarget = _screen; maSetColor(DEFAULT_BACKGROUND); result = true; } } return result; }
void testDrawableImages() { const unsigned int colors[] = { 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff, }; const unsigned int NUMCOLORS = sizeof(colors)/sizeof(int); unsigned int colors2[NUMCOLORS]; MAHandle testImg = maCreatePlaceholder(); printf("testing resources\n"); int res = maCreateDrawableImage(testImg, NUMCOLORS, 1); assert("maCreateImageRaw", res == RES_OK); MAExtent e1 = maGetImageSize(testImg); assert("maGetImageSize", e1 == EXTENT(NUMCOLORS,1)); maSetDrawTarget(testImg); for(unsigned int i = 0; i < NUMCOLORS; i++) { maSetColor(colors[i]); maPlot(i, 0); } MARect rect = {0, 0, NUMCOLORS, 1}; maSetDrawTarget(0); maGetImageData(testImg, colors2, &rect, NUMCOLORS); assert( "testing drawable image res", (memcmp(colors, colors2, sizeof(colors)) == 0) ); }
int MAMain() { maSetColor(0xFFFFFF); maDrawText(0,0, "Hello World!"); maUpdateScreen(); //Freeze while(1) { maWait(0); EVENT event; if(maGetEvent(&event)) { if(event.type == EVENT_TYPE_CLOSE) break; if(event.type == EVENT_TYPE_KEY_PRESSED) { if(event.key == MAK_0) break; } } } return 0; }