Vizrt gap comparaison


structure onoffcontainer
dYScale as double
sContainerName as string
end structure

dim sRefCont = (string) “txt_result_reference”
dim sLeftScoreCont = (string) “txt_result_left”
dim sRightScoreCont = (string) “txt_result_right”

dim sLeftContMask = (string) “left_progress_bar”
dim sRightContMask = (string) “right_progress_bar”

dim sTextGap = (string) “txt_gap”

dim dPercentageRight as Double

dim sBaseContainerName = (string) “ONOFF_RESULT_GAP”
dim sBaseLineContainerPrefix = (string) “RESULT_GAP”

dim vRef = (double) CDbl(scene.findcontainer(sBaseContainerName).findsubcontainer(sBaseLineContainerPrefix).findsubcontainer(sRefCont).geometry.text)

sub OnInitParameters()
RegisterPushButton(“action”, “Calculate All Progress Bar Size”, 0)
‘RegisterPushButton(“SetLeftSize”, “Calculate Left Progress Bar Size”, 1)
‘RegisterPushButton(“SetRightSize”, “Calculate Right Progress Bar Size”, 2)
‘RegisterPushButton(“SetGapColor”, “Set Right Bar Color”, 3)
end sub

sub OnExecAction(buttonId As Integer)
SetLeftSize()
SetRightSize()
SetTextGap()
SetColor(“color_pipe”, “color_bg”)
end sub

sub SetLeftSize()
dim vLeft = CDbl(scene.findcontainer(sLeftScoreCont).geometry.text)
dim dPercentageLeft = (double) (vLeft/vRef)
dim cLeftMaskContainer = (container) scene.findcontainer(sLeftContMask)
if dPercentageLeft > 1 then
dPercentageLeft = 1
end if
if dPercentageLeft < 0 then
dPercentageLeft = 0
end if
cLeftMaskContainer.scaling.y = dPercentageLeft
end sub

sub SetRightSize()
dim vRight = CDbl(scene.findcontainer(sRightScoreCont).geometry.text)
dPercentageRight = (double) (vRight/vRef)
dim cRightMaskContainer = (container) scene.findcontainer(sRightContMask)
if dPercentageRight > 1 then
dPercentageRight = 1
end if
if dPercentageRight < 0 then
dPercentageRight = 0
end if
cRightMaskContainer.scaling.y = dPercentageRight
end sub

sub SetColor(target1 as String, target2 as String)
dim dKeyFrame1 = FindKeyFrame(target1)
dim dKeyFrame2 = FindKeyFrame(target2)
if dPercentageRight = 1 then
dKeyFrame1.MaterialValue.Color.SetRGB(cdbl(255)/255, cdbl(255)/255, cdbl(255)/255)
dKeyFrame2.MaterialValue.Color.SetRGB(cdbl(255)/255, cdbl(255)/255, cdbl(255)/255)
else
if dPercentageRight > 1 then
dKeyFrame1.MaterialValue.Color.SetRGB(cdbl(31)/255, cdbl(190)/255, cdbl(27)/255)
dKeyFrame2.MaterialValue.Color.SetRGB(cdbl(31)/255, cdbl(190)/255, cdbl(27)/255)
else
dKeyFrame1.MaterialValue.Color.SetRGB(cdbl(153)/255, cdbl(1)/255, cdbl(17)/255)
dKeyFrame2.MaterialValue.Color.SetRGB(cdbl(153)/255, cdbl(1)/255, cdbl(17)/255)
end if
end if
end sub

sub SetTextGap()

dim dLeftval = CDbl(scene.findcontainer(sLeftScoreCont).geometry.text)
dim dRightval = CDbl(scene.findcontainer(sRightScoreCont).geometry.text)
dim dGapVal = (double) dRightVal-dLeftVal
dim dGapStr = (string) dGapVal
dim aGapArr as Array[String]
dGapStr.split(“”, aGapArr)

dim dArrayLength = (integer) aGapArr.size

dim aNewStringArr as Array[String]

For i = 0 to dArrayLength
if aGapArr[i] = “.” then
dArrayLength = 5
else
Println i
end if
aNewStringArr.push(aGapArr[i])

Next

if dGapVal > 0 then
‘dKeyFrameGapValue.MaterialValue.Color.SetRGB(cdbl(31)/255, cdbl(190)/255, cdbl(27)/255)
Scene.FindContainer(sTextGap).geometry.text = (string) “+ “&dGapVal
else
‘dKeyFrameGapValue.MaterialValue.Color.SetRGB(cdbl(153)/255, cdbl(1)/255, cdbl(17)/255)
Scene.FindContainer(sTextGap).geometry.text = (string) dGapVal
end if
end sub