-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResizer.php
55 lines (45 loc) · 1.55 KB
/
Resizer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace VoidEngine;
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @package Resizer
* @copyright 2019 Podvirnyy Nikita (KRypt0n_)
* @license GNU GPLv3 <https://www.gnu.org/licenses/gpl-3.0.html>
* @license Enfesto Studio Group license <https://vk.com/topic-113350174_36400959>
* @author Podvirnyy Nikita (KRypt0n_)
*
* Contacts:
*
* Email: <[email protected]>
* VK: vk.com/technomindlp
* vk.com/hphp_convertation
*
*/
function resize (NetObject $object, array $config = []): Timer
{
$config['speed'] ??= 0.3;
return setTimer (10, function ($self) use ($object, $config)
{
$finished = 0;
foreach (['x', 'y', 'w', 'h'] as $dimension)
if (isset ($config[$dimension]))
{
$object->$dimension += ceil ($config['speed'] * ($config[$dimension] - $object->$dimension));
if ($config['speed'] * abs ($config[$dimension] - $object->$dimension) < 1)
$object->$dimension = $config[$dimension];
if ($object->$dimension == $config[$dimension])
++$finished;
}
else ++$finished;
if ($finished == 4)
{
$self->stop ();
if (isset ($config['callable']))
$config['callable'] ($object);
}
});
}