# Convert x/y (0.0 - 1.0) point to proper int values based on Hyperion image width/height
# Or get a random value
# @param bool rand Randomize point if true
# @param float x Point at the x axis between 0.0-1.0
# @param float y Point at the y axis between 0.0-1.0
# @return Tuple with (x,y) as Integer
defgetPoint(rand=True,x=0.5,y=0.5):
ifrand:
x=random.uniform(0.0,1.0)
y=random.uniform(0.0,1.0)
x=int(round(x*hyperion.imageWidth()))
y=int(round(y*hyperion.imageHeight()))
return(x,y)
# Returns the required sleep time for a interval function based on rotationtime and steps
# Adapts also to led device latchTime if required
# @param float rt RotationTime in seconds (time for one ration, based on steps)
# @param int steps The steps it should calc the rotation time
# @return Tuple with (x,y) as Integer
defgetSTime(rt,steps=360):
rt=float(rt)
sleepTime=max(0.1,rt)/steps
# adapt sleeptime to hardware
minStepTime=float(hyperion.latchTime)/1000.0
ifminStepTime>sleepTime:
sleepTime=minStepTime
returnsleepTime
# Creates a PRGBA bytearray gradient based on provided colors (RGB or RGBA (0-255, 0-1 for alpha)), the color stop positions are calculated based on color count. Requires at least 2 colors!
# @param tuple cc Colors in a tuple of RGB or RGBA
# @param bool closeCircle If True use last color as first color
# @return bytearray A bytearray of RGBA for hyperion.image*Gradient functions