void RectangleTest::access() { Rectanglei rect({34, 23}, {47, 30}); constexpr Rectanglei crect({34, 23}, {47, 30}); CORRADE_COMPARE(rect.bottomLeft(), Vector2i(34, 23)); CORRADE_COMPARE(rect.topRight(), Vector2i(47, 30)); CORRADE_COMPARE(rect.bottom(), 23); CORRADE_COMPARE(rect.top(), 30); CORRADE_COMPARE(rect.left(), 34); CORRADE_COMPARE(rect.right(), 47); CORRADE_COMPARE(rect.bottomLeft(), Vector2i(34, 23)); CORRADE_COMPARE(rect.topRight(), Vector2i(47, 30)); constexpr Int bottom = crect.bottom(); constexpr Int top = crect.top(); constexpr Int left = crect.left(); constexpr Int right = crect.right(); CORRADE_COMPARE(bottom, 23); CORRADE_COMPARE(top, 30); CORRADE_COMPARE(left, 34); CORRADE_COMPARE(right, 47); constexpr Vector2i bottomLeft = crect.bottomLeft(); constexpr Vector2i topRight = crect.topRight(); CORRADE_COMPARE(bottomLeft, Vector2i(34, 23)); CORRADE_COMPARE(topRight, Vector2i(47, 30)); CORRADE_COMPARE(rect.topLeft(), Vector2i(34, 30)); CORRADE_COMPARE(rect.bottomRight(), Vector2i(47, 23)); }
QImage QtNativeFont::nativeFontRasterize(String const &text, Vector4ub const &foreground, Vector4ub const &background) const { #ifdef LIBGUI_ACCURATE_TEXT_BOUNDS Rectanglei const bounds = measure(text); #else Rectanglei const bounds(Vector2i(0, -d->metrics->ascent()), Vector2i(d->metrics->width(text), d->metrics->descent())); #endif QColor const fgColor(foreground.x, foreground.y, foreground.z, foreground.w); QColor const bgColor(background.x, background.y, background.z, background.w); QImage img(QSize(bounds.width() + 1, bounds.height() + 1), QImage::Format_ARGB32); img.fill(bgColor.rgba()); QPainter painter(&img); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.setFont(d->font); painter.setPen(fgColor); painter.setBrush(bgColor); painter.drawText(-bounds.left(), -bounds.top(), text); return img; }
duint CanvasWindow::grabAsTexture(Rectanglei const &area, GrabMode mode) const { QSize size; if(mode == GrabHalfSized) { size = QSize(area.width()/2, area.height()/2); } return d->canvas->grabAsTexture( QRect(area.left(), area.top(), area.width(), area.height()), size); }
void glSubImage(int level, Rectanglei const &rect, Image const &image, CubeFace face = PositiveX) { auto const &glFormat = image.glFormat(); LIBGUI_GL.glPixelStorei(GL_UNPACK_ALIGNMENT, GLint(glFormat.rowAlignment)); LIBGUI_GL.glPixelStorei(GL_UNPACK_ROW_LENGTH, GLint(image.width())); int const bytesPerPixel = image.depth() / 8; LIBGUI_GL.glTexSubImage2D(isCube()? glFace(face) : texTarget, level, rect.left(), rect.top(), rect.width(), rect.height(), glFormat.format, glFormat.type, static_cast<dbyte const *>(image.bits()) + bytesPerPixel * rect.left() + image.stride() * rect.top()); LIBGUI_GL.glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); LIBGUI_ASSERT_GL_OK(); }