<?php
// Smooth Decrease Class 0.1 by ming0070913
Class SmoothDecrease{
public $am, $step, $now, $round;
function __construct($amplitude, $step, $round=2){
$this->am = $amplitude;
$this->step = $step;
$this->round = $round;
}
function checkRemain(){
return ($this->now < $this->step);
}
function getValue(){
$this->now++;
if($this->now < $this->step/2)
$r = (1-pow($this->now/$this->step*2,2))*$this->am/2+$this->am/2;
else
$r = (pow(($this->step-$this->now)/$this->step*2,2))*$this->am/2;
return round($r, $this->round);
}
function skip($step){
$this->now += (int) $step;
}
function clear(){
$this->now = 0;
}
}
?>