mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-05 14:42:42 -07:00
remove using usage from sokol_demo.odin
This commit is contained in:
@@ -168,13 +168,6 @@ draw_text_string_pos_norm :: proc( content : string, font : Font_ID, size : f32,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw text using a string and extent-based screen coordinates
|
|
||||||
draw_text_string_pos_extent :: proc( content : string, id : Font_ID, size : f32, pos : Vec2, color := COLOR_WHITE ) {
|
|
||||||
render_pos := pos + demo_ctx.screen_size * 0.5
|
|
||||||
normalized_pos := render_pos * (1.0 / demo_ctx.screen_size)
|
|
||||||
draw_text_string_pos_norm( content, id, size, normalized_pos, color )
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adapt the draw_text_string_pos_extent_zoomed procedure
|
// Adapt the draw_text_string_pos_extent_zoomed procedure
|
||||||
draw_text_zoomed_norm :: proc(content : string, font : Font_ID, size : f32, pos : Vec2, zoom : f32, color := COLOR_WHITE)
|
draw_text_zoomed_norm :: proc(content : string, font : Font_ID, size : f32, pos : Vec2, zoom : f32, color := COLOR_WHITE)
|
||||||
{
|
{
|
||||||
@@ -284,26 +277,25 @@ init :: proc "c" ()
|
|||||||
path_noto_sans_jp_reg := strings.concatenate({ PATH_FONTS, "NotoSansJP-Regular.otf" })
|
path_noto_sans_jp_reg := strings.concatenate({ PATH_FONTS, "NotoSansJP-Regular.otf" })
|
||||||
path_firacode := strings.concatenate({ PATH_FONTS, "FiraCode-Regular.ttf" })
|
path_firacode := strings.concatenate({ PATH_FONTS, "FiraCode-Regular.ttf" })
|
||||||
|
|
||||||
using demo_ctx
|
demo_ctx.font_logo = font_load(path_sawarabi_mincho, 330.0, "SawarabiMincho", 6 )
|
||||||
font_logo = font_load(path_sawarabi_mincho, 330.0, "SawarabiMincho", 6 )
|
demo_ctx.font_title = font_load(path_open_sans, 92.0, "OpenSans", 12 )
|
||||||
font_title = font_load(path_open_sans, 92.0, "OpenSans", 12 )
|
demo_ctx.font_print = font_load(path_noto_sans_jp, 19.0, "NotoSansJP")
|
||||||
font_print = font_load(path_noto_sans_jp, 19.0, "NotoSansJP")
|
demo_ctx.font_mono = font_load(path_ubuntu_mono, 21.0, "UbuntuMono")
|
||||||
font_mono = font_load(path_ubuntu_mono, 21.0, "UbuntuMono")
|
demo_ctx.font_small = font_load(path_roboto, 10.0, "Roboto")
|
||||||
font_small = font_load(path_roboto, 10.0, "Roboto")
|
demo_ctx.font_demo_sans = font_load(path_open_sans, 18.0, "OpenSans")
|
||||||
font_demo_sans = font_load(path_open_sans, 18.0, "OpenSans")
|
demo_ctx.font_demo_serif = font_load(path_bitter, 18.0, "Bitter")
|
||||||
font_demo_serif = font_load(path_bitter, 18.0, "Bitter")
|
demo_ctx.font_demo_script = font_load(path_dancing_script, 22.0, "DancingScript")
|
||||||
font_demo_script = font_load(path_dancing_script, 22.0, "DancingScript")
|
demo_ctx.font_demo_mono = font_load(path_nova_mono, 18.0, "NovaMono")
|
||||||
font_demo_mono = font_load(path_nova_mono, 18.0, "NovaMono")
|
demo_ctx.font_demo_chinese = font_load(path_noto_serif_sc, 24.0, "NotoSerifSC")
|
||||||
font_demo_chinese = font_load(path_noto_serif_sc, 24.0, "NotoSerifSC")
|
demo_ctx.font_demo_japanese = font_load(path_sawarabi_mincho, 24.0, "SawarabiMincho")
|
||||||
font_demo_japanese = font_load(path_sawarabi_mincho, 24.0, "SawarabiMincho")
|
demo_ctx.font_demo_korean = font_load(path_nanum_pen_script, 36.0, "NanumPenScript")
|
||||||
font_demo_korean = font_load(path_nanum_pen_script, 36.0, "NanumPenScript")
|
demo_ctx.font_demo_thai = font_load(path_krub, 24.0, "Krub")
|
||||||
font_demo_thai = font_load(path_krub, 24.0, "Krub")
|
demo_ctx.font_demo_arabic = font_load(path_tajawal, 24.0, "Tajawal")
|
||||||
font_demo_arabic = font_load(path_tajawal, 24.0, "Tajawal")
|
demo_ctx.font_demo_hebrew = font_load(path_david_libre, 22.0, "DavidLibre")
|
||||||
font_demo_hebrew = font_load(path_david_libre, 22.0, "DavidLibre")
|
demo_ctx.font_demo_raincode = font_load(path_noto_sans_jp_reg, 20.0, "NotoSansJPRegular")
|
||||||
font_demo_raincode = font_load(path_noto_sans_jp_reg, 20.0, "NotoSansJPRegular")
|
demo_ctx.font_demo_grid2 = font_load(path_noto_serif_sc, 54.0, "NotoSerifSC")
|
||||||
font_demo_grid2 = font_load(path_noto_serif_sc, 54.0, "NotoSerifSC")
|
demo_ctx.font_demo_grid3 = font_load(path_bitter, 44.0, "Bitter")
|
||||||
font_demo_grid3 = font_load(path_bitter, 44.0, "Bitter")
|
demo_ctx.font_firacode = font_load(path_firacode, 16.0, "FiraCode", 12 )
|
||||||
font_firacode = font_load(path_firacode, 16.0, "FiraCode", 12 )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event :: proc "c" (sokol_event : ^app.Event)
|
event :: proc "c" (sokol_event : ^app.Event)
|
||||||
@@ -328,8 +320,6 @@ frame :: proc "c" ()
|
|||||||
// ve.configure_snap( & demo_ctx.ve_ctx, u32(demo_ctx.screen_size.x), u32(demo_ctx.screen_size.y) )
|
// ve.configure_snap( & demo_ctx.ve_ctx, u32(demo_ctx.screen_size.x), u32(demo_ctx.screen_size.y) )
|
||||||
// ve.set_colour( & demo_ctx.ve_ctx, ve.Colour { 1.0, 1.0, 1.0, 1.0 })
|
// ve.set_colour( & demo_ctx.ve_ctx, ve.Colour { 1.0, 1.0, 1.0, 1.0 })
|
||||||
|
|
||||||
using demo_ctx
|
|
||||||
|
|
||||||
// Smooth scrolling implementation
|
// Smooth scrolling implementation
|
||||||
@static demo_autoscroll := false
|
@static demo_autoscroll := false
|
||||||
@static current_scroll : f32 = 0.0
|
@static current_scroll : f32 = 0.0
|
||||||
@@ -340,7 +330,7 @@ frame :: proc "c" ()
|
|||||||
|
|
||||||
frame_duration := cast(f32) app.frame_duration()
|
frame_duration := cast(f32) app.frame_duration()
|
||||||
|
|
||||||
scroll_velocity += mouse_scroll.y * 0.05
|
scroll_velocity += demo_ctx.mouse_scroll.y * 0.05
|
||||||
mouse_down_pos = -1.0
|
mouse_down_pos = -1.0
|
||||||
substep_dt := frame_duration / 4.0
|
substep_dt := frame_duration / 4.0
|
||||||
for _ in 0 ..< 4 {
|
for _ in 0 ..< 4 {
|
||||||
@@ -350,14 +340,14 @@ frame :: proc "c" ()
|
|||||||
if demo_autoscroll {
|
if demo_autoscroll {
|
||||||
current_scroll += 0.05 * frame_duration
|
current_scroll += 0.05 * frame_duration
|
||||||
}
|
}
|
||||||
mouse_scroll = {} // Reset mouse scroll
|
demo_ctx.mouse_scroll = {} // Reset mouse scroll
|
||||||
|
|
||||||
// Clamp scroll value if needed
|
// Clamp scroll value if needed
|
||||||
current_scroll = clamp(current_scroll, 0, 6.1) // Adjust max value as needed
|
current_scroll = clamp(current_scroll, 0, 6.1) // Adjust max value as needed
|
||||||
|
|
||||||
// Frametime display
|
// Frametime display
|
||||||
frametime_text := fmt.tprintf("Frametime %v", frame_duration)
|
frametime_text := fmt.tprintf("Frametime %v", frame_duration)
|
||||||
draw_text_string_pos_norm(frametime_text, font_title, 0, {0.0, 0.0}, COLOR_WHITE)
|
draw_text_string_pos_norm(frametime_text, demo_ctx.font_title, 0, {0.0, 0.0}, COLOR_WHITE)
|
||||||
|
|
||||||
if current_scroll < 1.5 {
|
if current_scroll < 1.5 {
|
||||||
intro := `Ça va! Everything here is rendered using VE Font Cache, a single header-only library designed for game engines.
|
intro := `Ça va! Everything here is rendered using VE Font Cache, a single header-only library designed for game engines.
|
||||||
@@ -372,9 +362,9 @@ It aims to:
|
|||||||
• Support cached text shaping with HarfBuzz with simple Latin-style fallback.
|
• Support cached text shaping with HarfBuzz with simple Latin-style fallback.
|
||||||
• Load and unload fonts at any time.`
|
• Load and unload fonts at any time.`
|
||||||
|
|
||||||
draw_text_string_pos_norm("ゑ", font_logo, 330, {0.4, current_scroll}, COLOR_WHITE)
|
draw_text_string_pos_norm("ゑ", demo_ctx.font_logo, 330, { 0.4, current_scroll }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("VEFontCache Demo", font_title, 92, {0.2, current_scroll - 0.1}, COLOR_WHITE)
|
draw_text_string_pos_norm("VEFontCache Demo", demo_ctx.font_title, 92, { 0.2, current_scroll - 0.1 }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm(intro, font_print, 19, {0.2, current_scroll - 0.14}, COLOR_WHITE)
|
draw_text_string_pos_norm(intro, demo_ctx.font_print, 19, { 0.2, current_scroll - 0.14 }, COLOR_WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
section_start : f32 = 0.42
|
section_start : f32 = 0.42
|
||||||
@@ -417,10 +407,10 @@ Glyphs are first rendered to an intermediate 2k x 512px R8 texture. This allows
|
|||||||
4 x 4 = 16x supersampling, and 8 Region C glyphs similarly. A simple 16-tap box downsample shader is then used to blit from this
|
4 x 4 = 16x supersampling, and 8 Region C glyphs similarly. A simple 16-tap box downsample shader is then used to blit from this
|
||||||
intermediate texture to the final atlas location.`
|
intermediate texture to the final atlas location.`
|
||||||
|
|
||||||
draw_text_string_pos_norm("How it works", font_title, 92, {0.2, current_scroll - (section_start + 0.06)}, COLOR_WHITE)
|
draw_text_string_pos_norm("How it works", demo_ctx.font_title, 92, { 0.2, current_scroll - (section_start + 0.06) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm(how_it_works, font_print, 19, {0.2, current_scroll - (section_start + 0.1)}, COLOR_WHITE)
|
draw_text_string_pos_norm(how_it_works, demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.1) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm(caching_strategy, demo_ctx.font_mono, 21, {0.28, current_scroll - (section_start + 0.32)}, COLOR_WHITE)
|
draw_text_string_pos_norm(caching_strategy, demo_ctx.font_mono, 21, { 0.28, current_scroll - (section_start + 0.32) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm(how_it_works2, font_print, 19, {0.2, current_scroll - (section_start + 0.82)}, COLOR_WHITE)
|
draw_text_string_pos_norm(how_it_works2, demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.82) }, COLOR_WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Showcase section
|
// Showcase section
|
||||||
@@ -431,49 +421,49 @@ intermediate texture to the final atlas location.`
|
|||||||
incididunt ut labore et dolore magna aliqua. Est ullamcorper eget nulla facilisi
|
incididunt ut labore et dolore magna aliqua. Est ullamcorper eget nulla facilisi
|
||||||
etiam dignissim diam quis enim. Convallis convallis tellus id interdum.`
|
etiam dignissim diam quis enim. Convallis convallis tellus id interdum.`
|
||||||
|
|
||||||
draw_text_string_pos_norm("Showcase", font_title, 92, {0.2, current_scroll - (section_start + 0.2)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Showcase", demo_ctx.font_title, 92, { 0.2, current_scroll - (section_start + 0.2) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("This is a showcase demonstrating different hb_font categories and languages.", font_print, 19, {0.2, current_scroll - (section_start + 0.24)}, COLOR_WHITE)
|
draw_text_string_pos_norm("This is a showcase demonstrating different hb_font categories and languages.", demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.24) }, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Sans serif", font_print, 19, {0.2, current_scroll - (section_start + 0.28)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Sans serif", demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.28) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm(font_family_test, font_demo_sans, 18, {0.3, current_scroll - (section_start + 0.28)}, COLOR_WHITE)
|
draw_text_string_pos_norm(font_family_test, demo_ctx.font_demo_sans, 18, { 0.3, current_scroll - (section_start + 0.28) }, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Serif", font_print, 19, {0.2, current_scroll - (section_start + 0.36)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Serif", demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.36) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm(font_family_test, font_demo_serif, 18, {0.3, current_scroll - (section_start + 0.36)}, COLOR_WHITE)
|
draw_text_string_pos_norm(font_family_test, demo_ctx.font_demo_serif, 18, { 0.3, current_scroll - (section_start + 0.36) }, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Script", font_print, 19, {0.2, current_scroll - (section_start + 0.44)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Script", demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.44) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm(font_family_test, font_demo_script, 22, {0.3, current_scroll - (section_start + 0.44)}, COLOR_WHITE)
|
draw_text_string_pos_norm(font_family_test, demo_ctx.font_demo_script, 22, { 0.3, current_scroll - (section_start + 0.44) }, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Monospace", font_print, 19, {0.2, current_scroll - (section_start + 0.52)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Monospace", demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.52) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm(font_family_test, font_demo_mono, 18, {0.3, current_scroll - (section_start + 0.52)}, COLOR_WHITE)
|
draw_text_string_pos_norm(font_family_test, demo_ctx.font_demo_mono, 18, { 0.3, current_scroll - (section_start + 0.52) }, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Small", font_print, 19, {0.2, current_scroll - (section_start + 0.60)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Small", demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.60) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm(font_family_test, font_small, 10, {0.3, current_scroll - (section_start + 0.60)}, COLOR_WHITE)
|
draw_text_string_pos_norm(font_family_test, demo_ctx.font_small, 10, { 0.3, current_scroll - (section_start + 0.60) }, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Greek", font_print, 19, {0.2, current_scroll - (section_start + 0.72)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Greek", demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.72) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("Ήταν απλώς θέμα χρόνου.", font_demo_sans, 18, {0.3, current_scroll - (section_start + 0.72)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Ήταν απλώς θέμα χρόνου.", demo_ctx.font_demo_sans, 18, { 0.3, current_scroll - (section_start + 0.72) }, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Vietnamese", font_print, 19, {0.2, current_scroll - (section_start + 0.76)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Vietnamese", demo_ctx.font_print, 19, { 0.2, current_scroll - (section_start + 0.76) }, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("Bầu trời trong xanh thăm thẳm, không một gợn mây.", font_demo_sans, 18, {0.3, current_scroll - (section_start + 0.76)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Bầu trời trong xanh thăm thẳm, không một gợn mây.", demo_ctx.font_demo_sans, 18, { 0.3, current_scroll - (section_start + 0.76) }, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Thai", font_print, 19, {0.2, current_scroll - (section_start + 0.80)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Thai", demo_ctx.font_print, 19, {0.2, current_scroll - (section_start + 0.80)}, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("การเดินทางขากลับคงจะเหงา", font_demo_thai, 24, {0.3, current_scroll - (section_start + 0.80)}, COLOR_WHITE)
|
draw_text_string_pos_norm("การเดินทางขากลับคงจะเหงา", demo_ctx.font_demo_thai, 24, {0.3, current_scroll - (section_start + 0.80)}, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Chinese", font_print, 19, {0.2, current_scroll - (section_start + 0.84)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Chinese", demo_ctx.font_print, 19, {0.2, current_scroll - (section_start + 0.84)}, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("床前明月光 疑是地上霜 举头望明月 低头思故乡", font_demo_chinese, 24, {0.3, current_scroll - (section_start + 0.84)}, COLOR_WHITE)
|
draw_text_string_pos_norm("床前明月光 疑是地上霜 举头望明月 低头思故乡", demo_ctx.font_demo_chinese, 24, {0.3, current_scroll - (section_start + 0.84)}, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Japanese", font_print, 19, {0.2, current_scroll - (section_start + 0.88)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Japanese", demo_ctx.font_print, 19, {0.2, current_scroll - (section_start + 0.88)}, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("ぎょしょうとナレズシの研究 モンスーン・アジアの食事文化", font_demo_japanese, 24, {0.3, current_scroll - (section_start + 0.88)}, COLOR_WHITE)
|
draw_text_string_pos_norm("ぎょしょうとナレズシの研究 モンスーン・アジアの食事文化", demo_ctx.font_demo_japanese, 24, {0.3, current_scroll - (section_start + 0.88)}, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Korean", font_print, 19, {0.2, current_scroll - (section_start + 0.92)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Korean", demo_ctx.font_print, 19, {0.2, current_scroll - (section_start + 0.92)}, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("그들의 장비와 기구는 모두 살아 있다.", font_demo_korean, 36, {0.3, current_scroll - (section_start + 0.92)}, COLOR_WHITE)
|
draw_text_string_pos_norm("그들의 장비와 기구는 모두 살아 있다.", demo_ctx.font_demo_korean, 36, {0.3, current_scroll - (section_start + 0.92)}, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Needs harfbuzz to work:", font_print, 14, {0.2, current_scroll - (section_start + 0.96)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Needs harfbuzz to work:", demo_ctx.font_print, 14, {0.2, current_scroll - (section_start + 0.96)}, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Arabic", font_print, 19, {0.2, current_scroll - (section_start + 1.00)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Arabic", demo_ctx.font_print, 19, {0.2, current_scroll - (section_start + 1.00)}, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("حب السماء لا تمطر غير الأحلام.", font_demo_arabic, 24, {0.3, current_scroll - (section_start + 1.00)}, COLOR_WHITE)
|
draw_text_string_pos_norm("حب السماء لا تمطر غير الأحلام.", demo_ctx.font_demo_arabic, 24, {0.3, current_scroll - (section_start + 1.00)}, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Hebrew", font_print, 19, {0.2, current_scroll - (section_start + 1.04)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Hebrew", demo_ctx.font_print, 19, {0.2, current_scroll - (section_start + 1.04)}, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("אז הגיע הלילה של כוכב השביט הראשון.", font_demo_hebrew, 22, {0.3, current_scroll - (section_start + 1.04)}, COLOR_WHITE)
|
draw_text_string_pos_norm("אז הגיע הלילה של כוכב השביט הראשון.", demo_ctx.font_demo_hebrew, 22, {0.3, current_scroll - (section_start + 1.04)}, COLOR_WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zoom Test
|
// Zoom Test
|
||||||
@@ -511,21 +501,21 @@ etiam dignissim diam quis enim. Convallis convallis tellus id interdum.`
|
|||||||
zoom_info_y := current_scroll - (section_start + 0.10)
|
zoom_info_y := current_scroll - (section_start + 0.10)
|
||||||
zoomed_text_y := current_scroll - (section_start + 0.30) + math.sin(zoom_time) * 0.02
|
zoomed_text_y := current_scroll - (section_start + 0.30) + math.sin(zoom_time) * 0.02
|
||||||
|
|
||||||
draw_text_string_pos_norm("Zoom Test", font_title, 92, {0.2, title_y}, COLOR_WHITE)
|
draw_text_string_pos_norm("Zoom Test", demo_ctx.font_title, 92, {0.2, title_y}, COLOR_WHITE)
|
||||||
|
|
||||||
zoomed_text_base_size : f32 = 12.0
|
zoomed_text_base_size : f32 = 12.0
|
||||||
zoom_adjust_size := zoomed_text_base_size * current_zoom
|
zoom_adjust_size := zoomed_text_base_size * current_zoom
|
||||||
// ve_id, resolved_size := font_resolve_draw_id( font_firacode, zoom_adjust_size * OVER_SAMPLE_ZOOM )
|
// ve_id, resolved_size := font_resolve_draw_id( font_firacode, zoom_adjust_size * OVER_SAMPLE_ZOOM )
|
||||||
resolved_size := zoom_adjust_size
|
resolved_size := zoom_adjust_size
|
||||||
current_zoom_text := fmt.tprintf("Current Zoom : %.2f x\nCurrent Resolved Size: %v px", current_zoom, resolved_size )
|
current_zoom_text := fmt.tprintf("Current Zoom : %.2f x\nCurrent Resolved Size: %v px", current_zoom, resolved_size )
|
||||||
draw_text_string_pos_norm(current_zoom_text, font_firacode, 19, {0.2, zoom_info_y}, COLOR_WHITE)
|
draw_text_string_pos_norm(current_zoom_text, demo_ctx.font_firacode, 19, {0.2, zoom_info_y}, COLOR_WHITE)
|
||||||
|
|
||||||
// ve.configure_snap( & demo_ctx.ve_ctx, u32(0), u32(0) )
|
// ve.configure_snap( & demo_ctx.ve_ctx, u32(0), u32(0) )
|
||||||
|
|
||||||
size := measure_text_size( zoom_text, font_firacode, zoomed_text_base_size, 0 ) * current_zoom
|
size := measure_text_size( zoom_text, demo_ctx.font_firacode, zoomed_text_base_size, 0 ) * current_zoom
|
||||||
x_offset := (size.x / demo_ctx.screen_size.x) * 0.5
|
x_offset := (size.x / demo_ctx.screen_size.x) * 0.5
|
||||||
zoomed_text_pos := Vec2 { 0.5 - x_offset, zoomed_text_y }
|
zoomed_text_pos := Vec2 { 0.5 - x_offset, zoomed_text_y }
|
||||||
draw_text_zoomed_norm(zoom_text, font_firacode, zoomed_text_base_size, zoomed_text_pos, current_zoom, COLOR_WHITE)
|
draw_text_zoomed_norm(zoom_text, demo_ctx.font_firacode, zoomed_text_base_size, zoomed_text_pos, current_zoom, COLOR_WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raincode Demo
|
// Raincode Demo
|
||||||
@@ -577,7 +567,7 @@ etiam dignissim diam quis enim. Convallis convallis tellus id interdum.`
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw grid
|
// Draw grid
|
||||||
draw_text_string_pos_norm("Raincode demo", font_title, 92, { 0.2, current_scroll - (section_start + 0.2) }, COLOR_WHITE)
|
draw_text_string_pos_norm("Raincode demo", demo_ctx.font_title, 92, { 0.2, current_scroll - (section_start + 0.2) }, COLOR_WHITE)
|
||||||
for y in 0 ..< GRID_H do for x in 0 ..< GRID_W
|
for y in 0 ..< GRID_H do for x in 0 ..< GRID_W
|
||||||
{
|
{
|
||||||
pos_x := 0.2 + f32(x) * 0.007
|
pos_x := 0.2 + f32(x) * 0.007
|
||||||
@@ -594,7 +584,7 @@ etiam dignissim diam quis enim. Convallis convallis tellus id interdum.`
|
|||||||
if code_colour.a == 0 do continue
|
if code_colour.a == 0 do continue
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_text_string_pos_norm(codes[grid[y * GRID_W + x]], font_demo_raincode, 20, {pos_x, pos_y}, code_colour)
|
draw_text_string_pos_norm(codes[grid[y * GRID_W + x]], demo_ctx.font_demo_raincode, 20, {pos_x, pos_y}, code_colour)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ve.set_colour(&ve_ctx, {1.0, 1.0, 1.0, 1.0})
|
// ve.set_colour(&ve_ctx, {1.0, 1.0, 1.0, 1.0})
|
||||||
@@ -664,28 +654,28 @@ etiam dignissim diam quis enim. Convallis convallis tellus id interdum.`
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw grid
|
// Draw grid
|
||||||
draw_text_string_pos_norm("Cache pressure test", font_title, 92, {0.2, current_scroll - (section_start + 0.2)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Cache pressure test", demo_ctx.font_title, 92, {0.2, current_scroll - (section_start + 0.2)}, COLOR_WHITE)
|
||||||
for y in 0..< GRID_H do for x in 0 ..< GRID_W
|
for y in 0..< GRID_H do for x in 0 ..< GRID_W
|
||||||
{
|
{
|
||||||
posx := 0.2 + f32(x) * 0.02
|
posx := 0.2 + f32(x) * 0.02
|
||||||
posy := current_scroll - (section_start + 0.24 + f32(y) * 0.025)
|
posy := current_scroll - (section_start + 0.24 + f32(y) * 0.025)
|
||||||
c := [5]u8{}
|
c := [5]u8{}
|
||||||
codepoint_to_utf8(c[:], grid[ y * GRID_W + x ])
|
codepoint_to_utf8(c[:], grid[ y * GRID_W + x ])
|
||||||
draw_text_string_pos_norm(string( c[:] ), font_demo_chinese, 24, {posx, posy}, COLOR_WHITE)
|
draw_text_string_pos_norm(string( c[:] ), demo_ctx.font_demo_chinese, 24, {posx, posy}, COLOR_WHITE)
|
||||||
}
|
}
|
||||||
for y in 0 ..< GRID2_H do for x in 0 ..< GRID2_W {
|
for y in 0 ..< GRID2_H do for x in 0 ..< GRID2_W {
|
||||||
posx := 0.2 + f32(x) * 0.03
|
posx := 0.2 + f32(x) * 0.03
|
||||||
posy := current_scroll - (section_start + 0.66 + f32(y) * 0.052)
|
posy := current_scroll - (section_start + 0.66 + f32(y) * 0.052)
|
||||||
c := [5]u8{}
|
c := [5]u8{}
|
||||||
codepoint_to_utf8(c[:], grid2[ y * GRID2_W + x ])
|
codepoint_to_utf8(c[:], grid2[ y * GRID2_W + x ])
|
||||||
draw_text_string_pos_norm(string( c[:] ), font_demo_grid2, 54, {posx, posy}, COLOR_WHITE)
|
draw_text_string_pos_norm(string( c[:] ), demo_ctx.font_demo_grid2, 54, {posx, posy}, COLOR_WHITE)
|
||||||
}
|
}
|
||||||
for y in 0 ..< GRID3_H do for x in 0 ..< GRID3_W {
|
for y in 0 ..< GRID3_H do for x in 0 ..< GRID3_W {
|
||||||
posx := 0.45 + f32(x) * 0.02
|
posx := 0.45 + f32(x) * 0.02
|
||||||
posy := current_scroll - (section_start + 0.64 + f32(y) * 0.034)
|
posy := current_scroll - (section_start + 0.64 + f32(y) * 0.034)
|
||||||
c := [5]u8{}
|
c := [5]u8{}
|
||||||
codepoint_to_utf8( c[:], grid3[ y * GRID3_W + x ])
|
codepoint_to_utf8( c[:], grid3[ y * GRID3_W + x ])
|
||||||
draw_text_string_pos_norm(string( c[:] ), font_demo_grid3, 44, {posx, posy}, COLOR_WHITE)
|
draw_text_string_pos_norm(string( c[:] ), demo_ctx.font_demo_grid3, 44, {posx, posy}, COLOR_WHITE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user