balala wrote: ↑July 6th, 2020, 5:28 pm
Have no idea if I don't see the code, so post it please.
Nevermind, I went for a different approach instead, and formatted the string so that substitutions happen in a certain way. Everything works, but the measure order is important. I guess
[MeasureInitialHistogramPath] (which is automatically building the "0 to 0 to 0 to ... to 0" path string) and
[MeasureHistogramPath] (which deals with the path string "last in first out" removals and insertions) could be carefully merged to further compact the code and make the measure order unimportant, but that will be a job for another day, if really needed.
So far, my mission is complete, as the code works, no additional measures or meters are needed, every parameter of the Path histogram simulation is adjustable (and only for convenience linked to the equivalent parameter in the actual histogram, so one can notice the similarity). The commented lines write the Path strings to a Test.inc file in the skin's folder - I used those to verify if the results were appropriate.
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
---Measures---
[MeasureFirstValueIndex]
Measure=Calc
Formula=(MeasureFirstValueIndex+1)
[MeasureLastValueIndex]
Group=InitialGroup
Measure=Calc
Formula=(MeasureLastValueIndex+1)
[MeasureInitialHistogramPath]
Group=InitialGroup
Measure=String
String=
IfCondition=(MeasureLastValueIndex<=#Values#)
IfTrueAction=[!SetOption MeasureInitialHistogramPath String "[MeasureInitialHistogramPath]#PathSegment#"][!UpdateMeasureGroup InitialGroup]
IfFalseAction=[!PauseMeasure MeasureInitialHistogramPath][!SetOption MeasureHistogramPath String "[MeasureInitialHistogramPath]"][!UpdateMeasure MeasureHistogramPath]
IfConditionMode=1
;OnUpdateAction=[!WriteKeyValue Variables MeasureInitialHistogramPath "[[MeasureInitialHistogramPath]]" "Test.inc"]
DynamicVariables=1
[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#) | "]
DynamicVariables=1
[MeasureHistogramPath]
Measure=String
String=
RegExpSubstitute=1
Substitute="(?siU)^(?:LineTo .* \| LineTo .* \| ){1}((?:LineTo .* \| LineTo .* \| ){#Values#})$":"\1","-\(\d+\+":"-([MeasureFirstValueIndex]+"
;OnUpdateAction=[!WriteKeyValue Variables "MeasureHistogramPath[MeasureFirstValueIndex]" "[MeasureHistogramPath]" "Test.inc"]
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%
Result:
Path Histogram.jpg
LEGEND:
Value = number of value points in the Path histogram (i.e. how many "columns" there are in it; for convenience, this applies to the actual histogram as well)
Padding = the padding in the skin; since the Histogram example in the manual was used as a basis for this skin, this one is not essential
W = the width of a histogram "column" (for visual and comparison convenience, this applies to the actual histogram as well)
H = the height of a histogram "column" (for visual and comparison convenience, this applies to the actual histogram as well)
The other three variables are self-explanatory, really. The PathSegment variable is used only to build the initial path string, as a slightly different segment string is used for insertion (in the MeasureCPU's OnUpdateAction).