easingTween

package
v0.0.0-...-a8ee3e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

Example

Webassembly and Golang tween functions example

This example can move 200 divs simultaneously on my Sansung Galaxy A51 phone (a basic cell phone model, with android) and 700 divs on my Mac Book.

Environment variables:

GOARCH=wasm
GOOS=js

Go tool arguments:

-o main.wasm

Code Golang:

//go:build js
// +build js

//
package main

import (
  global "github.com/helmutkemper/iotmaker.santa_isabel_theater.globalConfig"
  "github.com/helmutkemper/iotmaker.santa_isabel_theater.platform.webbrowser/css"
  document2 "github.com/helmutkemper/iotmaker.santa_isabel_theater.platform.webbrowser/document"
  "github.com/helmutkemper/iotmaker.santa_isabel_theater.platform.webbrowser/factoryBrowserImage"
  "github.com/helmutkemper/iotmaker.santa_isabel_theater.platform/mathUtil"
  "github.com/helmutkemper/iotmaker.santa_isabel_theater.platform/tween"
  "log"
  "strconv"
  "time"
)

func main() {
  
  done := make(chan struct{}, 0)
  document := global.Global.Document
  
  // Carrega a imagem
  factoryBrowserImage.NewImage(
    29,
    50,
    map[string]interface{}{
      "id":  "spacecraft",
      "src": "./small.png",
    },
    true,
    false,
  )
  
  var err error
  document.GetElementById(document, "palco")
  for a := 0; a != 500; a += 1 {
    
    id := "div_" + strconv.FormatInt(int64(a), 10)
    var cssClass = css.Class{}
    cssClass.SetList("current", "animate")
    err = document.CreateElement(document, "palco", "div", document2.Property{Property: "id", Value: id}, cssClass)
    if err != nil {
      log.Printf("document.CreateElement().error: %v", err.Error())
    }
    var e = document.GetElementById(document, id)
    
    a := tween.Tween{}
    a.
      SetDuration(
        time.Duration(mathUtil.Int(2000, 5000))*time.Millisecond,
      ).
      SetValues(
        mathUtil.Float64FomInt(0, global.Global.Document.GetDocumentWidth()-29),
        mathUtil.Float64FomInt(0, global.Global.Document.GetDocumentWidth()-29),
      ).
      SetOnStepFunc(
        func(x, p float64, ars ...interface{}) {
          px := strconv.FormatFloat(x, 'E', 10, 32) + "px"
          document.SetElementStyle(e, "left", px)
        },
      ).
      SetLoops(-1).
      SetTweenFunc(tween.KLinear).
      Start()
    
    b := tween.Tween{}
    b.
      SetDuration(
        time.Duration(mathUtil.Int(2000, 5000))*time.Millisecond,
      ).
      SetValues(
        mathUtil.Float64FomInt(0, global.Global.Document.GetDocumentHeight()-50),
        mathUtil.Float64FomInt(0, global.Global.Document.GetDocumentHeight()-50),
      ).
      SetOnStepFunc(
        func(y, p float64, ars ...interface{}) {
          py := strconv.FormatFloat(y, 'E', 10, 32) + "px"
          document.SetElementStyle(e, "top", py)
        },
      ).
      SetLoops(-1).
      SetTweenFunc(tween.KLinear).
      Start()
  
  }
  
  <-done
}

Html code:

<html>
<head>
  <meta charset="utf-8"/>
  <style>
      body {
          margin: 0 !important;
          padding: 0 !important;
      }

      .animate {
        width: 29px;
        height: 50px;
        position: absolute;
        background-image: url("./small.png");
      }
  </style>
  <script src="wasm_exec.js"></script>
  <script>
    const go = new Go();
    WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) => {
      go.run(result.instance);
    });
  </script>
</head>
<body>
  <div id="palco"></div>
</body>
</html>

Browser screen: motion 500 divs

Webassembly needs a server to run. The example below is a simple static server that prints the IP address to standard output.

package main

import (
  "log"
  "net"
  "net/http"
)

