-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStairstepPlots.nim
35 lines (30 loc) · 1.12 KB
/
StairstepPlots.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import std/[math]
import imgui
import implot
import utils
#--------------------------
# proc demo_StairstepPlots
#--------------------------
proc demo_StairstepPlots*() =
var
ys1{.global.}:array[21,cfloat]
ys2{.global.}:array[21,cfloat]
for i in 0..<21:
ys1[i] = 0.75f + 0.2f * sin((10 * i).float32 * 0.05f)
ys2[i] = 0.25f + 0.2f * sin((10 * i).float32 * 0.05f)
var flags{.global.} = 0.ImPlotStairsFlags
CHECKBOX_FLAG(flags, ImPlotStairsFlags.Shaded)
if ipBeginPlot("Stairstep Plot"):
ipSetupAxes("x","f(x)")
ipSetupAxesLimits(0,1,0,1)
ipPushStyleColor(ImPlotCol.Line, ImVec4(x:0.5f,y:0.5f,z:0.5f,w:1.0f))
ipPlotLine("##1", ys1.ptz ,21,0.05f)
ipPlotLine("##2", ys2.ptz ,21,0.05f)
ipPopStyleColor()
ipSetNextMarkerStyle(ImPlotMarker.Circle)
ipSetNextFillStyle(IMPLOT_AUTO_COL, 0.25f)
ipPlotStairs("Post Step (default)", ys1.ptz, 21, 0.05f, 0, flags)
ipSetNextMarkerStyle(ImPlotMarker.Circle)
ipSetNextFillStyle(IMPLOT_AUTO_COL, 0.25f)
ipPlotStairs("Pre Step", ys2.ptz, 21, 0.05f, 0, flags or ImPlotStairsFlags.PreStep)
ipEndPlot()