void testRoundRect() { fillScreen(BLACK); uint16_t x; for (x=0; x < width(); x+=6) { drawRoundRect(width()/2 -x/2, height()/2 -x/2 , x, x, x/8, Color565(x, 0, 0)); } }
void Design::paint(Graphics::ManagedSurface *surface, Patterns &patterns, int x, int y) { bool needRender = false; if (_surface == NULL) { _boundsCalculationMode = true; _bounds->debugPrint(4, "Internal bounds:"); render(patterns); _boundsCalculationMode = false; if (_bounds->right == -10000) { _bounds->left = _bounds->top = _bounds->right = _bounds->bottom = 0; } _bounds->debugPrint(4, "Calculated bounds:"); _surface = new Graphics::ManagedSurface; _surface->create(_bounds->width(), _bounds->height(), Graphics::PixelFormat::createFormatCLUT8()); _surface->clear(kColorGreen); needRender = true; } _bounds->debugPrint(4, "Using bounds:"); #if 0 PlotData pd(_surface, &patterns, 8, 1, this); int x1 = 50, y1 = 50, x2 = 200, y2 = 200, borderThickness = 30; Common::Rect inn(x1-5, y1-5, x2+5, y2+5); drawRoundRect(inn, 6, kColorGray, false, drawPixelPlain, &pd); drawThickLine(x1, y1, x2-borderThickness, y1, borderThickness, kColorBlack, drawPixel, &pd); drawThickLine(x2-borderThickness, y1, x2-borderThickness, y2, borderThickness, kColorBlack, drawPixel, &pd); drawThickLine(x2-borderThickness, y2-borderThickness, x1, y2-borderThickness, borderThickness, kColorBlack, drawPixel, &pd); drawThickLine(x1, y2-borderThickness, x1, y1, borderThickness, kColorBlack, drawPixel, &pd); drawThickLine(x2+10, y2+10, x2+100, y2+100, borderThickness, kColorBlack, drawPixel, &pd); g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->w, _surface->h); while (true) { ((WageEngine *)g_engine)->processEvents(); g_system->updateScreen(); g_system->delayMillis(50); } return; #endif if (needRender) render(patterns); if (_bounds->width() && _bounds->height()) { const int padding = 3; Common::Rect from(padding, padding, _bounds->width() - 2 * padding, _bounds->height() - 2 * padding); Common::Rect to(from); to.moveTo(x, y); surface->transBlitFrom(*_surface, from, to, kColorGreen); } }
//----------------------------------------------------------------------------- void CTextKickButton::draw(CDrawContext* pContext) { // 枠線を描画 CDrawMode oldDrawMode = pContext->getDrawMode(); CCoord oldLineWidth = pContext->getLineWidth(); pContext->setDrawMode(kAntialias); pContext->setLineWidth(1); pContext->setFrameColor(kBlackCColor); pContext->setFillColor(kBlackCColor); if (value > 0) { drawRoundRect(pContext, size, 5, kDrawFilled); } else { drawRoundRect(pContext, size, 5, kDrawStroked); } pContext->setDrawMode(oldDrawMode); pContext->setLineWidth(oldLineWidth); // 文字を描画 CRect newClip(size); pContext->setFont(mLabelFont); if (value > 0) { pContext->setFontColor(kWhiteCColor); } else { pContext->setFontColor(kBlackCColor); } #if WIN32 newClip.offset(0, 2); #endif #if VSTGUI_USES_UTF8 pContext->drawStringUTF8(text, newClip, kCenterText, true); #else pContext->drawString(text, newClip, true, kCenterText); #endif }
void Design::render(Patterns &patterns) { Common::MemoryReadStream in(_data, _len); bool needRender = true; while (needRender) { byte fillType = in.readByte(); byte borderThickness = in.readByte(); byte borderFillType = in.readByte(); int type = in.readByte(); if (in.eos()) break; debug(8, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type); switch (type) { case 4: drawRect(_surface, in, patterns, fillType, borderThickness, borderFillType); break; case 8: drawRoundRect(_surface, in, patterns, fillType, borderThickness, borderFillType); break; case 12: drawOval(_surface, in, patterns, fillType, borderThickness, borderFillType); break; case 16: case 20: drawPolygon(_surface, in, patterns, fillType, borderThickness, borderFillType); break; case 24: drawBitmap(_surface, in); break; default: warning("Unknown type => %d", type); break; } //g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->w, _surface->h); //((WageEngine *)g_engine)->processEvents(); //g_system->updateScreen(); //g_system->delayMillis(500); } }
void testroundrects() { int color = 100; int i; int x = 0; int y = 0; int w = width(); int h = height(); fillScreen(BLACK); for (i = 0; i <= 24; ++i) { drawRoundRect(x, y, w, h, 5, color); x += 2; y += 3; w -= 4; h -= 6; color += 1100; } }