| 193 | } |
| 194 | |
| 195 | void CanvasWidget::renderTiledImage(Vec2F const& renderingOffset, String const& texName, float textureScale, Vec2D const& offset, RectF const& screenCoords, Vec4B const& color) { |
| 196 | auto& context = GuiContext::singleton(); |
| 197 | |
| 198 | Vec2F texSize = Vec2F(context.textureSize(texName)); |
| 199 | Vec2F texScaledSize = texSize * textureScale; |
| 200 | Vec2I textureCount = Vec2I::ceil(screenCoords.size().piecewiseDivide(texScaledSize)) + Vec2I(2, 2); |
| 201 | Vec2F screenLowerLeft = screenCoords.min() - Vec2F(pfmod<double>(texScaledSize[0] - offset[0], texScaledSize[0]), pfmod<double>(texScaledSize[1] - offset[1], texScaledSize[1])); |
| 202 | |
| 203 | for (int x = 0; x < textureCount[0]; ++x) { |
| 204 | for (int y = 0; y < textureCount[1]; ++y) { |
| 205 | Vec2F screenPos = screenLowerLeft + texScaledSize.piecewiseMultiply({(float)x, (float)y}); |
| 206 | RectF screenRect = RectF::withSize(screenPos, texScaledSize); |
| 207 | |
| 208 | RectF limitedScreenRect; |
| 209 | limitedScreenRect.setXMin(max(screenRect.xMin(), screenCoords.xMin())); |
| 210 | limitedScreenRect.setYMin(max(screenRect.yMin(), screenCoords.yMin())); |
| 211 | limitedScreenRect.setXMax(min(screenRect.xMax(), screenCoords.xMax())); |
| 212 | limitedScreenRect.setYMax(min(screenRect.yMax(), screenCoords.yMax())); |
| 213 | |
| 214 | RectF limitedTexRect = limitedScreenRect.translated(-screenPos).scaled(1 / textureScale); |
| 215 | |
| 216 | if (limitedScreenRect.isEmpty()) |
| 217 | continue; |
| 218 | |
| 219 | if (m_ignoreInterfaceScale) |
| 220 | context.drawQuad(texName, limitedTexRect, limitedScreenRect.translated(renderingOffset), color); |
| 221 | else |
| 222 | context.drawQuad(texName, limitedTexRect, limitedScreenRect.translated(renderingOffset).scaled(context.interfaceScale()), color); |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | void CanvasWidget::renderLine(Vec2F const& renderingOffset, Vec2F const& begin, Vec2F const end, Vec4B const& color, float lineWidth) { |
| 228 | auto& context = GuiContext::singleton(); |
nothing calls this directly
no test coverage detected