From e7d588810fc1893dae602e101d071f65ee3b3d70 Mon Sep 17 00:00:00 2001 From: Stormwind Date: Fri, 31 May 2013 09:21:23 +0200 Subject: [PATCH] Color depends on load value Added the load values of all cores and created a overall percentage to use it as base for the heat point. --- testdummy.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/testdummy.rb b/testdummy.rb index a8aadf4..2d66858 100644 --- a/testdummy.rb +++ b/testdummy.rb @@ -26,12 +26,23 @@ dummyList = Array.new(60) do numberGenerator.rand(100) end end + + # Add all loads to compute how much % is one % load + loadSum = 0 + cores.each { |core| loadSum = loadSum + core } + percentLoad = 100.0/loadSum + # every 10 load percent one heatpoint i = 0 Array.new(10) do - amount = cores.select { |core| core >= i and core < (i+10)}.length + # get all cores in the certain percentage + selectedCores= cores.select { |core| core >= i and core < (i+10)} + # (go to next level here) i = i + 10 - amount + # add the load of the resulting cores and multiply it with the overall value + loadSum = 0 + selectedCores.each { |core| loadSum = loadSum + core } + percent = loadSum*percentLoad end end @@ -47,7 +58,7 @@ dummyList.each do |point| # draw a red rectangle on the white background core = Draw.new - l = (255-((cores*7.96875))).round + l = (255-((cores*1.275))).round core.fill(Pixel.from_hsla(0, 255, l, 1).to_color) core.rectangle((i*15), (j*15), ((i+1)*15), ((j+1)*15)) core.draw loadImg