MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / renderTiledImage

Method renderTiledImage

source/windowing/StarCanvasWidget.cpp:195–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195void 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
227void CanvasWidget::renderLine(Vec2F const& renderingOffset, Vec2F const& begin, Vec2F const end, Vec4B const& color, float lineWidth) {
228 auto& context = GuiContext::singleton();

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
textureSizeMethod · 0.80
piecewiseDivideMethod · 0.80
piecewiseMultiplyMethod · 0.80
setXMinMethod · 0.80
xMinMethod · 0.80
setYMinMethod · 0.80
yMinMethod · 0.80
setXMaxMethod · 0.80
xMaxMethod · 0.80
setYMaxMethod · 0.80
yMaxMethod · 0.80

Tested by

no test coverage detected