func main() {
  var err error
  var addrs []net.Addr
  
  var ifaces []net.Interface
  
  ifaces, err = net.Interfaces()
  // handle err
  for _, i := range ifaces {
    addrs, err = i.Addrs()
    // handle err
    for _, addr := range addrs {
      var ip net.IP
      switch v := addr.(type) {
      case *net.IPNet:
        ip = v.IP
      case *net.IPAddr:
        ip = v.IP
      }
      log.Printf("addr: %v", ip)
    }
  }
  
  fs := http.FileServer(http.Dir("./"))
  http.Handle("/", fs)
  
  log.Println("Listening on :3000..")
  err = http.ListenAndServe(":3000", nil)
  if err != nil {
    log.Fatal(err)
  }
}

Samples files: ./example/motion_500_divs

Documentation

Overview

Package tween

English

Português:

Index

Constants

This section is empty.

Variables

View Source
var KEaseInBack = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return math.Pow(currentPercentage, 2.0)*(1.70158+1*currentPercentage-1.70158)*delta + startValue
}
View Source
var KEaseInBounce = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {

	value := interactionCurrent / interactionTotal
	endValue -= startValue
	return endValue - EaseOutBounce(0, endValue, value) + startValue
}
View Source
var KEaseInCircular = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return -delta*(math.Sqrt(math.Abs(1-math.Pow(currentPercentage, 2.0)))-1) + startValue
}

KEaseInCircular

English:

Circular easing in, accelerating from zero velocity

Português:

Circular easing in, acelerando do zero até a velocidade
View Source
var KEaseInCubic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return delta*math.Pow(currentPercentage, 3.0) + startValue
}

en: Cubic easing in - accelerating from zero velocity

View Source
var KEaseInElastic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {

	if currentPercentage == 0 {
		return startValue
	}

	if currentPercentage == 1.0 {
		return 1.0*delta + startValue
	}

	currentPercentage -= 1

	return -(math.Pow(2, 10*currentPercentage)*math.Sin((currentPercentage-0.075)*20.9435102))*delta + startValue
}
View Source
var KEaseInExponential = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return delta*math.Pow(2, 10*(currentPercentage-1)) + startValue
}

en: exponential easing in - accelerating from zero velocity

View Source
var KEaseInOutBack = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	currentPercentage = currentPercentage / 0.5

	if currentPercentage < 1 {
		return 0.5*(math.Pow(currentPercentage, 2.0)*(3.5949095*currentPercentage-2.5949095))*delta + startValue
	}
	currentPercentage -= 2
	return 0.5*(math.Pow(currentPercentage, 2.0)*(3.5949095*currentPercentage+2.5949095)+2)*delta + startValue
}
View Source
var KEaseInOutBounce = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	if currentPercentage < 0.5 {
		return (1.0-bounceOut(1-2*currentPercentage))/2*delta + startValue
	} else {
		return (1.0+bounceOut(2*currentPercentage-1))/2*delta + startValue
	}
}
View Source
var KEaseInOutCircular = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	currentPercentage = currentPercentage * 2
	if currentPercentage < 1 {
		return -1*delta/2*(math.Sqrt(1-math.Pow(currentPercentage, 2.0))-1) + startValue
	}
	currentPercentage -= 2
	return delta/2*(math.Sqrt(1-math.Pow(currentPercentage, 2.0))+1) + startValue
}

en: circular easing in/out - acceleration until halfway, then deceleration

View Source
var KEaseInOutCubic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	currentPercentage = currentPercentage * 2
	if currentPercentage < 1 {
		return delta/2*math.Pow(currentPercentage, 3.0) + startValue
	}
	currentPercentage -= 2
	return delta/2*(math.Pow(currentPercentage, 3.0)+2) + startValue
}

en: cubic easing in/out - acceleration until halfway, then deceleration

View Source
var KEaseInOutElastic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {

	value := interactionCurrent / interactionTotal

	if value == 0 {
		return startValue
	}

	value /= 0.5
	if value == 2 {
		return endValue
	}

	if value < 1.0 {
		value -= 1
		return -0.5*(math.Pow(2.0, 10.0*value)*math.Sin((value-0.075)*20.9435102))*delta + startValue
	}

	value -= 1
	return math.Pow(2.0, -10.0*value)*math.Sin((value-0.075)*20.9435102)*0.5*delta + endValue
}
View Source
var KEaseInOutExponential = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	interactionCurrent /= interactionTotal / 2
	if interactionCurrent < 1 {
		return delta/2*math.Pow(2, 10*(interactionCurrent-1)) + startValue
	}
	interactionCurrent--
	return delta/2*(-1*math.Pow(2, -10*interactionCurrent)+2) + startValue
}

