EvenirXaneis wrote:xela wrote:the simplest implementation of a circle bar that I've seen was simply 100 images for 100 states and a displayable that showed a correct state based of variable.
I did think of that and was hoping to avoid it if possible. I also just recently had a thought to make basically the illusion of a half-circle bar, which would use the vertical bar code to decrease the value, but it would appear to be a curved bar. It's not exactly what I want, but it's a possibility.
It is likely the easiest way. I can think of a couple different ways how this could be done without one image per frame, but all of them would require a lot of fiddling and more complicated code, and they probably wouldn't work anyway.
But here's a version of the simple solution that I made just for you. Need to do something for someone once in a while. Also made you some circles... but only 8.
I'll attach two versions, a simple one with one "bar" and a slightly more complex one with 3 bars like in your example. It uses only one color of a circle and instead used hue manipulation to change the color.
And also, here's how the code looks like:
For the simpler version:
Code: Select all
init python:
# I used a color matrix to adjust hue and brightness
def cBarTest(st,at):
return LiveComposite(
(0,0),
(-100,-100), im.MatrixColor("test/c0.png", im.matrix.brightness(0.5)*im.matrix.hue(cbt['hue'])),
(-100,-100), im.MatrixColor("test/c%d.png"%cbt['value'], im.matrix.brightness(0.0)*im.matrix.hue(cbt['hue'])),
(-100,-100), im.MatrixColor("test/cInside.png", im.matrix.brightness(0.0)),
(-100,-100), im.MatrixColor("test/cOutside.png", im.matrix.brightness(0.0)),
),10
init:
# has to be declared as a dynamic displayable
image cBarTestA = DynamicDisplayable(cBarTest)
# I used a dictionary, but you can use any type of variable. For this to wrk the variable has to be initialized before the game starts, you can also use a "default" statement to do the same
$ cbt = {'value1':2, 'hue1':90}
# A simple screen to show of the bar, it uses slider bars with the dictionary values
screen circleBar:
vbox xalign 0.5 yalign 0.5:
vbox xalign 0.5 yalign 0.5:
add "cBarTestA"
vbox xalign 0.5 yalign 1.0:
bar value DictValue(cbt,'value', 8) xmaximum 200
bar value DictValue(cbt,'hue', 255) xmaximum 200
[/code]
For the more complicated version:
Code: Select all
init python:
def cBarTest(st,at):
return LiveComposite(
(0,0),
(-100,-100), im.MatrixColor("cb/c0.png", im.matrix.brightness(0.5)*im.matrix.hue(cbt['hue1'])),
(-100,-100), im.MatrixColor("cb/c%d.png"%cbt['value1'], im.matrix.brightness(0.0)*im.matrix.hue(cbt['hue1'])),
(-100,-100), im.MatrixColor("cb/cInside.png", im.matrix.brightness(0.0)),
(-100,-100), im.MatrixColor("cb/cOutside.png", im.matrix.brightness(0.0)),
(-75,-75), im.Scale(im.MatrixColor("cb/c0.png", im.matrix.brightness(0.5)*im.matrix.hue(cbt['hue2'])),150,150),
(-75,-75), im.Scale(im.MatrixColor("cb/c%d.png"%cbt['value2'], im.matrix.brightness(0.0)*im.matrix.hue(cbt['hue2'])),150,150),
(-75,-75), im.Scale(im.MatrixColor("cb/cInside.png", im.matrix.brightness(0.0)),150,150),
(-75,-75), im.Scale(im.MatrixColor("cb/cOutside.png", im.matrix.brightness(0.0)),150,150),
(-50,-50), im.Scale(im.MatrixColor("cb/c0.png", im.matrix.brightness(0.5)*im.matrix.hue(cbt['hue3'])),100,100),
(-50,-50), im.Scale(im.MatrixColor("cb/c%d.png"%cbt['value3'], im.matrix.brightness(0.0)*im.matrix.hue(cbt['hue3'])),100,100),
(-50,-50), im.Scale(im.MatrixColor("cb/cInside.png", im.matrix.brightness(0.0)),100,100),
(-50,-50), im.Scale(im.MatrixColor("cb/cOutside.png", im.matrix.brightness(0.0)),100,100),
),10
init:
image cBarTestA = DynamicDisplayable(cBarTest)
$ cbt = {'value1':2, 'hue1':90, 'value2':3, 'hue2':270, 'value3':5, 'hue3':120}
screen circleBar:
vbox xalign 0.5 yalign 0.5 yminimum 300:
vbox xalign 0.5 yalign 0.5:
add "cBarTestA"
hbox xalign 0.5 yalign 1.0:
vbox:
text "bar 1 (value)"
bar value DictValue(cbt,'value1', 8) xmaximum 200
text "bar 1 (color)"
bar value DictValue(cbt,'hue1', 255) xmaximum 200
vbox xminimum 10
vbox:
text "bar 2 (value)"
bar value DictValue(cbt,'value2', 8) xmaximum 200
text "bar 2 (color)"
bar value DictValue(cbt,'hue2', 255) xmaximum 200
vbox xminimum 10
vbox:
text "bar 3 (value)"
bar value DictValue(cbt,'value3', 8) xmaximum 200
text "bar 3 (color)"
bar value DictValue(cbt,'hue3', 255) xmaximum 200
It may not be exactly what you were looking for, but maybe It'll be of some use? If not to you then to somebody else.