MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/FleX / drawLine

Function drawLine

demo/d3d11/imguiGraph.cpp:190–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188
189
190static void drawLine(float x0, float y0, float x1, float y1, float r, float fth, unsigned int col)
191{
192 float dx = x1 - x0;
193 float dy = y1 - y0;
194 float d = sqrtf(dx*dx + dy*dy);
195 if (d > 0.0001f)
196 {
197 d = 1.0f / d;
198 dx *= d;
199 dy *= d;
200 }
201 float nx = dy;
202 float ny = -dx;
203 float verts[4 * 2];
204 r -= fth;
205 r *= 0.5f;
206 if (r < 0.01f) r = 0.01f;
207 dx *= r;
208 dy *= r;
209 nx *= r;
210 ny *= r;
211
212 verts[0] = x0 - dx - nx;
213 verts[1] = y0 - dy - ny;
214
215 verts[2] = x0 - dx + nx;
216 verts[3] = y0 - dy + ny;
217
218 verts[4] = x1 + dx + nx;
219 verts[5] = y1 + dy + ny;
220
221 verts[6] = x1 + dx - nx;
222 verts[7] = y1 + dy - ny;
223
224 drawPolygon(verts, 4, fth, col);
225}
226
227
228bool imguiGraphInit(const char* fontpath, const ImguiGraphDesc* desc)

Callers 1

imguiGraphDrawFunction · 0.70

Calls 1

drawPolygonFunction · 0.70

Tested by

no test coverage detected