Final version of the code. I merged [MeasureInitialHistogramPath] and [MeasureHistogramPath] into one measure, and tricked Rainmeter to not consume resources with the substitutions while the initial string was automatically (and recursively) built by setting the initial RegExpSubstitute to 0. After the initial string is built, the normal substitutions take place, triggered from the "histogrammed" measure ([MeasureCPU] in this case), and because an UpdateDivider of -1 is set on [MeasureHistogramPath], a duplicate update of it is avoided (not that it would affect the result, but just to be efficient with resources).
The code:
Code: Select all
[Variables]
Values=100
Padding=5
W=3
H=100
HistogramColor=255,255,255,255
HistogramBGCol=0,0,0,100
PathSegment="LineTo (#W#*([MeasureLastValueIndex]-1-(0+0))),(#H#-(0/100)*#H#) | LineTo (#W#*([MeasureLastValueIndex]-(0+0))),(#H#-(0/100)*#H#) | "
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
---Histogram Path Measures---
[MeasureFirstValueIndex]
Measure=Calc
Formula=(MeasureFirstValueIndex+1)
[MeasureLastValueIndex]
Group=InitialGroup
Measure=Calc
Formula=(MeasureLastValueIndex+1)
[MeasureHistogramPath]
Group=InitialGroup
Measure=String
String=
UpdateDivider=-1
RegExpSubstitute=0
Substitute="(?siU)^(?:LineTo .* \| LineTo .* \| ){1}((?:LineTo .* \| LineTo .* \| ){#Values#})$":"\1","-\(\d+\+":"-([MeasureFirstValueIndex]+"
IfCondition=(MeasureLastValueIndex<=#Values#)
IfTrueAction=[!SetOption #CURRENTSECTION# String "[#CURRENTSECTION#]#PathSegment#"][!UpdateMeasureGroup InitialGroup]
IfFalseAction=[!SetOption #CURRENTSECTION# RegExpSubstitute 1]
IfConditionMode=1
DynamicVariables=1
---Actual Histogram Measures---
[MeasureCPU]
Measure=CPU
OnUpdateAction=[!SetOption MeasureHistogramPath String "[MeasureHistogramPath]LineTo (#W#*([MeasureLastValueIndex]-(0+1))),(#H#-([#CURRENTSECTION#]/100)*#H#) | LineTo (#W#*([MeasureLastValueIndex]+1-(0+1))),(#H#-([#CURRENTSECTION#]/100)*#H#) | "][!UpdateMeasure MeasureHistogramPath]
DynamicVariables=1
---Meters---
[MeterCPUBackgroundImage]
Meter=Image
SolidColor=24,102,10
X=0
Y=0
W=(#Values#+#W#*#Values#+#Padding#*3)
H=(#H#+#Padding#*2)
[MeterCPUHistogram]
Meter=Histogram
MeasureName=MeasureCPU
X=#Padding#
Y=#Padding#
W=#Values#
H=#H#
PrimaryColor=#HistogramColor#
SolidColor=#HistogramBGCol#
AntiAlias=1
[MeterImageGap]
Meter=Image
X=0R
Y=0r
W=#Padding#
H=#H#
SolidColor=0,0,0,0
AntiAlias=1
[MeterCPUShapeHistogram]
Meter=Shape
X=0R
Y=0r
Shape=Rectangle 0,0,(#W#*#Values#),#H# | StrokeWidth 0 | Stroke Color #HistogramBGCol# | Fill Color #HistogramBGCol#
Shape2=Path HistogramPath | StrokeWidth 0 | Stroke Color #HistogramColor# | Fill Color #HistogramColor#
HistogramPath=0,#H# | [MeasureHistogramPath]LineTo (#W#*#Values#),#H# | SetNoStroke 1 | ClosePath 1
DynamicVariables=1
[MeterCPUText]
Meter=String
MeasureName=MeasureCPU
X=((#Values#+#W#*#Values#+#Padding#*3)/2)
Y=(#Padding#*2)R
FontSize=8
FontColor=255,255,255,255
StringAlign=Center
AntiAlias=1
Text=%1%