MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / linearAngleToEndpoints

Function linearAngleToEndpoints

src/core/ThemeManager.cpp:146–159  ·  view source on GitHub ↗

Convert a CSS-convention angle (0deg = bottom→top, 90deg = left→right, 180deg = top→bottom, 270deg = right→left) to a 0–1 normalised (x1, y1, x2, y2) endpoint pair that covers a unit square. Used by both brush() (mapping onto a real QRect) and cssFragment() (emitting normalised stylesheet coords). Extracted so the two paths stay in lock-step — a future bug in one would otherwise produce subtle m

Source from the content-addressed store, hash-verified

144// mismatches between the painted gradient and the stylesheet-emitted
145// preview.
146void linearAngleToEndpoints(qreal angleDeg,
147 qreal& x1, qreal& y1, qreal& x2, qreal& y2)
148{
149 const qreal rad = qDegreesToRadians(angleDeg);
150 // Half-diagonal of the unit square — guarantees the gradient line
151 // reaches the corners regardless of angle. sqrt(2)/2 ≈ 0.7071.
152 constexpr qreal kHalfDiagonal = 0.7071067811865476;
153 const qreal dx = std::sin(rad);
154 const qreal dy = -std::cos(rad); // CSS Y axis is inverted vs screen
155 x1 = 0.5 - dx * kHalfDiagonal;
156 y1 = 0.5 - dy * kHalfDiagonal;
157 x2 = 0.5 + dx * kHalfDiagonal;
158 y2 = 0.5 + dy * kHalfDiagonal;
159}
160
161// Emit a Qt stylesheet gradient fragment for the given gradient.
162QString gradientCssFragment(const ThemeGradient& g)

Callers 2

gradientCssFragmentFunction · 0.85
brushMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected