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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/* SPDX-License-Identifier: MIT */
/*
* konpicture.h
*
* Copyright (c) 2026 KonAki
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef KONPICTURE_H
#define KONPICTURE_H
#include "konsofren.h"
#include "kon2d.h"
#ifdef __cplusplus
extern "C" {
#endif
/*** definition ***/
/* pictures drawn over the screen that can be moved, faded, turned and tinted, the way RPG Maker has them: a number of slots
drawn in order so a higher one is in front, each a picture with a place, a scale in percent, an opacity from 0 to 255,
a blend, an angle and a tone. all the times are in frames at 60 a second, like RPG Maker counts them.
a number that isn't a slot does nothing, so a bad script can't write outside of them */
#define KON_PICTURES 100
#define KON_PICTURE_NAME 64
/* gives the image for a name, or NULL. the pictures do not own what it gives, whoever made the image keeps it until the picture is
erased or replaced */
typedef const kon_image *(*kon_pictureLoad)(const char *name, void *user);
typedef struct kon_picture {
int shown;
char name[KON_PICTURE_NAME];
const kon_image *image;
int origin; /* 0 top left, 1 middle */
int blend; /* a kon_blend_t: 0 normal, 1 add, 2 multiply, 3 screen */
kon_tween_t x, y, scaleX, scaleY, opacity;
kon_tween_t tone[4]; /* red, green, blue added from -255 to 255 and gray from 0 to 255 */
float angle; /* radians */
float turn; /* RPG Maker's rotation speed */
kon_image *toned; /* a copy with the tone in it, made when there is one to apply */
int tonedFor[4];
} kon_picture_t;
typedef struct kon_pictures {
kon_picture_t slot[KON_PICTURES];
kon_pictureLoad load;
void *user;
} kon_pictures_t;
/*** pictures ***/
void kon_picturesInit(kon_pictures_t *pictures, kon_pictureLoad load, void *user);
void kon_picturesFree(kon_pictures_t *pictures);
/* id is 1 to KON_PICTURES. scale is a percent. this puts everything back as given, a picture that is already there is replaced */
void kon_pictureShow(kon_pictures_t *pictures, int id, const char *name, int origin, int x, int y, int scaleX, int scaleY, int opacity, int blend);
/* goes to the new values over frames, with easing 0 constant, 1 slow start, 2 slow end, 3 slow both. 0 frames is at once */
void kon_pictureMove(kon_pictures_t *pictures, int id, int origin, int x, int y, int scaleX, int scaleY, int opacity, int blend, int frames, int easing);
/* turns clockwise, speed is RPG Maker's: half a degree a frame for each 1. 0 stops it */
void kon_pictureRotate(kon_pictures_t *pictures, int id, int speed);
void kon_pictureTint(kon_pictures_t *pictures, int id, int red, int green, int blue, int gray, int frames);
void kon_pictureErase(kon_pictures_t *pictures, int id);
void kon_picturesUpdate(kon_pictures_t *pictures, float dt);
/* draws the shown ones in order, a made copy of a toned picture is kept in the slot, which is why this changes the pictures */
void kon_picturesDraw(kon_pictures_t *pictures, kon_framebuffer_t *fb);
/* 1 while any picture is still moving or changing tone, what a "wait" in a script waits for */
int kon_picturesBusy(const kon_pictures_t *pictures);
#ifdef __cplusplus
}
#endif
#endif /* KONPICTURE_H */
|