mirror of
https://github.com/wolfpld/tracy
synced 2026-01-19 17:02:11 +00:00
Test of shaded histogram graph.
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
# pragma warning( disable: 4244 ) // conversion from don't care to whatever, possible loss of data
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../imgui/imgui.h"
|
||||
#include "../imgui/imgui_internal.h"
|
||||
|
||||
@@ -65,6 +68,27 @@ namespace tracy
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void LineVertical( struct ImDrawList* draw, float x, float y0, float y1, uint32_t c0, uint32_t c1 )
|
||||
{
|
||||
draw->AddRectFilledMultiColor( ImVec2( x, y0 ), ImVec2( x+1, y1 ), c0, c0, c1, c1 );
|
||||
}
|
||||
|
||||
static inline uint8_t lerp( uint8_t v0, uint8_t v1, float t )
|
||||
{
|
||||
return uint8_t( v0 + t * ( v1 - v0 ) );
|
||||
}
|
||||
|
||||
static inline void LineVerticalShaded( struct ImDrawList* draw, float x, float y0, float y1, uint32_t c0, uint32_t c1, float maxHeight )
|
||||
{
|
||||
const auto dy = y1 - y0;
|
||||
const auto t = std::min( 1.f, dy / maxHeight );
|
||||
const auto ct = 0xFF000000 |
|
||||
( lerp( ( c0 & 0x00FF0000 ) >> 16, ( c1 & 0x00FF0000 ) >> 16, t ) << 16 ) |
|
||||
( lerp( ( c0 & 0x0000FF00 ) >> 8, ( c1 & 0x0000FF00 ) >> 8, t ) << 8 ) |
|
||||
( lerp( ( c0 & 0x000000FF ) , ( c1 & 0x000000FF ) , t ) );
|
||||
LineVertical( draw, x, y0, y1, c0, ct );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7586,7 +7586,8 @@ void View::DrawFindZone()
|
||||
const auto val = cumulateTime ? binTime[i] : bins[i];
|
||||
if( val > 0 )
|
||||
{
|
||||
draw->AddLine( wpos + ImVec2( 2+i, Height-3 ), wpos + ImVec2( 2+i, Height-3 - val * hAdj ), 0xFF22DDDD );
|
||||
LineVerticalShaded( draw, wpos.x + 2+i, wpos.y + Height-2 - val * hAdj, wpos.y + Height-1, 0xFF22DDDD, 0xFF118888, hAdj );
|
||||
//draw->AddLine( wpos + ImVec2( 2+i, Height-3 ), wpos + ImVec2( 2+i, Height-3 - val * hAdj ), 0xFF22DDDD );
|
||||
if( selBin[i] > 0 )
|
||||
{
|
||||
draw->AddLine( wpos + ImVec2( 2+i, Height-3 ), wpos + ImVec2( 2+i, Height-3 - selBin[i] * hAdj ), 0xFFDD7777 );
|
||||
|
||||
Reference in New Issue
Block a user