pilasengine.utils

pilasengine.utils.interpolaciones

pilasengine.utils.pitweener

class pilasengine.utils.pitweener.Tween(obj, tduration, tween_type, complete_function, update_function, delay, inicial, **kwargs)

Clases base: object

Remove()

Disables and removes this tween without calling the complete function

decode_arguments(inicial)

Internal setup procedure to create tweenables and work out how to deal with each

get_tweenable(name)

Return the tweenable values corresponding to the name of the original tweening function or property.

Allows the parameters of tweens to be changed at runtime. The parameters can even be tweened themselves!

Eg:

# the rocket needs to escape!! -- we're already moving, but must go
# faster!
twn = tweener.get_tweens_affecting_object(my_rocket)[0]
tweenable = twn.get_tweenable("thruster_power")
tweener.addTween(tweenable, change=1000.0, tween_time=0.4,
                 tween_type=tweener.IN_QUAD)
pause(seconds=-1)

Pause this tween

Do tween.pause(2) to pause for a specific time, or tween.pause() which pauses indefinitely.

resume()

Resume from pause

update(ptime=None)

Update this tween with the time since the last frame. If there is an update function, it is always called whether the tween is running or paused. ptime is the change in time in seconds.

class pilasengine.utils.pitweener.TweenTestObject

Clases base: object

complete()
get_rotation()
set_rotation(rot)
update()
class pilasengine.utils.pitweener.Tweenable(start, change)

Clases base: object

class pilasengine.utils.pitweener.Tweener

Clases base: pilasengine.utils.pitweener.TweenerEquations

This class manages all active tweens, and provides a factory for creating and spawning tween motions.

add_tween(obj, inicial=None, **kwargs)

Returns Tween object or False

Example:

tweener.add_tween(my_rocket, throttle=50, set_thrust=400,
                  tween_time=5.0, tween_type=tweener.OUT_QUAD)

You must first specify an object, and at least one property or function with a corresponding change value. The tween will throw an error if you specify an attribute the object does not possess. Also the data types of the change and the initial value of the tweened item must match. If you specify a ‘set’ -type function, the tweener will attempt to get the starting value by call the corresponding ‘get’ function on the object. If you specify a property, the tweener will read the current state as the starting value. You add both functions and property changes to the same tween.

in addition to any properties you specify on the object, these keywords do additional setup of the tween.

  • tween_time: the duration of the motion
  • tween_type: a predefined tweening equation or your own function
  • on_complete_function: called on completion of the tween
  • on_update_function: called every time the tween updates
  • tween_delay: a delay before starting.
force_update_one_frame()
get_tweens_affecting_object(obj)

Get a list of all tweens acting on the specified object. Useful for manipulating tweens on the fly.

has_tweens()

Returns True if there are any tweens (paused or unpaused), False otherwise. This function can be useful to determine if a redraw should be done or not.

remove_all_tweens()

Stops and removes every tween associated with this Tweener object.

remove_tween(tween_obj)

Stops and removes the Tween instance passed.

remove_tweening_from(obj)

Stop tweening an object, without completing the motion or firing the complete_function.

update(time_since_last_frame=None)

Update every tween with the time since the last frame. If there is an update function, it is always called whether the tween is running or paused.

time_since_last_frame is the change in time in seconds. If no value is passed, the change in time is measured with time.time() from the previous call of this function. If it is the first time calling this function, timing is measured from the construction of the Tweener engine.

update_time_without_motion()
class pilasengine.utils.pitweener.TweenerEquations

Clases base: object

A set of predefined interpolation (tweening) equations. They are ported from the work of Robert Penner. Each equation takes 4 arguments, the current time from start, the start value, the desired final change from the start value, and the total duration of the tween. As is the nature of interpolation, no equation has units.

Note: When using the Tweener class, you should use the Tweener class’ instance copies of the equations (Tweener extends TweenerEquations)

IN_CUBIC(t, b, c, d)
IN_OUT_CUBIC(t, b, c, d)
IN_OUT_QUAD(t, b, c, d)
IN_OUT_QUART(t, b, c, d)
IN_QUAD(t, b, c, d)
IN_QUART(t, b, c, d)
LINEAR(t, b, c, d)
OUT_CUBIC(t, b, c, d)
OUT_ELASTIC(t, b, c, d)
OUT_EXPO(t, b, c, d)
OUT_IN_CUBIC(t, b, c, d)
OUT_IN_QUAD(t, b, c, d)
OUT_QUAD(t, b, c, d)
OUT_QUART(t, b, c, d)

Contenido del módulo

class pilasengine.utils.Utils(pilas)

Clases base: object

agregar_ruta_personalizada(ruta)
es_interpolacion(valor)
interpolar(actor, atributo, valor, duracion=0.5, tipo='desaceleracion_gradual')
interpretar_propiedad_numerica(objeto, propiedad, valor)

Procesa una propiedad y permite que sea numero o interpolación.

Este método se invoca en la mayoría de propiedades y atributos de actores en pilas-engine. Por ejemplo cuando se invoca a esta sentencia para mover al personaje:

>>> actor.x = [100, 0, 200]

o bien, para duplicar su tamaño en 10 segundos:

>>> actor.escala = [2], 10
obtener_area_de_texto(cadena, magnitud=10, vertical=False, fuente=None, ancho=0)
obtener_directorio_de_configuracion()

” Retorna la ruta de configuracion segun la plataforma

obtener_ruta_al_recurso(ruta)
obtener_uuid()

Genera un identificador único.

pilasengine.utils.centrar_ventana(ventana)

Mueve la ventana al centro del area visible del escritorio.

pilasengine.utils.convertir_a_metros(valor)

Convierte una magnitid de pixels a metros.

pilasengine.utils.convertir_a_pixels(valor)

Convierte una magnitud de metros a pixels.

pilasengine.utils.destacar_ventanas()
pilasengine.utils.iniciar_desde_terminal()
pilasengine.utils.instanciar_interpolacion(pilas, valor_o_valores, duracion=1, demora=0, tipo='lineal')

Retorna un objeto que representa cambios de atributos progresivos.

El resultado de esta función se puede aplicar a varios atributos de los actores, por ejemplo:

>>> bomba = pilas.actores.Bomba()
>>> bomba.escala = pilas.interpolar(3)

Esta función también admite otros parámetros cómo:

Parámetros:
  • duracion – es la cantidad de segundos que demorará toda la interpolación.
  • demora – cuantos segundos se deben esperar antes de iniciar.
  • tipo – es el algoritmo de la interpolación, puede ser ‘lineal’.
pilasengine.utils.obtener_angulo_entre(punto_a, punto_b)

Retorna el ángulo entro dos puntos de la pantalla.

Parámetros:
  • punto_a – Una tupla con la coordenada del primer punto.
  • punto_b – Una tupla con la coordenada del segundo punto.
pilasengine.utils.obtener_ruta_al_recurso(ruta)
pilasengine.utils.realizar_pruebas()

Imprime pruebas en pantalla para detectar si pilas tiene todas las dependencias instaladas.