update...
This commit is contained in:
parent
63d62aec4d
commit
4d7255f105
26 changed files with 518 additions and 641 deletions
55
include/app/rotate.h
Normal file
55
include/app/rotate.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* rotate.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/29 19:00:18 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/01/29 19:27:19 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ROTATE_H
|
||||
#define ROTATE_H
|
||||
|
||||
#include "me/types.h"
|
||||
|
||||
enum e_rotation_direction
|
||||
{
|
||||
FORWARD,
|
||||
REVERSE,
|
||||
};
|
||||
typedef struct s_rotation
|
||||
{
|
||||
t_usize value;
|
||||
t_usize ring_size;
|
||||
enum e_rotation_direction direction;
|
||||
} t_rotation;
|
||||
|
||||
static inline t_rotation forward(t_usize by, t_usize ring_size)
|
||||
{
|
||||
return ((t_rotation){
|
||||
.value = by % ring_size, .ring_size = ring_size, .direction = FORWARD});
|
||||
}
|
||||
|
||||
static inline t_rotation reverse(t_usize by, t_usize ring_size)
|
||||
{
|
||||
return ((t_rotation){
|
||||
.value = by % ring_size, .ring_size = ring_size, .direction = REVERSE});
|
||||
}
|
||||
|
||||
static inline t_rotation flip(t_rotation rot)
|
||||
{
|
||||
enum e_rotation_direction flipped;
|
||||
|
||||
flipped = FORWARD;
|
||||
if (rot.direction == FORWARD)
|
||||
flipped = REVERSE;
|
||||
|
||||
return ((t_rotation){.value = rot.ring_size - rot.value,
|
||||
.ring_size = rot.ring_size,
|
||||
.direction = flipped});
|
||||
}
|
||||
|
||||
#endif /* ROTATE_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue