void FramelessDlg::paintEvent(QPaintEvent *e) { QPainter painter(this); QRect bottom(5, 136, 200, 7); QRect top(5, 0, 200, 3); QRect left(0, 3, 5, 133); QRect right(205, 3, 5, 133); QRect topRight(205, 0, 5, 3); QRect topLeft(0, 0, 5, 3); QRect bottomLeft(0, 136, 5, 7); QRect bottomRight(205, 136, 5, 7); QRect tBottom(5, this->height() - 7, this->width() - 10, 7); QRect tTop(5, 0, this->width() - 10, 3); QRect tLeft(0, 3, 5, this->height() - 10); QRect tRight(this->width() - 5, 3, 5, this->height() - 10); QRect tTopLeft(0, 0, 5, 3); QRect tTopRight(this->width() - 5, 0, 5, 3); QRect tBottomLeft(0, this->height() - 7, 5, 7); QRect tBottomRight(this->width() - 5, this->height() - 7, 5, 7); painter.drawPixmap(tBottom, m_shadow, bottom); painter.drawPixmap(tTop, m_shadow, top); painter.drawPixmap(tLeft, m_shadow, left); painter.drawPixmap(tRight, m_shadow, right); painter.drawPixmap(tTopRight, m_shadow, topRight); painter.drawPixmap(tTopLeft, m_shadow, topLeft); painter.drawPixmap(tBottomLeft, m_shadow, bottomLeft); painter.drawPixmap(tBottomRight, m_shadow, bottomRight); }
void SpriteBatch::draw(const Vector3& position, const Vector3& right, const Vector3& forward, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Vector2& rotationPoint, float rotationAngle) { // Calculate the vertex positions. Vector3 tRight(right); tRight *= width * 0.5f; Vector3 tForward(forward); tForward *= height * 0.5f; Vector3 p0 = position; p0 -= tRight; p0 -= tForward; Vector3 p1 = position; p1 += tRight; p1 -= tForward; tForward = forward; tForward *= height; Vector3 p2 = p0; p2 += tForward; Vector3 p3 = p1; p3 += tForward; // Calculate the rotation point. Vector3 rp = p0; tRight = right; tRight *= width * rotationPoint.x; tForward *= rotationPoint.y; rp += tRight; rp += tForward; // Rotate all points the specified amount about the given point (about the up vector). static Vector3 u; Vector3::cross(right, forward, &u); static Matrix rotation; Matrix::createRotation(u, rotationAngle, &rotation); p0 -= rp; p0 *= rotation; p0 += rp; p1 -= rp; p1 *= rotation; p1 += rp; p2 -= rp; p2 *= rotation; p2 += rp; p3 -= rp; p3 *= rotation; p3 += rp; // Add the sprite vertex data to the batch. static SpriteVertex v[4]; SPRITE_ADD_VERTEX(v[0], p0.x, p0.y, p0.z, u1, v1, color.x, color.y, color.z, color.w); SPRITE_ADD_VERTEX(v[1], p1.x, p1.y, p1.z, u2, v1, color.x, color.y, color.z, color.w); SPRITE_ADD_VERTEX(v[2], p2.x, p2.y, p2.z, u1, v2, color.x, color.y, color.z, color.w); SPRITE_ADD_VERTEX(v[3], p3.x, p3.y, p3.z, u2, v2, color.x, color.y, color.z, color.w); static const unsigned short indices[4] = { 0, 1, 2, 3 }; _batch->add(v, 4, const_cast<unsigned short*>(indices), 4); }