en: exponential easing in/out - accelerating until halfway, then decelerating

View Source
var KEaseInOutQuadratic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	interactionCurrent /= interactionTotal / 2
	if interactionCurrent < 1 {
		return delta/2*math.Pow(interactionCurrent, 2.0) + startValue
	}
	interactionCurrent--
	return -1*delta/2*(interactionCurrent*(interactionCurrent-2)-1) + startValue
}

en: Quadratic easing in/out - acceleration until halfway, then deceleration

View Source
var KEaseInOutQuartic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	currentPercentage = currentPercentage * 2
	if currentPercentage < 1 {
		return delta/2*math.Pow(currentPercentage, 4.0) + startValue
	}
	currentPercentage -= 2
	return -1*delta/2*(math.Pow(currentPercentage, 4.0)-2) + startValue
}

en: quartic easing in/out - acceleration until halfway, then deceleration

View Source
var KEaseInOutQuintic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	currentPercentage = currentPercentage * 2
	if currentPercentage < 1 {
		return delta/2*math.Pow(currentPercentage, 5.0) + startValue
	}
	currentPercentage -= 2
	return delta/2*(math.Pow(currentPercentage, 5.0)+2) + startValue
}

en: quintic easing in/out - acceleration until halfway, then deceleration

View Source
var KEaseInOutSine = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return -1*delta/2*(math.Cos(math.Pi*currentPercentage)-1) + startValue
}

en: sinusoidal easing in/out - accelerating until halfway, then decelerating

View Source
var KEaseInQuadratic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return delta*math.Pow(currentPercentage, 2.0) + startValue
}

en: quadratic easing in - accelerating from zero velocity

View Source
var KEaseInQuartic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	interactionCurrent /= interactionTotal
	return delta*math.Pow(interactionCurrent, 4.0) + startValue
}

en: quartic easing in - accelerating from zero velocity

View Source
var KEaseInQuintic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return delta*math.Pow(currentPercentage, 5.0) + startValue
}

en: quintic easing in - accelerating from zero velocity

View Source
var KEaseInSine = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return -1*delta*math.Cos(currentPercentage*1.570796) + delta + startValue
}

en: sinusoidal easing in - accelerating from zero velocity

View Source
var KEaseOutBack = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	currentPercentage = currentPercentage - 1
	return (math.Pow(currentPercentage, 2.0)*(2.70158*currentPercentage+1.70158)+1)*delta + startValue
}
View Source
var KEaseOutBounce = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {

	if currentPercentage < 0.36363636363 {
		formula := 7.5625 * math.Pow(currentPercentage, 2.0)
		return formula*delta + startValue
	} else if currentPercentage < 0.72727272727 {
		currentPercentage -= 0.54545454545
		formula := 7.5625*math.Pow(currentPercentage, 2.0) + 0.75
		return formula*delta + startValue
	} else if currentPercentage < 0.90909090909 {
		currentPercentage -= 0.81818181818
		formula := 7.5625*math.Pow(currentPercentage, 2.0) + 0.9375
		return formula*delta + startValue
	} else {
		currentPercentage -= 0.95454545454
		formula := 7.5625*math.Pow(currentPercentage, 2.0) + 0.984375
		return formula*delta + startValue
	}
}
View Source
var KEaseOutCircular = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	currentPercentage--
	return delta*math.Sqrt(1-math.Pow(currentPercentage, 2.0)) + startValue
}

en: circular easing out - decelerating to zero velocity

View Source
var KEaseOutCubic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	currentPercentage--
	return delta*(math.Pow(currentPercentage, 3.0)+1) + startValue
}

en: cubic easing out - decelerating to zero velocity

View Source
var KEaseOutElastic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	value := interactionCurrent / interactionTotal

	if value == 0 {
		return startValue
	}

	if value == 1.0 {
		return 1.0*delta + startValue
	}

	return ((math.Pow(2.0, -10.0*value)*math.Sin((value-0.075)*20.9435102))+1.0)*delta + startValue
}
View Source
var KEaseOutExponential = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return delta*(-1*math.Pow(2, -10*currentPercentage)+1) + startValue
}

en: exponential easing out - decelerating to zero velocity

View Source
var KEaseOutQuadratic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return -1*delta*currentPercentage*(currentPercentage-2) + startValue
}

en: quadratic easing out - decelerating to zero velocity

View Source
var KEaseOutQuartic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	currentPercentage -= 1
	return -1*delta*(math.Pow(currentPercentage, 4.0)-1) + startValue
}

en: quartic easing out - decelerating to zero velocity

View Source
var KEaseOutQuintic = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	interactionCurrent /= interactionTotal
	interactionCurrent--
	return delta*(math.Pow(interactionCurrent, 5.0)+1) + startValue
}

en: quintic easing out - decelerating to zero velocity

View Source
var KEaseOutSine = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return delta*math.Sin(currentPercentage*1.570796) + startValue
}

en: sinusoidal easing out - decelerating to zero velocity

View Source
var KLinear = func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64 {
	return delta*currentPercentage + startValue
}

en: simple linear tweening - no easing, no acceleration

Functions

func EaseOutBounce

func EaseOutBounce(start, end, value float64) float64

func SelectRandom

func SelectRandom() func(interactionCurrent, interactionTotal, currentPercentage, startValue, endValue, delta float64) float64

Types

type Tween

type Tween struct {
	// contains filtered or unexported fields
}

func (*Tween) End

func (el *Tween) End() (object interfaces.TweenInterface)

End

English:

Terminates all interactions of the chosen Tween function, without invoking the onCycleEnd and
onEnd functions.

 Saída:
   object: reference to the current Tween object.

Português:

Termina todas as interações da função Tween escolhida, sem invocar as funções onCycleEnd e onEnd.

Saída:
  object: referência para o objeto Tween corrente.

func (*Tween) SetArgumentsFunc

func (el *Tween) SetArgumentsFunc(arguments interface{}) (object interfaces.TweenInterface)

SetArgumentsFunc

English:

Determines the arguments passed to event functions.

 Input:
   arguments: list of interfaces{} passed to all event functions when they are invoked.

 Output:
   object: reference to the current Tween object.

 Note:
   * If you need complex functions, remember to use pointers to data in the arguments.

Português:

Determina os argumentos passados para as funções de eventos.

 Entrada:
   arguments: lista de interfaces{} passadas para todas as funções de eventos quando elas são invocadas.

 Saída:
   object: referência para o objeto Tween corrente.

 Nota:
   * Caso necessite de funções complexas, lembre-se de usar ponteiros para dados nos argumentos.

func (*Tween) SetDoNotReverseMotion

func (el *Tween) SetDoNotReverseMotion() (object interfaces.TweenInterface)

SetDoNotReverseMotion

English:

Defines the option of reversing values at the end of each cycle.

 Input:
   value: true to not revert the values at the end of each cycle.

 Output:
   object: reference to the current Tween object.

 Notas:
   * In case of loop, the order of event functions are: SetOnStartFunc(), SetOnCycleStartFunc(),
     SetOnCycleEndFunc(), SetOnInvertFunc(), SetOnCycleStartFunc(), SetOnCycleEndFunc(),
     SetOnInvertFunc() ...
   * SetOnEndFunc() will only be called at the end of all interactions;
   * This function prevents inversion of values, but the SetOnInvertFunc() event function
     continues to be called.

Português:

Define a opção de reversão de valores ao final de cada ciclo.

 Entrada:
   value: true para não reverter os valores ao final de cada ciclo.

 Saída:
   object: referência para o objeto Tween corrente.

 Notas:
   * Em caso de laço, a ordem das funções de eventos são: SetOnStartFunc(), SetOnCycleStartFunc(),
     SetOnCycleEndFunc(), SetOnInvertFunc(), SetOnCycleStartFunc(), SetOnCycleEndFunc(),
     SetOnInvertFunc() ...
   * SetOnEndFunc() só será chamada ao final de todas as interações.
   * Esta função impede a inversão de valores, mas, a função de evento SetOnInvertFunc() continua
     sendo chamada.

func (*Tween) SetDuration

func (el *Tween) SetDuration(value time.Duration) (object interfaces.TweenInterface)

SetDuration

English:

