Skip to content

Commit 8363a4f

Browse files
feat: Adding color and updating progress scaling ( Fixes PoshWeb#13, Fixes PoshWeb#15 )
1 parent 0eab1c9 commit 8363a4f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

build.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ $history = @(try {
115115

116116
$buildTimes | ConvertTo-Html -Title BuildTimes > ./times.html
117117

118+
119+
118120
@(
119121
"<html>"
120122

@@ -142,7 +144,16 @@ $buildTimes | ConvertTo-Html -Title BuildTimes > ./times.html
142144
"<h2>Time to build 4096 markdown files</h2>"
143145
"<h3>Last built at $([DateTime]::UtcNow.ToString("s")) running @ $cpuSpeed Mhz</h3>"
144146
"<h4><a href='https://github.com/PowerShellWeb/4kbMarkdownFiles/'><button>Github Repo</button></a></h4>"
147+
145148
foreach ($buildTime in $buildTimes) {
149+
$green = [Math]::Floor(
150+
(1 - $buildTime.RelativeSpeed) * 255
151+
)
152+
$red = [Math]::Floor(
153+
(1 - $buildTime.RelativeSpeed) * 255
154+
)
155+
$color = "#{0:x2}{1:x2}00" -f $red, $green
156+
146157
"<details open>"
147158
"<summary class='techniqueSummary'>$($buildTime.Technique) ($([Math]::Round(
148159
$buildTime.Time.TotalSeconds, 2
@@ -154,8 +165,8 @@ $buildTimes | ConvertTo-Html -Title BuildTimes > ./times.html
154165
"</code></pre>"
155166
"</details>"
156167
"<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'>"
157-
"<rect x='0%' width='1%' height='100%'>"
158-
"<animate attributeName='width' from='1%' to='$([Math]::Round($buildTime.relativeSpeed * 100, 2))%' dur='$($buildTime.Time.TotalSeconds)s' fill='freeze' />"
168+
"<rect x='0%' width='1%' height='100%' fill='$color' stroke='currentColor'>"
169+
"<animate attributeName='width' from='1%' to='100%' dur='$($buildTime.Time.TotalSeconds)s' fill='freeze' />"
159170
"</rect>"
160171
"</svg>"
161172
"</details>"

0 commit comments

Comments
 (0)