void xsCanvasContext::clearRect(float x, float y, float width, float height) { xsGraphics *gc = xsGetSystemGc(); xsSetColor(gc, XS_COLOR_WHITE); xsFillRectangle(gc, x, y, width, height); xsFlushScreen(x, y, x + width, y + height); }
int DemoApp::start() { xsColor color = {255,255,255,255}; xsSetColor(xsGetSystemGc(), color); xsGetScreenDimension(&width, &height); xsFillRectangle(xsGetSystemGc(), 0, 0, width, height);//, xsArgbToColor(0xFFFFFFFF)); xsFlushScreen(0, 0, width - 1, height - 1); const char * js = getManifest()->getStartup(); invokeJavascript(js, LOAD_JS_STRING); x = (width - BOX_SIZE) / 2; y = (height - BOX_SIZE) / 2; //img = this->getResource()->loadImage(xsT("logo-48x48.jpg")); //timer = xsStartTimer(20, _onTimeout, this); return XS_EC_OK; }
int DemoApp::onTimeout() { xsGraphics *gc = xsGetSystemGc(); // clear xsColor color = {255, 255, 255, 255}; xsSetColor(gc, color); xsFillRectangle(gc, x, y, BOX_SIZE, BOX_SIZE);//, xsArgbToColor(0xFFFFFFFF)); // draw new box x += rateX; y += rateY; if (x < 0 || x + BOX_SIZE > width) rateX = -rateX; if (y < 0 || y + BOX_SIZE > height) rateY = -rateY; xsDrawImage(gc, img, x, y, 0, 0); xsFlushScreen(0, 0, width - 1, height - 1); return 0; }