main
Dominik Madarász 2023-12-01 22:27:44 +01:00
parent 4af34422f2
commit 5738a5615a
14 changed files with 164 additions and 64 deletions

View File

@ -3440,7 +3440,8 @@ float scale;
void timer_destroy(unsigned timer_handle);
typedef vec3i guid;
guid guid_create();
float ease_nop(float t);
float ease_zero(float t);
float ease_one(float t);
float ease_linear(float t);
float ease_out_sine(float t);
float ease_out_quad(float t);
@ -3487,7 +3488,8 @@ EASE_BOUNCE,
EASE_IN,
EASE_OUT = 0,
EASE_INOUT = EASE_IN * 2,
EASE_NOP = EASE_INOUT | (EASE_BOUNCE + 1),
EASE_ZERO = EASE_INOUT | (EASE_BOUNCE + 1),
EASE_ONE,
EASE_LINEAR,
EASE_INOUT_PERLIN,
EASE_NUM

View File

@ -4,7 +4,8 @@ struct {
float (*ease)(float);
const char *name;
} easings[] = {
{ease_nop, "ease_nop"},
{ease_zero, "ease_zero"},
{ease_one, "ease_one"},
{ease_linear, "ease_linear"},
{ease_out_sine, "ease_out_sine"},
{ease_out_quad, "ease_out_quad"},

View File

@ -153,7 +153,8 @@ int editor_toolbar(int x, int y, int incw, int inch, const char *sym) {
int my = input(MOUSE_Y);
int inc = maxi(incw, inch);
static int ox = 0, oy = 0, dragging = 0; // drag origin
static int ox = 0, oy = 0; // drag origin
static uint64_t dragging = 0;
editor_toolbar_rect = vec4(x,y,x + (incw ? incw * array_count(codepoints) : inch), y + (inch ? inch * array_count(codepoints) : incw) );
int oo = is_hovering(editor_toolbar_rect, vec2(ox,oy));
@ -167,20 +168,24 @@ int editor_toolbar(int x, int y, int incw, int inch, const char *sym) {
ix += incw;
iy += inch;
}
// debug:
// ddraw_push_2d();
// ddraw_aabb(vec3(editor_toolbar_rect.x,editor_toolbar_rect.y,0),vec3(editor_toolbar_rect.z,editor_toolbar_rect.w,0));
// ddraw_pop_2d();
if( 0 && editor_toolbar_hovered() ) { // debug:
ddraw_push_2d();
ddraw_aabb(vec3(editor_toolbar_rect.x,editor_toolbar_rect.y,0),vec3(editor_toolbar_rect.z,editor_toolbar_rect.w,0));
ddraw_pop_2d();
}
if( 1 ) // is_hovering(editor_toolbar_rect, vec2(mx,my)) )
{
if( input_down(MOUSE_L) && editor_toolbar_hovered() ) {
uint64_t id = hash_bin(&editor_toolbar_rect, sizeof(vec4));
if( input_down(MOUSE_L) && editor_toolbar_hovered() && !dragging ) {
window_cursor_shape(0);
editor_toolbar_drag = vec4(0,0, mx,my);
ox = mx, oy = my, dragging = 1;
ox = mx, oy = my, dragging = id;
int mcx = ((ox - x) / inc) + 1, mcy = ((oy - y) / inc) + 1; // mouse cells
return incw ? -mcx : -mcy;
}
if( input(MOUSE_L) && dragging ) {
if( input(MOUSE_L) && dragging == id ) {
int mcx = ((ox - x) / inc) + 1, mcy = ((oy - y) / inc) + 1; // mouse cells
editor_toolbar_drag.x = mx - editor_toolbar_drag.z;
editor_toolbar_drag.y = my - editor_toolbar_drag.w;
@ -190,14 +195,13 @@ int editor_toolbar(int x, int y, int incw, int inch, const char *sym) {
editor_toolbar_drag.w = oy;
return incw ? -mcx : -mcy;
}
if( input_up(MOUSE_L) && dragging ) {
if( input_up(MOUSE_L) && dragging == id ) {
int mcx = ((ox - x) / inc) + 1, mcy = ((oy - y) / inc) + 1; // mouse cells
window_cursor_shape(CURSOR_SW_AUTO);
ox = oy = 0, dragging = 0;
return incw ? mcx : mcy;
}
}
editor_toolbar_drag = vec4(0,0,0,0);
return 0;
}
@ -472,26 +476,51 @@ int main(){
camera_t *cam = camera_get_active();
int choice1 = editor_toolbar(window_width()-32, ui_has_menubar() ? 34 : 0, 0, 32,
int font_ascent_diff = 4; // ascent(mdi) - ascent(md) // @todo: move this into font api
int choiceV = editor_toolbar(window_width()-32, ui_has_menubar() ? 34 + font_ascent_diff : 0, 0, 32,
va(
ICON_MD_VISIBILITY
ICON_MD_360 // ICON_MDI_ORBIT
ICON_MDI_ARROW_ALL
ICON_MD_LOUPE // ZOOM_OUT_MAP // ICON_MD_ZOOM_IN
ICON_MD_GRID_ON ); // ICON_MDI_GRID );
int choice2 = editor_toolbar(window_width()-32*2, ui_has_menubar() ? 34 : 0, -32, 0, ICON_MD_SQUARE_FOOT );
"%s", camera_get_active()->orthographic ? ICON_MDI_AXIS_ARROW_INFO : ICON_MDI_AXIS_ARROW // ICON_MDI_GRID_OFF : ICON_MDI_GRID // ICON_MD_GRID_ON
)
);
static int rot_snapping = 0;
static int pos_snapping = 1;
int choiceH = editor_toolbar(window_width()-32*2, ui_has_menubar() ? 34 : 0, -32, 0,
va(
ICON_MDI_ANGLE_ACUTE
//ICON_MDI_ARROW_COLLAPSE
//ICON_MDI_ARTBOARD
"%s", pos_snapping ? ICON_MDI_DOTS_SQUARE : ICON_MDI_DOTS_CIRCLE
)
);
if( choice1 > 0 ) { // clicked[>0]
if( choiceV ) { // clicked[>0] dragged[<0]
camera_t *cam = camera_get_active();
if( choice1 == 4 ) cam->orthographic ^= 1, camera_fps(cam, 0, 0);
}
if( choice1 < 0 ) { // dragged[<0]
vec2 mouse_sensitivity = vec2(0.1, -0.1); // sensitivity + polarity
vec2 drag = mul2( editor_toolbar_dragged(), mouse_sensitivity );
if( choice1 == -1 ) camera_fps(cam, drag.x, drag.y );
if( choice1 == -2 ) camera_orbit(cam, drag.x, drag.y, 0); //len3(cam->position) );
if( choice1 == -3 ) camera_fov(cam, cam->fov += drag.y - drag.x);
if( choiceV == -1 ) camera_fps(cam, drag.x, drag.y );
if( choiceV == -2 ) camera_orbit(cam, drag.x, drag.y, 0); //len3(cam->position) );
if( choiceV == -3 ) camera_moveby(cam, scale3(vec3(drag.x, drag.y, 0), 10)) ;
if( choiceV == -4 ) camera_fov(cam, cam->fov += drag.y - drag.x);
if( choiceV == 5 ) cam->orthographic ^= 1, camera_fps(cam, 0, 0);
}
if( choiceH ) {
if( choiceH == 2 ) pos_snapping ^= 1;
}
// font demo
font_print(va(FONT_BOTTOM FONT_RIGHT FONT_H6 "(CAM: %5.2f,%5.2f,%5.2f)", cam->position.x, cam->position.y, cam->position.z));
//
char *cam_info = NULL, *cam_info_fmt = FONT_BOTTOM FONT_RIGHT FONT_H5;
if( choiceV == -1 ) cam_info = va("%s(CAM POS: %5.2f,%5.2f,%5.2f)", cam_info_fmt, cam->position.x, cam->position.y, cam->position.z, cam->fov);
if( choiceV == -2 ) cam_info = va("%s(CAM YAW: %5.2f PITCH: %5.2f)", cam_info_fmt, cam->yaw, cam->pitch);
if( choiceV == -4 ) cam_info = va("%s(CAM FOV: %5.2f)", cam_info_fmt, cam->fov);
if( choiceV == -5 ) cam_info = va("%s(CAM ORTHOGRAPHIC: %d)", cam_info_fmt, cam->orthographic);
if( choiceH == -2 ) cam_info = va("%s(OBJ SNAPPING: %d)", cam_info_fmt, pos_snapping);
if( cam_info ) font_print(cam_info);
}
}

View File

@ -18335,7 +18335,8 @@ AUTORUN {
// ----------------------------------------------------------------------------
// ease
API float ease_nop(float t);
API float ease_zero(float t);
API float ease_one(float t);
API float ease_linear(float t);
API float ease_out_sine(float t);
@ -18389,7 +18390,8 @@ enum EASE_FLAGS {
EASE_OUT = 0,
EASE_INOUT = EASE_IN * 2,
EASE_NOP = EASE_INOUT | (EASE_BOUNCE + 1),
EASE_ZERO = EASE_INOUT | (EASE_BOUNCE + 1),
EASE_ONE,
EASE_LINEAR,
EASE_INOUT_PERLIN,
@ -32815,7 +32817,6 @@ int gladLoadGL( GLADloadfunc load) {
#define BQ_PLATFORM_IMPLEMENTATION // websocket
#define BQ_WEBSOCKET_IMPLEMENTATION // websocket
#define XML_C // xml
#define LIGHTMAPPER_IMPLEMENTATION // lightmapper
#ifdef __APPLE__
#define MA_NO_RUNTIME_LINKING // miniaudio osx
#define _GLFW_COCOA // glfw osx
@ -347878,6 +347879,8 @@ void lt_tick(struct lua_State *L) {
}
#line 0
#define LIGHTMAPPER_IMPLEMENTATION
//#define LM_DEBUG_INTERPOLATION
#line 1 "3rd_lightmapper.h"
/***********************************************************
* A single header file OpenGL lightmapping library *
@ -349659,7 +349662,8 @@ lm_bool lmImageSaveTGAf(const char *filename, const float *image, int w, int h,
return success;
}
#endif // LIGHTMAPPER_IMPLEMENTATION#line 0
#endif // LIGHTMAPPER_IMPLEMENTATION
#line 0
#endif // V4K_3RD
/* game framework.
@ -350498,7 +350502,7 @@ const char *extract_utf32(const char *s, uint32_t *out) {
/**/ if( (s[0] & 0x80) == 0x00 ) return *out = (s[0]), s + 1;
else if( (s[0] & 0xe0) == 0xc0 ) return *out = (s[0] & 31) << 6 | (s[1] & 63), s + 2;
else if( (s[0] & 0xf0) == 0xe0 ) return *out = (s[0] & 15) << 12 | (s[1] & 63) << 6 | (s[2] & 63), s + 3;
else if( (s[0] & 0xf8) == 0xf0 ) return *out = (s[0] & 7) << 18 | (s[1] & 63) << 12 | (s[2] & 63) << 8 | (s[3] & 63), s + 4;
else if( (s[0] & 0xf8) == 0xf0 ) return *out = (s[0] & 7) << 18 | (s[1] & 63) << 12 | (s[2] & 63) << 6 | (s[3] & 63), s + 4;
return *out = 0, s + 0;
}
array(uint32_t) string32( const char *utf8 ) {
@ -359705,7 +359709,8 @@ static const unsigned table_middle_east[] = {
static const unsigned table_emoji[] = {
// 0xE000, 0xEB4C, // Private use (emojis)
0xE000, 0xF8FF, // Private use (emojis+webfonts)
0xE000, 0xF68B, // Private use (emojis+webfonts). U+F68C excluded
0xF68D, 0xF8FF, // Private use (emojis+webfonts)
0xF0001,0xF1CC7,// Private use (icon mdi)
0
};
@ -360053,13 +360058,25 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
unsigned char *bitmap = (unsigned char*)MALLOC(f->height*f->width);
int charCount = *array_back(sorted) - sorted[0] + 1; // 0xEFFFF;
f->begin = sorted[0];
f->cdata = (stbtt_packedchar*)CALLOC(1, sizeof(stbtt_packedchar) * charCount);
f->iter2cp = (unsigned*)MALLOC( sizeof(unsigned) * charCount );
f->cp2iter = (unsigned*)MALLOC( sizeof(unsigned) * charCount );
for( int i = 0; i < charCount; ++i )
f->iter2cp[i] = f->cp2iter[i] = 0xFFFD; // default invalid glyph
// find first char
{
stbtt_fontinfo info = {0};
stbtt_InitFont(&info, ttf_data, stbtt_GetFontOffsetForIndex(ttf_data,0));
for( int i = 0, end = array_count(sorted); i < end; ++i ) {
unsigned glyph = sorted[i];
if(!stbtt_FindGlyphIndex(&info, glyph)) continue;
f->begin = glyph;
break;
}
}
stbtt_pack_context pc;
if( !stbtt_PackBegin(&pc, bitmap, f->width, f->height, 0, 1, NULL) ) {
PANIC("Failed to initialize atlas font");
@ -360072,6 +360089,8 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
while( i < (num-1) && (sorted[i+1]-sorted[i]) == 1 ) end = sorted[++i];
//printf("(%d,%d)", (unsigned)begin, (unsigned)end);
if( begin < f->begin ) continue;
if( stbtt_PackFontRange(&pc, ttf_data, 0, f->font_size, begin, end - begin + 1, (stbtt_packedchar*)f->cdata + begin - f->begin) ) {
for( uint64_t cp = begin; cp <= end; ++cp ) {
// unicode->index runtime lookup
@ -360382,7 +360401,7 @@ vec2 font_draw_ex(const char *text, vec2 offset, const char *col, void (*draw_cm
// convert to vbo data
int cp = ch - f->begin; // f->cp2iter[ch - f->begin];
//if(cp == 0xFFFD) continue;
//if(cp > f->num_glyphs) cp = 0xFFFD;
//if (cp > f->num_glyphs) continue;
*t++ = X;
*t++ = Y;
@ -374693,7 +374712,8 @@ guid guid_create() {
// ----------------------------------------------------------------------------
// ease
float ease_nop(float t) { return 0; }
float ease_zero(float t) { return 0; }
float ease_one(float t) { return 1; }
float ease_linear(float t) { return t; }
float ease_out_sine(float t) { return sinf(t*(C_PI*0.5f)); }
@ -374767,7 +374787,8 @@ float ease(float t01, unsigned mode) {
ease_inout_elastic,
ease_inout_bounce,
ease_nop,
ease_zero,
ease_one,
ease_linear,
ease_inout_perlin,
};
@ -374814,7 +374835,8 @@ const char **ease_enums() {
"ease_inout_elastic",
"ease_inout_bounce",
"ease_nop",
"ease_zero",
"ease_one",
"ease_linear",
"ease_inout_perlin",
@ -374862,7 +374884,8 @@ const char *ease_enum(unsigned mode) {
ENUM(EASE_ELASTIC|EASE_INOUT);
ENUM(EASE_BOUNCE|EASE_INOUT);
ENUM(EASE_NOP);
ENUM(EASE_ZERO);
ENUM(EASE_ONE);
ENUM(EASE_LINEAR);
ENUM(EASE_INOUT_PERLIN);
};*/
@ -379918,7 +379941,7 @@ int ui_tween(const char *label, tween_t *t) {
ui_hue = (hash & 0x3F) / (float)0x3F; ui_hue += !ui_hue;
struct nk_color c = nk_hsva_f(ui_hue, 0.75f, 0.8f, ui_alpha);
nk_fill_rect(canvas, pos, ROUNDING, k->ease == EASE_NOP ? AS_NKCOLOR(0) : c); // AS_NKCOLOR(track_color));
nk_fill_rect(canvas, pos, ROUNDING, k->ease == EASE_ZERO ? AS_NKCOLOR(0) : c); // AS_NKCOLOR(track_color));
}
// horizontal line

View File

@ -53,7 +53,6 @@
#define BQ_PLATFORM_IMPLEMENTATION // websocket
#define BQ_WEBSOCKET_IMPLEMENTATION // websocket
#define XML_C // xml
#define LIGHTMAPPER_IMPLEMENTATION // lightmapper
#ifdef __APPLE__
#define MA_NO_RUNTIME_LINKING // miniaudio osx
#define _GLFW_COCOA // glfw osx
@ -218,6 +217,8 @@ static char *ui_filter = 0;
{{FILE:3rd_lite_sys.h}}
{{FILE:3rd_lite.h}}
#define LIGHTMAPPER_IMPLEMENTATION
//#define LM_DEBUG_INTERPOLATION
{{FILE:3rd_lightmapper.h}}
#endif // V4K_3RD

View File

@ -72,7 +72,7 @@ int ui_tween(const char *label, tween_t *t) {
ui_hue = (hash & 0x3F) / (float)0x3F; ui_hue += !ui_hue;
struct nk_color c = nk_hsva_f(ui_hue, 0.75f, 0.8f, ui_alpha);
nk_fill_rect(canvas, pos, ROUNDING, k->ease == EASE_NOP ? AS_NKCOLOR(0) : c); // AS_NKCOLOR(track_color));
nk_fill_rect(canvas, pos, ROUNDING, k->ease == EASE_ZERO ? AS_NKCOLOR(0) : c); // AS_NKCOLOR(track_color));
}
// horizontal line

View File

@ -1387,7 +1387,8 @@ static const unsigned table_middle_east[] = {
static const unsigned table_emoji[] = {
// 0xE000, 0xEB4C, // Private use (emojis)
0xE000, 0xF8FF, // Private use (emojis+webfonts)
0xE000, 0xF68B, // Private use (emojis+webfonts). U+F68C excluded
0xF68D, 0xF8FF, // Private use (emojis+webfonts)
0xF0001,0xF1CC7,// Private use (icon mdi)
0
};
@ -1735,13 +1736,25 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
unsigned char *bitmap = (unsigned char*)MALLOC(f->height*f->width);
int charCount = *array_back(sorted) - sorted[0] + 1; // 0xEFFFF;
f->begin = sorted[0];
f->cdata = (stbtt_packedchar*)CALLOC(1, sizeof(stbtt_packedchar) * charCount);
f->iter2cp = (unsigned*)MALLOC( sizeof(unsigned) * charCount );
f->cp2iter = (unsigned*)MALLOC( sizeof(unsigned) * charCount );
for( int i = 0; i < charCount; ++i )
f->iter2cp[i] = f->cp2iter[i] = 0xFFFD; // default invalid glyph
// find first char
{
stbtt_fontinfo info = {0};
stbtt_InitFont(&info, ttf_data, stbtt_GetFontOffsetForIndex(ttf_data,0));
for( int i = 0, end = array_count(sorted); i < end; ++i ) {
unsigned glyph = sorted[i];
if(!stbtt_FindGlyphIndex(&info, glyph)) continue;
f->begin = glyph;
break;
}
}
stbtt_pack_context pc;
if( !stbtt_PackBegin(&pc, bitmap, f->width, f->height, 0, 1, NULL) ) {
PANIC("Failed to initialize atlas font");
@ -1754,6 +1767,8 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
while( i < (num-1) && (sorted[i+1]-sorted[i]) == 1 ) end = sorted[++i];
//printf("(%d,%d)", (unsigned)begin, (unsigned)end);
if( begin < f->begin ) continue;
if( stbtt_PackFontRange(&pc, ttf_data, 0, f->font_size, begin, end - begin + 1, (stbtt_packedchar*)f->cdata + begin - f->begin) ) {
for( uint64_t cp = begin; cp <= end; ++cp ) {
// unicode->index runtime lookup
@ -2064,7 +2079,7 @@ vec2 font_draw_ex(const char *text, vec2 offset, const char *col, void (*draw_cm
// convert to vbo data
int cp = ch - f->begin; // f->cp2iter[ch - f->begin];
//if(cp == 0xFFFD) continue;
//if(cp > f->num_glyphs) cp = 0xFFFD;
//if (cp > f->num_glyphs) continue;
*t++ = X;
*t++ = Y;

View File

@ -331,7 +331,7 @@ const char *extract_utf32(const char *s, uint32_t *out) {
/**/ if( (s[0] & 0x80) == 0x00 ) return *out = (s[0]), s + 1;
else if( (s[0] & 0xe0) == 0xc0 ) return *out = (s[0] & 31) << 6 | (s[1] & 63), s + 2;
else if( (s[0] & 0xf0) == 0xe0 ) return *out = (s[0] & 15) << 12 | (s[1] & 63) << 6 | (s[2] & 63), s + 3;
else if( (s[0] & 0xf8) == 0xf0 ) return *out = (s[0] & 7) << 18 | (s[1] & 63) << 12 | (s[2] & 63) << 8 | (s[3] & 63), s + 4;
else if( (s[0] & 0xf8) == 0xf0 ) return *out = (s[0] & 7) << 18 | (s[1] & 63) << 12 | (s[2] & 63) << 6 | (s[3] & 63), s + 4;
return *out = 0, s + 0;
}
array(uint32_t) string32( const char *utf8 ) {

View File

@ -250,7 +250,8 @@ guid guid_create() {
// ----------------------------------------------------------------------------
// ease
float ease_nop(float t) { return 0; }
float ease_zero(float t) { return 0; }
float ease_one(float t) { return 1; }
float ease_linear(float t) { return t; }
float ease_out_sine(float t) { return sinf(t*(C_PI*0.5f)); }
@ -324,7 +325,8 @@ float ease(float t01, unsigned mode) {
ease_inout_elastic,
ease_inout_bounce,
ease_nop,
ease_zero,
ease_one,
ease_linear,
ease_inout_perlin,
};
@ -371,7 +373,8 @@ const char **ease_enums() {
"ease_inout_elastic",
"ease_inout_bounce",
"ease_nop",
"ease_zero",
"ease_one",
"ease_linear",
"ease_inout_perlin",
@ -419,7 +422,8 @@ const char *ease_enum(unsigned mode) {
ENUM(EASE_ELASTIC|EASE_INOUT);
ENUM(EASE_BOUNCE|EASE_INOUT);
ENUM(EASE_NOP);
ENUM(EASE_ZERO);
ENUM(EASE_ONE);
ENUM(EASE_LINEAR);
ENUM(EASE_INOUT_PERLIN);
};*/

View File

@ -45,7 +45,8 @@ AUTORUN {
// ----------------------------------------------------------------------------
// ease
API float ease_nop(float t);
API float ease_zero(float t);
API float ease_one(float t);
API float ease_linear(float t);
API float ease_out_sine(float t);
@ -99,7 +100,8 @@ enum EASE_FLAGS {
EASE_OUT = 0,
EASE_INOUT = EASE_IN * 2,
EASE_NOP = EASE_INOUT | (EASE_BOUNCE + 1),
EASE_ZERO = EASE_INOUT | (EASE_BOUNCE + 1),
EASE_ONE,
EASE_LINEAR,
EASE_INOUT_PERLIN,

View File

@ -13981,7 +13981,6 @@ int gladLoadGL( GLADloadfunc load) {
#define BQ_PLATFORM_IMPLEMENTATION // websocket
#define BQ_WEBSOCKET_IMPLEMENTATION // websocket
#define XML_C // xml
#define LIGHTMAPPER_IMPLEMENTATION // lightmapper
#ifdef __APPLE__
#define MA_NO_RUNTIME_LINKING // miniaudio osx
#define _GLFW_COCOA // glfw osx
@ -329044,6 +329043,8 @@ void lt_tick(struct lua_State *L) {
}
#line 0
#define LIGHTMAPPER_IMPLEMENTATION
//#define LM_DEBUG_INTERPOLATION
#line 1 "3rd_lightmapper.h"
/***********************************************************
* A single header file OpenGL lightmapping library *
@ -330825,6 +330826,7 @@ lm_bool lmImageSaveTGAf(const char *filename, const float *image, int w, int h,
return success;
}
#endif // LIGHTMAPPER_IMPLEMENTATION#line 0
#endif // LIGHTMAPPER_IMPLEMENTATION
#line 0
#endif // V4K_3RD

View File

@ -834,7 +834,7 @@ const char *extract_utf32(const char *s, uint32_t *out) {
/**/ if( (s[0] & 0x80) == 0x00 ) return *out = (s[0]), s + 1;
else if( (s[0] & 0xe0) == 0xc0 ) return *out = (s[0] & 31) << 6 | (s[1] & 63), s + 2;
else if( (s[0] & 0xf0) == 0xe0 ) return *out = (s[0] & 15) << 12 | (s[1] & 63) << 6 | (s[2] & 63), s + 3;
else if( (s[0] & 0xf8) == 0xf0 ) return *out = (s[0] & 7) << 18 | (s[1] & 63) << 12 | (s[2] & 63) << 8 | (s[3] & 63), s + 4;
else if( (s[0] & 0xf8) == 0xf0 ) return *out = (s[0] & 7) << 18 | (s[1] & 63) << 12 | (s[2] & 63) << 6 | (s[3] & 63), s + 4;
return *out = 0, s + 0;
}
array(uint32_t) string32( const char *utf8 ) {
@ -10041,7 +10041,8 @@ static const unsigned table_middle_east[] = {
static const unsigned table_emoji[] = {
// 0xE000, 0xEB4C, // Private use (emojis)
0xE000, 0xF8FF, // Private use (emojis+webfonts)
0xE000, 0xF68B, // Private use (emojis+webfonts). U+F68C excluded
0xF68D, 0xF8FF, // Private use (emojis+webfonts)
0xF0001,0xF1CC7,// Private use (icon mdi)
0
};
@ -10389,13 +10390,25 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
unsigned char *bitmap = (unsigned char*)MALLOC(f->height*f->width);
int charCount = *array_back(sorted) - sorted[0] + 1; // 0xEFFFF;
f->begin = sorted[0];
f->cdata = (stbtt_packedchar*)CALLOC(1, sizeof(stbtt_packedchar) * charCount);
f->iter2cp = (unsigned*)MALLOC( sizeof(unsigned) * charCount );
f->cp2iter = (unsigned*)MALLOC( sizeof(unsigned) * charCount );
for( int i = 0; i < charCount; ++i )
f->iter2cp[i] = f->cp2iter[i] = 0xFFFD; // default invalid glyph
// find first char
{
stbtt_fontinfo info = {0};
stbtt_InitFont(&info, ttf_data, stbtt_GetFontOffsetForIndex(ttf_data,0));
for( int i = 0, end = array_count(sorted); i < end; ++i ) {
unsigned glyph = sorted[i];
if(!stbtt_FindGlyphIndex(&info, glyph)) continue;
f->begin = glyph;
break;
}
}
stbtt_pack_context pc;
if( !stbtt_PackBegin(&pc, bitmap, f->width, f->height, 0, 1, NULL) ) {
PANIC("Failed to initialize atlas font");
@ -10408,6 +10421,8 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
while( i < (num-1) && (sorted[i+1]-sorted[i]) == 1 ) end = sorted[++i];
//printf("(%d,%d)", (unsigned)begin, (unsigned)end);
if( begin < f->begin ) continue;
if( stbtt_PackFontRange(&pc, ttf_data, 0, f->font_size, begin, end - begin + 1, (stbtt_packedchar*)f->cdata + begin - f->begin) ) {
for( uint64_t cp = begin; cp <= end; ++cp ) {
// unicode->index runtime lookup
@ -10718,7 +10733,7 @@ vec2 font_draw_ex(const char *text, vec2 offset, const char *col, void (*draw_cm
// convert to vbo data
int cp = ch - f->begin; // f->cp2iter[ch - f->begin];
//if(cp == 0xFFFD) continue;
//if(cp > f->num_glyphs) cp = 0xFFFD;
//if (cp > f->num_glyphs) continue;
*t++ = X;
*t++ = Y;
@ -25029,7 +25044,8 @@ guid guid_create() {
// ----------------------------------------------------------------------------
// ease
float ease_nop(float t) { return 0; }
float ease_zero(float t) { return 0; }
float ease_one(float t) { return 1; }
float ease_linear(float t) { return t; }
float ease_out_sine(float t) { return sinf(t*(C_PI*0.5f)); }
@ -25103,7 +25119,8 @@ float ease(float t01, unsigned mode) {
ease_inout_elastic,
ease_inout_bounce,
ease_nop,
ease_zero,
ease_one,
ease_linear,
ease_inout_perlin,
};
@ -25150,7 +25167,8 @@ const char **ease_enums() {
"ease_inout_elastic",
"ease_inout_bounce",
"ease_nop",
"ease_zero",
"ease_one",
"ease_linear",
"ease_inout_perlin",
@ -25198,7 +25216,8 @@ const char *ease_enum(unsigned mode) {
ENUM(EASE_ELASTIC|EASE_INOUT);
ENUM(EASE_BOUNCE|EASE_INOUT);
ENUM(EASE_NOP);
ENUM(EASE_ZERO);
ENUM(EASE_ONE);
ENUM(EASE_LINEAR);
ENUM(EASE_INOUT_PERLIN);
};*/
@ -30254,7 +30273,7 @@ int ui_tween(const char *label, tween_t *t) {
ui_hue = (hash & 0x3F) / (float)0x3F; ui_hue += !ui_hue;
struct nk_color c = nk_hsva_f(ui_hue, 0.75f, 0.8f, ui_alpha);
nk_fill_rect(canvas, pos, ROUNDING, k->ease == EASE_NOP ? AS_NKCOLOR(0) : c); // AS_NKCOLOR(track_color));
nk_fill_rect(canvas, pos, ROUNDING, k->ease == EASE_ZERO ? AS_NKCOLOR(0) : c); // AS_NKCOLOR(track_color));
}
// horizontal line

View File

@ -4402,7 +4402,8 @@ AUTORUN {
// ----------------------------------------------------------------------------
// ease
API float ease_nop(float t);
API float ease_zero(float t);
API float ease_one(float t);
API float ease_linear(float t);
API float ease_out_sine(float t);
@ -4456,7 +4457,8 @@ enum EASE_FLAGS {
EASE_OUT = 0,
EASE_INOUT = EASE_IN * 2,
EASE_NOP = EASE_INOUT | (EASE_BOUNCE + 1),
EASE_ZERO = EASE_INOUT | (EASE_BOUNCE + 1),
EASE_ONE,
EASE_LINEAR,
EASE_INOUT_PERLIN,