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

Method renderWire

source/frontend/StarWireInterface.cpp:68–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void WirePane::renderWire(Vec2F from, Vec2F to, Color baseColor) {
69 if (m_worldClient->isTileProtected(Vec2I::floor(from)) || m_worldClient->isTileProtected(Vec2I::floor(to)))
70 return;
71
72 from = m_worldPainter->camera().worldToScreen(from);
73 to = m_worldPainter->camera().worldToScreen(to);
74
75 auto rangeRand = [&](float dev, float min, float max) {
76 return clamp<float>(Random::nrandf(dev, max), min, max);
77 };
78
79 float lineThickness = m_worldPainter->camera().pixelRatio() * rangeRand(m_beamWidthDev, m_minBeamWidth, m_maxBeamWidth);
80 float beamTransparency = rangeRand(m_beamTransDev, m_minBeamTrans, m_maxBeamTrans);
81 baseColor.setAlphaF(baseColor.alphaF() * beamTransparency);
82 Color innerStripe = baseColor;
83 innerStripe.setValue(1 - (1 - innerStripe.value()) / m_innerBrightnessScale);
84 innerStripe.setSaturation(innerStripe.saturation() / m_innerBrightnessScale);
85 Color firstStripe = innerStripe;
86 innerStripe.setValue(1 - (1 - innerStripe.value()) / m_innerBrightnessScale);
87 innerStripe.setSaturation(innerStripe.saturation() / m_innerBrightnessScale);
88 Color secondStripe = innerStripe;
89
90 context()->drawLine(from, to, baseColor.toRgba(), lineThickness);
91 context()->drawLine(from, to, firstStripe.toRgba(), lineThickness * m_firstStripeThickness);
92 context()->drawLine(from, to, secondStripe.toRgba(), lineThickness * m_secondStripeThickness);
93}
94
95void WirePane::renderImpl() {
96 if (!m_worldClient->inWorld())

Callers

nothing calls this directly

Calls 12

nrandfFunction · 0.85
worldToScreenMethod · 0.80
pixelRatioMethod · 0.80
setAlphaFMethod · 0.80
alphaFMethod · 0.80
setSaturationMethod · 0.80
saturationMethod · 0.80
toRgbaMethod · 0.80
isTileProtectedMethod · 0.45
setValueMethod · 0.45
valueMethod · 0.45
drawLineMethod · 0.45

Tested by

no test coverage detected