Defines the total cycle time of interactions.

 Input:
   value: time.Duration contendo o tempo do ciclo de interações.

 Output:
   object: reference to the current Tween object.

Português:

Define o tempo total do ciclo de interações.

 Entrada:
   value: time.Duration contendo o tempo do ciclo de interações.

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) SetEngine

func (el *Tween) SetEngine(value engine.IEngine) (object interfaces.TweenInterface)

SetEngine

English:

Defines a new engine for time control.

 Input:
   value: object compatible with the engine.IEEngine interface

 Output:
   object: reference to the current Tween object.

Português:

Define uma nova engine para controle de tempo.

 Entrada:
   value: objeto compatível com ã interface engine.IEngine

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) SetLoops

func (el *Tween) SetLoops(value int) (object interfaces.TweenInterface)

SetLoops

English:

Defines the number of loops before the end of the function.

 Notes:
   * At each new iteration of the loop, a movement inversion will occur, unless the
     SetDoNotReverseMotion(true) function is used;
   * For infinite loops, set the value to -1;
   * In case of loop, the order of event functions are: SetOnStartFunc(), SetOnCycleStartFunc(),
     SetOnCycleEndFunc(), SetOnInvertFunc(), SetOnCycleStartFunc(), SetOnCycleEndFunc(),
     SetOnInvertFunc() ...
   * SetOnEndFunc() will only be called at the end of all interactions.

Português:

Define a quantidade de laços antes do fim da função.

 Notas:
   * A cada nova interação do laço ocorrerá uma inversão de movimento, a não ser que seja usada a
     função SetDoNotReverseMotion(true);
   * Para laços infinitos, defina o valor como sendo -1;
   * Em caso de laço, a ordem das funções de eventos são: SetOnStartFunc(), SetOnCycleStartFunc(),
     SetOnCycleEndFunc(), SetOnInvertFunc(), SetOnCycleStartFunc(), SetOnCycleEndFunc(),
     SetOnInvertFunc() ...
   * SetOnEndFunc() só será chamada ao final de todas as interações.

func (*Tween) SetOnCycleEndFunc

func (el *Tween) SetOnCycleEndFunc(function func(value float64, arguments interface{})) (object interfaces.TweenInterface)

SetOnCycleEndFunc

English:

Adds the function to be called at the ending of the interpolation cycle

 Input:
   function: func(value float64, arguments ...interface{})
     value: final value defined in endValue
     arguments: list of values passed to event functions, defined in SetArguments()

Português:

Adiciona a função a ser chamada no fim do ciclo de interpolação

 Entrada:
   function: func(value float64, arguments ...interface{})
     value: valor final definido em endValue
     arguments: lista de valores passados para as funções de evento, definidos em SetArguments()

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) SetOnCycleStartFunc

func (el *Tween) SetOnCycleStartFunc(function func(value float64, arguments interface{})) (object interfaces.TweenInterface)

SetOnCycleStartFunc

English:

Adds the function to be called at the beginning of the interpolation cycle

 Input:
   function: func(value float64, arguments ...interface{})
     value: initial value defined in startValue
     arguments: list of values passed to event functions, defined in SetArguments()

Português:

Adiciona a função a ser chamada no início do ciclo de interpolação

 Entrada:
   function: func(value float64, arguments ...interface{})
     value: valor inicial definido em startValue
     arguments: lista de valores passados para as funções de evento, definidos em SetArguments()

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) SetOnEndFunc

func (el *Tween) SetOnEndFunc(function func(value float64, arguments interface{})) (object interfaces.TweenInterface)

SetOnEndFunc

English:

Add the function to be called when the animation ends.

 Input:
   function: func(value float64, arguments ...interface{})
     value: final value defined in endValue
     arguments: list of values passed to event functions, defined in SetArguments()

Português:

Adiciona a função a ser chamada quando a animação inicia.

 Entrada:
   function: func(value float64, arguments ...interface{})
     value: valor final definido em endValue
     arguments: lista de valores passados para as funções de evento, definidos em SetArguments()

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) SetOnInvertFunc

func (el *Tween) SetOnInvertFunc(function func(value float64, arguments interface{})) (object interfaces.TweenInterface)

SetOnInvertFunc

English:

Adds the function to be called on inversion of the interpolation cycle

 Input:
   function: func(value float64, arguments ...interface{})
     value: current value
     arguments: list of values passed to event functions, defined in SetArguments()

