void SdlApplication::onPaint(Fog::Painter& p) { // Just use the Fog-Framework ;-) // Create some variable we will work with. float w = float(_screen->w); float h = float(_screen->h); float roundw = 100.0f; float roundh = 100.0f; Fog::PointF cp(w / 2.0f, h / 2.0f); // Clear the entire screen. p.setSource(Fog::Argb32(0xFF000000)); p.fillAll(); p.save(); // Rotate across the screen center point. p.transform(createRotationMatrix(cp, _rotate)); // And draw something... Fog::LinearGradientF gradient; //gradient gradient.setStart(cp.x - roundw / 2.0f, cp.y - roundh / 2.0f); gradient.setEnd(cp.x + roundw / 2.0f, cp.y + roundh / 2.0f); gradient.addStop(0.0f, Fog::Argb32(0xFFFFFFFF)); gradient.addStop(0.5f, Fog::Argb32(0xFFFFFF00)); gradient.addStop(1.0f, Fog::Argb32(0xFFFF0000)); p.setSource(gradient); //p.setSource(Fog::Argb32(0xFFFF0000)); p.fillRound(Fog::RoundF( Fog::RectF(cp.x - roundw / 2.0f, cp.y - roundh / 2.0f, roundw, roundh), Fog::PointF(20.0f, 20.0f))); p.restore(); }
bool loadSvgFile(Image &img, const char *path) { Fog::Logger::getGlobal()->setSeverity(100); Fog::Logger::getLocal()->setSeverity(100); size_t width = 400, height = 400; Fog::SvgDocument svg; unsigned err; if ((err=svg.readFromFile(StringW::fromAscii8(path)))) { fprintf(stderr, "Failed to load SVG %s error %05X ERR_XML_SAX_NO_DOCUMENT=%05X\n", path, err, Fog::ERR_XML_SAX_NO_DOCUMENT); return false; } Fog::SizeF size = svg.getDocumentSize(); if (size.w >= 2 && size.w <= 2048) width = size.w; if (size.h >= 2 && size.h <= 2048) height = size.h; svg.getResourceManager()->loadQueuedResources(); Fog::SizeI si; void *imgdata=malloc(width*height*4); if (!imgdata) return false; si.w = width; si.h = height; Fog::ImageBits imgbits(si, Fog::IMAGE_FORMAT_PRGB32, width*4, (unsigned char*)imgdata); Fog::Painter painter; if ((err=painter.begin(imgbits))) { fprintf(stderr, "Failed to select surface to SVG rendering %s error %05X\n", path, err); } painter.setSource(Fog::Argb32(0xFFFFFFFF)); painter.fillAll(); if ((err=svg.render(&painter))) { fprintf(stderr, "Failed to render SVG %s error %05X\n", path, err); } painter.flush(Fog::PAINTER_FLUSH_SYNC); painter.end(); load_from_pixels(img, imgdata, width, height, 4, true); free(imgdata); return true; }