Português:

Adiciona a função a ser chamada a cada interação

 Entrada:
   function: func(value, percentToComplete float64, arguments ...interface{})
     value: valor corrente
     arguments: lista de valores passados para as funções de evento, definidos em SetArguments()

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) SetOnStartFunc

func (el *Tween) SetOnStartFunc(function func(value float64, arguments interface{})) (object interfaces.TweenInterface)

SetOnStartFunc

English:

Add the function to be called when the animation starts.

 Input:
   function: func(value float64, arguments ...interface{})
     value: initial value defined in startValue
     arguments: list of values passed to event functions, defined in SetArguments()

Português:

Adiciona a função a ser chamada quando a animação inicia.

 Entrada:
   function: func(value float64, arguments ...interface{})
     value: valor inicial definido em startValue
     arguments: lista de valores passados para as funções de evento, definidos em SetArguments()

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) SetOnStepFunc

func (el *Tween) SetOnStepFunc(function func(value, percentToComplete float64, arguments interface{})) (object interfaces.TweenInterface)

SetOnStepFunc

English:

Adds the function to be called for each iteration.

 Input:
   function: func(value float64, arguments ...interface{})
     value: current value
     percentToComplete: value between 0.0 and 1.0 indicating the percentage of the process
     arguments: list of values passed to event functions, defined in SetArguments()

Português:

Adiciona a função a ser chamada a cada interação

 Entrada:
   function: func(value float64, arguments ...interface{})
     value: valor corrente
     percentToComplete: valor entre 0.0 e 1.0 indicando o percentual do processo
     arguments: lista de valores passados para as funções de evento, definidos em SetArguments()

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) SetTweenFunc

func (el *Tween) SetTweenFunc(value func(currentTime, duration, currentPercentage, startValue, endValue, changeInValue float64) (percent float64)) (object interfaces.TweenInterface)

SetTweenFunc

English:

Defines the tween math function to control the loop of interactions

 Input:
   value: tween math function.
     currentTime:   current time, int64(time.Duration);
     duration:      total time, int64(time.Duration);
     startValue:    initial value;
     endValue:      final value;
     changeInValue: startValue - endValue

 Output:
   object: reference to the current Tween object.

 Note:
   * To create a new function, base it on the linear function, where:
       return changeInValue * currentTime / duration + startValue

Português:

Define a função matemática tween para controle do ciclo de interações

 Entrada:
   value: função matemática tween.
     currentTime:   tempo atual, int64(time.Duration);
     duration:      tempo total, int64(time.Duration);
     startValue:    valor inicial;
     endValue:      valor final;
     changeInValue: startValue - endValue

 Saída:
   object: referência para o objeto Tween corrente.

 Nota:
   * Para criar uma nova função, tenha como base a função linear, onde:
       return changeInValue * currentTime / duration + startValue

func (*Tween) SetValues

func (el *Tween) SetValues(start, end float64) (object interfaces.TweenInterface)

SetValues

English:

Defines the initial and final values of the interactions cycle.

 Input:
   start: initial value for the beginning of the cycle of interactions;
   end:   final value for the end of the iteration cycle.

 Output:
   object: reference to the current Tween object.

Português:

Defines os valores inicial e final do ciclo de interações.

 Entrada:
   start: valor inicial para o início do ciclo de interações;
   end:   valor final para o fim do ciclo de interações.

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) Start

func (el *Tween) Start() (object interfaces.TweenInterface)

Start

English:

Starts the interaction according to the chosen tween function.

 Output:
   object: reference to the current Tween object.

Português:

Inicia a interação conforme a função tween escolhida.

 Saída:
   object: referência para o objeto Tween corrente.

func (*Tween) Stop

func (el *Tween) Stop() (object interfaces.TweenInterface)

Stop

English:

Ends all interactions of the chosen Tween function, interacting with the onCycleEnd and onEnd
functions, respectively, in that order, if they have been defined.

 Output:
   object: reference to the current Tween object.

Português:

Termina todas as interações da função Tween escolhida, interagindo com as funções onCycleEnd e
onEnd, respectivamente nessa ordem, se elas tiverem sido definidas.

 Saída:
   object: referência para o objeto Tween corrente.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL