Use reviewed WebP packages and render Telegram as a vector

This commit is contained in:
waozi committed 2026-11-02 11:19:27 -03:00
1 parent e18a03a483
commit 00aa79b87f
33 files changed
+219 -87

No files matched your search

+3 -3
View File
@@ -210,7 +210,7 @@ WIN64_RESOURCE := $(BUILD_OBJ_DIR)/windows/$(WIN64_ARCH)/$(APP_NAME).res
RAYLIB_SOURCES := $(if $(wildcard $(RAYLIB_DIR)),$(shell find $(RAYLIB_DIR) -type f \( -name '*.c' -o -name '*.h' \)))
KRYON_ICON_DIR := icons
KRYON_ICON_FILES := $(shell find $(KRYON_DIR)/$(KRYON_ICON_DIR) -path '*/review/*' -prune -o -type f \( -name '*.png' -o -name '*.json' \) -print 2>/dev/null | LC_ALL=C sort)
KRYON_ICON_FILES := $(shell find $(KRYON_DIR)/$(KRYON_ICON_DIR) -path '*/review/*' -prune -o -type f \( -name '*.webp' -o -name '*.png' -o -name '*.json' \) -print 2>/dev/null | LC_ALL=C sort)
KRYON_GENERATED_INCLUDE_DIR := $(BUILD_OBJ_DIR)/kryon/generated/include
KRYON_GENERATED_SRC_DIR := $(BUILD_OBJ_DIR)/kryon/generated/src
KRYON_UI_ZI := $(addprefix $(KRYON_DIR)/src/ui/,$(shell cat $(KRYON_DIR)/src/ui/modules.txt))
@@ -370,7 +370,7 @@ LOCALE_FILES := $(wildcard locales/*.txt)
# The practice media is the practices package, packaged under
# assets/practices/ (scripts/practice_media.py).
PRACTICE_MEDIA := build/packages/practices
IMAGE_FILES := assets/app/icon.webp assets/easteregg/art.webp assets/easteregg/waozi.png $(PRACTICE_MEDIA)/whm/1.png $(PRACTICE_MEDIA)/whm/2.png $(PRACTICE_MEDIA)/meditation/1.png assets/pet/egg1.png $(wildcard $(PRACTICE_MEDIA)/*/banner*.png) $(wildcard $(PRACTICE_MEDIA)/sunsalutation/characters/*/*.png) $(wildcard $(PRACTICE_MEDIA)/taichi/*.png $(PRACTICE_MEDIA)/taichi/*/*.png) $(PRACTICE_MEDIA)/taichi/course.tch
IMAGE_FILES := assets/app/icon.webp assets/easteregg/art.webp assets/easteregg/waozi.png $(PRACTICE_MEDIA)/whm/1.webp $(PRACTICE_MEDIA)/whm/2.webp $(PRACTICE_MEDIA)/meditation/1.webp assets/pet/egg1.png $(wildcard $(PRACTICE_MEDIA)/*/banner*.webp) $(wildcard $(PRACTICE_MEDIA)/sunsalutation/characters/*/*.png) $(wildcard $(PRACTICE_MEDIA)/taichi/*.png $(PRACTICE_MEDIA)/taichi/*/*.png) $(PRACTICE_MEDIA)/taichi/course.tch
SOUND_FILES := $(wildcard assets/sounds/*.ogg)
FONT_SUBSET_DIR := assets/fonts/subset
FONT_SUBSET_CORPUS := locales assets/fonts/input_common.txt assets/fonts/ui_symbols.txt $(PRACTICE_MEDIA)/astral_projection/text $(PRACTICE_MEDIA)/workout/text
@@ -386,7 +386,7 @@ STYLE_FILES := $(wildcard $(KSS_DIR)/styles/*.kss) \
$(wildcard themes/catalog_*.kss)
IMAGE_FILES += assets/app/icon-sky-cradle.webp assets/app/icon-ink-and-air.webp
IMAGE_FILES += assets/social/telegram.svg $(wildcard assets/social/*.png assets/social/*.webp)
IMAGE_FILES += $(KRYON_DIR)/icons/ui.png $(KRYON_DIR)/icons/pfp.png
IMAGE_FILES += $(KRYON_DIR)/icons/ui.webp $(KRYON_DIR)/icons/pfp.webp
APP_BUNDLES := $(addprefix $(BUILD_DIR)/apps/,lists.zx habits.zx practices.zx diary.zx lumi.zx leaderboard.zx)
INBE_BUNDLE := $(BUILD_DIR)/inbe.zx
INBE_FULL_BUNDLE := $(BUILD_DIR)/inbe-full.zx
+1 -1
View File
@@ -164,7 +164,7 @@ Alpha :: (color: Color, opacity: float32) -> Color {
}
UiImage :: (label: string, x: float32, y: float32) -> ImageProps {
return ImageProps.{.asset_path = "icons/ui.png", .alt_text = label,
return ImageProps.{.asset_path = "icons/ui.webp", .alt_text = label,
.source = Rectangle.{x, y, 64.0, 64.0}}
}
+4 -4
View File
@@ -256,12 +256,12 @@ PicturePage :: (x: s32, width: s32, y: *s32) {
if manual.page == 0 {
if astral {
title = Locale("exercise_astral_projection")
Picture(ifx manual.dark then "assets/practices/astral_projection/banner-dark.png"
else "assets/practices/astral_projection/banner-light.png", title, hero,
Picture(ifx manual.dark then "assets/practices/astral_projection/banner-dark.webp"
else "assets/practices/astral_projection/banner-light.webp", title, hero,
cast(ImageFit)ImageFitCover)
} else {
title = Locale("meditation_title")
Picture("assets/practices/meditation/1.png", title, hero, cast(ImageFit)ImageFitContain)
Picture("assets/practices/meditation/1.webp", title, hero, cast(ImageFit)ImageFitContain)
}
} else {
CustomizeRing(hero, ifx astral then title else Locale("meditation_title"))
@@ -393,7 +393,7 @@ WhmPage :: (x: s32, width: s32, y: *s32) {
height := WhmVisualHeight(page)
hero := Hero(x, width, y.*, height)
if page == 0 || page == 3 {
Picture(ifx page == 3 then "assets/practices/whm/2.png" else "assets/practices/whm/1.png",
Picture(ifx page == 3 then "assets/practices/whm/2.webp" else "assets/practices/whm/1.webp",
Locale(WhmTitleKey(page)), hero, cast(ImageFit)ImageFitContain)
HeroDots(hero)
y.* += height + Scale(16)
+1 -1
View File
@@ -82,7 +82,7 @@ Controls :: () -> s32 {
for index: cast(s32)0..2 {
if Button(movement.session, ButtonProps.{.id = 83000 + index,
.bounds = BottomIconRowButtonBoundsFor(layout, index), .label = labels[index],
.icon_only = true, .image = ImageProps.{.asset_path = "icons/ui.png",
.icon_only = true, .image = ImageProps.{.asset_path = "icons/ui.webp",
.source = sources[index], .alt_text = labels[index]},
.tone = cast(ButtonTone)ButtonToneNeutral, .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft,
.disabled = index == 0 && !movement.can_back}) != 0 {
+4
View File
@@ -189,3 +189,7 @@ launcher-entry-test: $(ZI2C_BIN)
.PHONY: entity-picker-test
entity-picker-test: $(ZI2C_BIN)
ZI2C="$(ZI2C_BIN)" ZIRAN_STD_ROOT="$(ZIRAN_DIR)" python3 tests/entity_picker_test.py
.PHONY: telegram-svg-test
telegram-svg-test: $(ZI2C_BIN)
sh tests/telegram_svg_test.sh $(ZIRAN_BUILD_DIR)/bin
+2
View File
@@ -170,3 +170,5 @@ ci: test web
test: local-game-records-test
test: android-push-delivery-test
test: telegram-svg-test
+1 -1
View File
@@ -124,7 +124,7 @@ for variant in sky air; do
</adaptive-icon>
EOF
# Settings previews contain only the person and cloud.
generate_transparent 192 "$PROJECT_ROOT/assets/app/icon-$preview.png"
generate_transparent 192 "$PROJECT_ROOT/assets/app/icon-$preview.webp"
done
ARTWORK="$WORK_DIR/sky.png"
+3 -3
View File
@@ -42,13 +42,13 @@ patterns = (
'assets/habits/**/*', 'assets/lists/**/*', 'assets/diary/**/*', 'assets/lumi/**/*',
'assets/fonts/subset/*-App-Regular.*', 'assets/styles/*.kss',
'locales/*.txt', 'themes/catalog_*.kss',
'build/packages/kss/styles/*.kss', 'build/packages/kryon/icons/ui.png',
'build/packages/kryon/icons/pfp.png',
'build/packages/kss/styles/*.kss', 'build/packages/kryon/icons/ui.webp',
'build/packages/kryon/icons/pfp.webp',
) + tuple(f'assets/{name}/**/*' for name in NODE_APPS)
# The practice media comes from the practices package and is packaged
# under assets/practices/.
practice_patterns = (
'whm/1.png', 'whm/2.png', 'meditation/1.png', '*/banner-light.png', '*/banner-dark.png',
'whm/1.webp', 'whm/2.webp', 'meditation/1.webp', '*/banner-light.webp', '*/banner-dark.webp',
'sunsalutation/characters/*/*.png', 'sunsalutation/flat-edge.png',
'sunsalutation/voice/**/*', 'sunsalutation/voice-male/**/*',
'astral_projection/**/*', 'workout/**/*', 'taichi/**/*', 'guide/voice/**/*',
+1 -1
View File
@@ -47,7 +47,7 @@ app_draw_close_title_bar :: (app: *InnerBreeze, title: string,
close.bounds = Rectangle.{cast(float32)x, cast(float32)y,
cast(float32)button_total, cast(float32)button_total
}
close.image.asset_path = "icons/ui.png"
close.image.asset_path = "icons/ui.webp"
close.image.alt_text = close_label
close.image.source = Rectangle.{.x = 448.0, .y = 384.0, .width = 64.0, .height = 64.0}
close.icon_only = true
+2 -2
View File
@@ -481,8 +481,8 @@ EntityHostCall :: (context: *void, module: *u8, function: *u8,
}
EntityHostAssetAllowed :: (path: string) -> bool {
return path == "" || path == "assets/entity/pfp.png" || path == "assets/entity/flowers.png" ||
path == "assets/entity/abstract-jade.png" || path == "assets/entity/abstract-amber.png" || path == "assets/entity/abstract-violet.png"
return path == "" || path == "assets/entity/pfp.webp" || path == "assets/entity/flowers.webp" ||
path == "assets/entity/abstract-jade.webp" || path == "assets/entity/abstract-amber.webp" || path == "assets/entity/abstract-violet.webp"
}
EntityHostRoute :: (app: *InnerBreeze) -> bool {
+41 -3
View File
@@ -7,19 +7,57 @@ PngDimension :: (path: string, offset: s32) -> s32 {
}
value := (cast(u32)asset.data[offset] << 24) |
(cast(u32)asset.data[offset + 1] << 16) |
(cast(u32)asset.data[offset + 2] << 8) |
cast(u32)asset.data[offset + 3]
(cast(u32)asset.data[offset + 1] << 16) |
(cast(u32)asset.data[offset + 2] << 8) |
cast(u32)asset.data[offset + 3]
if value == 0 || value > 2147483647 {
return 0
}
return cast(s32)value
}
// WebP stores dimensions in its first image or extended header.
WebpDimension :: (path: string, height: bool) -> s32 {
asset := AssetRead(path)
data := asset.data
if !asset.found || asset.mime != "image/webp" || data.count < 25 ||
data[0:4] != "RIFF" || data[8:12] != "WEBP" {
return 0
}
if data[12:16] == "VP8L" && data[20] == 47 {
if height {
return 1 + cast(s32)((cast(u32)data[22] >> 6) |
(cast(u32)data[23] << 2) | ((cast(u32)data[24] & 15) << 10))
}
return 1 + cast(s32)(cast(u32)data[21] | ((cast(u32)data[22] & 63) << 8))
}
if data.count < 30 {
return 0
}
if data[12:16] == "VP8X" {
offset: s32 = ifx height then 27 else 24
return 1 + cast(s32)(cast(u32)data[offset] |
(cast(u32)data[offset + 1] << 8) | (cast(u32)data[offset + 2] << 16))
}
if data[12:16] == "VP8 " && data[23] == 157 && data[24] == 1 && data[25] == 42 {
offset: s32 = ifx height then 28 else 26
return cast(s32)((cast(u32)data[offset] | (cast(u32)data[offset + 1] << 8)) & 16383)
}
return 0
}
ImageWidth :: (path: string) -> s32 {
width := WebpDimension(path, false)
if width != 0 {
return width
}
return PngDimension(path, 16)
}
ImageHeight :: (path: string) -> s32 {
height := WebpDimension(path, true)
if height != 0 {
return height
}
return PngDimension(path, 20)
}
+1 -1
View File
@@ -111,7 +111,7 @@ PracticeTitleBar :: (app: *InnerBreeze, title: string,
cast(float32)button_total
}
close.label = LocaleText("close_button")
close.image.asset_path = "icons/ui.png"
close.image.asset_path = "icons/ui.webp"
close.image.alt_text = close.label
close.image.source = Rectangle.{.x = 448.0, .y = 384.0, .width = 64.0, .height = 64.0}
close.icon_only = true
+3 -3
View File
@@ -44,7 +44,7 @@ ProfilePictureImage :: (icon_type: s32, label: string) -> ImageProps {
if icon_type == 50 {
// The profile card needs more detail than the 64-pixel icon atlas.
// Entity's copy in the root package is the same picture.
image.asset_path = "assets/entity/flowers.png"
image.asset_path = "assets/entity/flowers.webp"
image.fit = cast(ImageFit)ImageFitContain
return image
}
@@ -55,7 +55,7 @@ ProfilePictureImage :: (icon_type: s32, label: string) -> ImageProps {
if index < 0 || index >= 28 {
index = 0
}
image.asset_path = "icons/pfp.png"
image.asset_path = "icons/pfp.webp"
image.source = Rectangle.{cast(float32)((index % 5) * 64),
cast(float32)((index / 5) * 64), 64.0, 64.0
}
@@ -102,7 +102,7 @@ ProfileImagePicker :: (session: Session,
frame_props.scale = MetricsScale()
frame_props.has_right_action = true
frame_props.right_label = LocaleText("close_button")
frame_props.right_image.asset_path = "icons/ui.png"
frame_props.right_image.asset_path = "icons/ui.webp"
frame_props.right_image.alt_text = frame_props.right_label
frame_props.right_image.source = Rectangle.{.x = 448.0, .y = 384.0, .width = 64.0, .height = 64.0}
frame := ModalFrame(session, frame_props)
+4
View File
@@ -0,0 +1,4 @@
// Telegram vector from assets/social/telegram.svg.
// Relative curves and arcs normalized to absolute cubic paths with fontTools.svgLib.path.
// Source SHA-256: 4435c9a57e165a1c3b7f27e0b5b11b82b10d674ea4fff7f6748cb67b7fcb994e
TelegramIconShape :: "F:M11.944 0C5.33846284 0.0308261754 -7.19281332e-05 5.39439091 -1.33226763e-15 12C1.33226763e-15 18.627417 5.372583 24 12 24C18.627417 24 24 18.627417 24 12C24 5.372583 18.627417 4.05812251e-16 12 0C11.9813334 -4.35556148e-05 11.9626666 -4.35556148e-05 11.944 0ZM16.906 7.224C17.006 7.222 17.227 7.247 17.371 7.364C17.4666886 7.44709629 17.5277112 7.56307491 17.542 7.689C17.558 7.782 17.578 7.995 17.562 8.161C17.382 10.059 16.6 14.663 16.202 16.788C16.034 17.688 15.703 17.989 15.382 18.018C14.686 18.083 14.157 17.558 13.482 17.116C12.426 16.423 11.829 15.992 10.804 15.316C9.619 14.536 10.387 14.106 11.062 13.406C11.239 13.222 14.309 10.429 14.369 10.176C14.376 10.144 14.383 10.026 14.313 9.964C14.243 9.902 14.139 9.923 14.064 9.94C13.958 9.964 12.271 11.08 9.003 13.285C8.523 13.615 8.09 13.775 7.701 13.765C7.273 13.757 6.449 13.524 5.836 13.325C5.084 13.08 4.487 12.951 4.539 12.536C4.566 12.32 4.864 12.099 5.432 11.873C8.93 10.349 11.262 9.344 12.43 8.859C15.762 7.473 16.455 7.232 16.906 7.224L16.906 7.224Z";
+1 -1
View File
@@ -46,7 +46,7 @@ guide_layout: GuideLayout;
// Inbe's active modal and guide actions use the shared icon atlas.
ActionImage :: (icon: ActionIcon, label: string) -> ImageProps {
image: ImageProps
image.asset_path = "icons/ui.png"
image.asset_path = "icons/ui.webp"
image.alt_text = label
x: s32 = 0
y: s32 = 0
+1 -1
View File
@@ -156,7 +156,7 @@ run_practice_probe :: (mode: s32, size: WindowSize) -> s32 {
}
} else if mode == 1 {
practice_draw_card_banner(
"assets/practices/meditation/banner-dark.png",
"assets/practices/meditation/banner-dark.webp",
Rectangle.{0.0, 0.0,
cast(float32)size.width, 360.0})
} else if mode == 2 {
+1 -1
View File
@@ -26,7 +26,7 @@ PRACTICE_AUDIO_MUSIC_POPUP_ID :: 15001
PracticeAudioImage :: (music: bool, muted: bool,
label: string) -> ImageProps {
image: ImageProps
image.asset_path = "icons/ui.png"
image.asset_path = "icons/ui.webp"
image.alt_text = label
x: s32 = 320
y: s32 = 256
+7 -7
View File
@@ -185,25 +185,25 @@ practice_card_banner_asset_path :: (app: *InnerBreeze, exercise: s32) -> string
dark: bool = app != null && ((app.theme_mode == APP_THEME_DARK) || (app.theme_mode != APP_THEME_LIGHT && app.dark_mode != 0))
if id == EXERCISE_WIM_HOF {
return ifx (dark) then ("assets/practices/whm/banner-dark.png") else ("assets/practices/whm/banner-light.png")
return ifx (dark) then ("assets/practices/whm/banner-dark.webp") else ("assets/practices/whm/banner-light.webp")
}
if id == EXERCISE_SUN_SALUTATION {
return ifx (dark) then ("assets/practices/sunsalutation/banner-dark.png") else ("assets/practices/sunsalutation/banner-light.png")
return ifx (dark) then ("assets/practices/sunsalutation/banner-dark.webp") else ("assets/practices/sunsalutation/banner-light.webp")
}
if id == EXERCISE_MEDITATION {
return ifx (dark) then ("assets/practices/meditation/banner-dark.png") else ("assets/practices/meditation/banner-light.png")
return ifx (dark) then ("assets/practices/meditation/banner-dark.webp") else ("assets/practices/meditation/banner-light.webp")
}
if id == EXERCISE_PATTERNS {
return ifx (dark) then ("assets/practices/patterns/banner-dark.png") else ("assets/practices/patterns/banner-light.png")
return ifx (dark) then ("assets/practices/patterns/banner-dark.webp") else ("assets/practices/patterns/banner-light.webp")
}
if id == EXERCISE_TAI_CHI {
return ifx (dark) then ("assets/practices/taichi/banner-dark.png") else ("assets/practices/taichi/banner-light.png")
return ifx (dark) then ("assets/practices/taichi/banner-dark.webp") else ("assets/practices/taichi/banner-light.webp")
}
if id == EXERCISE_ASTRAL_PROJECTION {
return ifx dark then "assets/practices/astral_projection/banner-dark.png" else "assets/practices/astral_projection/banner-light.png"
return ifx dark then "assets/practices/astral_projection/banner-dark.webp" else "assets/practices/astral_projection/banner-light.webp"
}
if id == EXERCISE_WORKOUT {
return ifx dark then "assets/practices/workout/banner-dark.png" else "assets/practices/workout/banner-light.png"
return ifx dark then "assets/practices/workout/banner-dark.webp" else "assets/practices/workout/banner-light.webp"
}
return ""
}
+19 -7
View File
@@ -1,3 +1,6 @@
#import "svg_icon_widget"
#import "svg_icon_props"
#import, file "../../app/telegram_icon.zi";
#import, file "../../app/modal_rules.zi";
#import "button_widget"
#import, file "../../app/locale.zi";
@@ -227,13 +230,22 @@ about_draw_link_icons :: (app: *InnerBreeze, content_x: s32, content_w: s32, y:
}) != 0 {
OpenUri(urls[i])
}
Image(CurrentApp().ui.session, ImageProps.{
.asset_path = about_social_icon_asset(app, i),
.alt_text = about_social_icon_alt(i),
.bounds = Rectangle.{cast(float32)(button_x + icon_padding),
cast(float32)(button_y + icon_padding),
cast(float32)icon_size, cast(float32)icon_size}
})
icon_bounds := Rectangle.{cast(float32)(button_x + icon_padding),
cast(float32)(button_y + icon_padding),
cast(float32)icon_size, cast(float32)icon_size}
if i == ABOUT_SOCIAL_TELEGRAM {
SvgIcon(CurrentApp().ui.session, SvgIconProps.{
.bounds = icon_bounds,
.shape = TelegramIconShape,
.color = Color.{38, 165, 228, 255}
})
} else {
Image(CurrentApp().ui.session, ImageProps.{
.asset_path = about_social_icon_asset(app, i),
.alt_text = about_social_icon_alt(i),
.bounds = icon_bounds
})
}
i += 1
}
}
+1 -1
View File
@@ -60,7 +60,7 @@ bottom_nav_route_image :: (route: s32) -> ImageProps {
image.fit = ImageFit.ImageFitContain
return image
}
image.asset_path = "icons/ui.png"
image.asset_path = "icons/ui.webp"
x: s32 = 384
y: s32 = 192
if route == {
+4 -4
View File
@@ -71,8 +71,8 @@ main(void)
assert(SessionValid(app.ui.session));
app.ui.view_width = 400;
AppMetricsConfigure(1.0f);
assert(ImageWidth(StringView("icons/ui.png", 12)) == 512);
assert(ImageHeight(StringView("icons/ui.png", 12)) == 512);
assert(ImageWidth(StringView("icons/ui.webp", 13)) == 512);
assert(ImageHeight(StringView("icons/ui.webp", 13)) == 512);
assert(app_toolbar_height() == 58);
assert(app_content_top_reserved(&app) == GetTabBarHeight());
app.breathing.screen = ScreenSettings;
@@ -85,7 +85,7 @@ main(void)
for(int32_t index = 0; index < count; index++) {
PaintCommand command = PendingPaintAt(app.ui.session, index);
if(command.kind == PaintKindImage &&
StringEqual(command.asset_path, StringView("icons/ui.png", 12))) {
StringEqual(command.asset_path, StringView("icons/ui.webp", 13))) {
assert(command.source.x == 448.0f);
assert(command.source.y == 384.0f);
assert(command.source.width == 64.0f);
@@ -106,7 +106,7 @@ main(void)
for(int32_t index = 0; index < count; index++) {
PaintCommand command = PendingPaintAt(app.ui.session, index);
if(command.kind == PaintKindImage &&
StringEqual(command.asset_path, StringView("icons/ui.png", 12))) {
StringEqual(command.asset_path, StringView("icons/ui.webp", 13))) {
assert(command.source.x == 448.0f);
assert(command.source.y == 384.0f);
found_icon = true;
+1 -1
View File
@@ -37,7 +37,7 @@ mkdir -p "$work/c"
$(sh "$root/scripts/package-paths.sh" "$root/build/packages") \
-o "$work/c" "$root/src/app/image_dimensions.zi"
python3 "$root/scripts/embed-app-assets.py" "$work/assets.c" \
"$root/build/packages/kryon/icons/ui.png"
"$root/build/packages/kryon/icons/ui.webp"
set -- "$root/tests/app_chrome_link_test.c" \
"$work/assets.c"
for generated in "$work/c"/*.c "$work/c/app"/*.c; do
+1 -1
View File
@@ -208,7 +208,7 @@ CheckRootConfiguration :: () {
// with the app. Its card banner stays in Practices before installation.
shipped := AssetRead("assets/practices/default/whm.zx")
Expect(shipped.found && shipped.data.count > 8 && shipped.data[:2] == "ZX" &&
AssetRead("assets/practices/whm/banner-light.png").found, 106)
AssetRead("assets/practices/whm/banner-light.webp").found, 106)
language := AssetRead("locales/es.txt")
Expect(language.found && language.data.count > 1000, 107)
Expect(!AssetRead("apps/publishers.json").found, 108)
+2 -2
View File
@@ -26,7 +26,7 @@ asset_entry_at :: (index: usize) -> *EmbeddedAssetEntry {
#program_export
main :: () -> s32 {
CopyCString("icons/ui.png", path_bytes[:])
CopyCString("icons/ui.webp", path_bytes[:])
CopyCString("application/octet-stream", mime_bytes[:])
embedded_bytes[0] = 10
embedded_bytes[1] = 0
@@ -56,7 +56,7 @@ main :: () -> s32 {
CopyCString("disk.bin", path_bytes[:])
// Keep the catalog's asset path stable while checking the disk fallback.
stored_path: [32]u8
CopyCString("icons/ui.png", stored_path[:])
CopyCString("icons/ui.webp", stored_path[:])
entry.path = *stored_path[0]
loaded = TestReadFile(*path_bytes[0], *length)
if loaded == null || length != 4 || loaded[0] != 30 ||
+2 -2
View File
@@ -146,7 +146,7 @@ CheckHabitShop :: () -> s32 {
return 0
}
// Generated rewards expose their packaged PNG size to the headless painter.
// Generated rewards expose their packaged WebP size to the headless painter.
#program_export
ImageWidth :: (path: string) -> s32 {
if RewardTestImage(path) { return 128 }
@@ -165,7 +165,7 @@ RewardTestImage :: (path: string) -> bool {
for icon: icons {
if path == RewardIconAsset(icon) {
asset := AppsAsset(path)
return asset.found && asset.data.count > 8 && asset.data[1:4] == "PNG"
return asset.found && asset.data.count >= 12 && asset.data[0:4] == "RIFF" && asset.data[8:12] == "WEBP"
}
}
return false
+4 -4
View File
@@ -1,6 +1,6 @@
"""Every Kryon icon Inbe draws comes from an icon sheet Inbe ships.
Kryon's ImageForIcon maps each IconType to a sheet such as icons/ui.png.
Kryon's ImageForIcon maps each IconType to a sheet such as icons/ui.webp.
A sheet that is missing from the desktop embed or the app packages shows
"Missing image" instead of the icon, so this fails the build first."""
from pathlib import Path
@@ -42,8 +42,8 @@ def shipped_sheets():
"""Sheets embedded in the desktop app and in the app packages."""
makefile = (ROOT / "Makefile").read_text()
packages = (ROOT / "scripts/prepare-package-assets.py").read_text()
desktop = set(re.findall(r"\$\(KRYON_DIR\)/(icons/[\w.-]+\.png)", makefile))
packaged = set(re.findall(r"build/packages/kryon/(icons/[\w.-]+\.png)", packages))
desktop = set(re.findall(r"\$\(KRYON_DIR\)/(icons/[\w.-]+\.webp)", makefile))
packaged = set(re.findall(r"build/packages/kryon/(icons/[\w.-]+\.webp)", packages))
return desktop, packaged
@@ -62,7 +62,7 @@ source = ICON_SOURCE.read_text()
values = icon_values(source)
sheets = icon_sheets(source)
desktop, packaged = shipped_sheets()
assert values and sheets and "icons/ui.png" in desktop and "icons/ui.png" in packaged, \
assert values and sheets and "icons/ui.webp" in desktop and "icons/ui.webp" in packaged, \
"Could not read Kryon's icon sheets or Inbe's shipped assets"
failures = []
for name, place in sorted(used_icons(values).items()):
+6 -6
View File
@@ -78,13 +78,13 @@ lumi = assets(root['cells/lumi.zx'])
assert not any(name.endswith('.ogg') for name in lumi), [name for name in lumi if name.endswith('.ogg')][:3]
combined = root | practices | content
source = '\n'.join(path.read_text(errors='replace') for path in (ROOT / 'src').rglob('*.zi'))
paths = set(re.findall(r'"((?:assets/)?(?:practices|easteregg|pet)/[^"\n]+\.(?:png|jpg|jpeg))"', source))
paths = set(re.findall(r'"((?:assets/)?(?:practices|easteregg|pet)/[^"\n]+\.(?:png|jpg|jpeg|webp))"', source))
assert paths
for path in paths:
path = path if path.startswith('assets/') else 'assets/' + path
assert path in combined, f'image is absent from package: {path}'
assert combined[path] == media_path(path).read_bytes(), path
for path in ('icons/ui.png', 'icons/pfp.png'):
for path in ('icons/ui.webp', 'icons/pfp.webp'):
assert root[path] == (ROOT / 'build/packages/kryon' / path).read_bytes()
for file in (ROOT / 'locales').glob('*.txt'):
assert root['locales/' + file.name] == file.read_bytes()
@@ -100,12 +100,12 @@ for name in root:
assert not any(name.endswith('/banner.png') for name in practices)
# Practice pictures ship only in their packs, apart from every practice's
# banners: Practice's tabs show each practice before it is downloaded.
banner = re.compile(r'assets/practices/[a-z_]+/banner-(?:light|dark)\.png')
assert not any(name.endswith('.png') and not banner.fullmatch(name) for name in practices), \
[name for name in practices if name.endswith('.png') and not banner.fullmatch(name)]
banner = re.compile(r'assets/practices/[a-z_]+/banner-(?:light|dark)\.webp')
assert not any(name.endswith(('.png', '.webp')) and not banner.fullmatch(name) for name in practices), \
[name for name in practices if name.endswith(('.png', '.webp')) and not banner.fullmatch(name)]
for name in NAMES:
for theme in ('light', 'dark'):
path = f'assets/practices/{name}/banner-{theme}.png'
path = f'assets/practices/{name}/banner-{theme}.webp'
assert practices[path] == media_path(path).read_bytes(), path
# The small practices ship installed with Practices, each its pack's exact
# bytes; Sun Salutation and Tai Chi download.
+2 -2
View File
@@ -103,7 +103,7 @@ CheckPracticeDownloads :: () -> s32 {
if FixtureStarts() != 1 {
return 16
}
if !PracticeDownloadsAsset("assets/practices/whm/1.png").found {
if !PracticeDownloadsAsset("assets/practices/whm/1.webp").found {
return 3
}
if PracticeDownloadsAsset("locales/en.txt").found ||
@@ -115,7 +115,7 @@ CheckPracticeDownloads :: () -> s32 {
FixtureCatalogMode(1)
AssetNotifyChanged()
FixturePracticePump(0, false, false, true)
if !PracticeContentReady(0) || !PracticeDownloadsAsset("assets/practices/whm/1.png").found {
if !PracticeContentReady(0) || !PracticeDownloadsAsset("assets/practices/whm/1.webp").found {
return 18
}
FixtureCatalogMode(0)
+1 -1
View File
@@ -51,7 +51,7 @@ sessions_test_course_codec: WidgetPracticeCourseFrameCodec;
sessions_test_row_codec: WidgetPracticeCourseRowCodec;
SessionsTestAssets :: (path: string) -> bool {
return path.count == 0 || path == "icons/ui.png"
return path.count == 0 || path == "icons/ui.webp"
}
SessionsTestCall :: (context: *void, module: *u8, function: *u8,
+14
View File
@@ -0,0 +1,14 @@
#import "svg_shape"
#import, file "../src/app/telegram_icon.zi";
coverage: [96 * 96]u8;
#program_export
RenderTelegram :: () -> bool {
return ShapeRaster(TelegramIconShape, 96, coverage[:])
}
#program_export
TelegramPixel :: (x: s32, y: s32) -> u8 {
return coverage[y * 96 + x]
}
+40
View File
@@ -0,0 +1,40 @@
#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
bin=${1:-"$root/build/ziran-toolchain/bin"}
work="$root/build/telegram-svg-test"
mkdir -p "$work/c"
"$bin/zi2c" --no-main --root "$root/tests" \
--module-path "$root/src" --module-path "$root/build/packages/ziran/std" \
--module-path "$root/build/packages/kryon/src/ui" \
-o "$work/c" "$root/tests/telegram_svg_behavior.zi"
cat > "$work/main.c" <<'C'
#include "telegram_svg_behavior.h"
#include <assert.h>
#include <stdio.h>
int main(void) {
assert(RenderTelegram());
assert(TelegramPixel(0, 0) == 0);
assert(TelegramPixel(12, 48) == 255);
FILE *image = fopen("coverage.pgm", "wb");
assert(image);
fprintf(image, "P5\n96 96\n255\n");
int area = 0, holes = 0;
for (int y = 0; y < 96; y++) {
for (int x = 0; x < 96; x++) {
unsigned char value = TelegramPixel(x, y);
area += value;
if (x >= 30 && x < 65 && y >= 30 && y < 65 && value == 0) holes++;
fwrite(&value, 1, 1, image);
}
}
assert(fclose(image) == 0);
assert(area / 255 > 4500 && area / 255 < 7500);
assert(holes > 100);
puts("Telegram SVG native vector raster: circle, transparent paper and coverage passed");
return 0;
}
C
"${CC:-cc}" -std=c11 -I"$root/build/packages/ziran/include" -I"$work/c" \
"$work/main.c" "$work/c"/*.c "$root/build/ziran-toolchain/libziran.a" -lm -lz -o "$work/test"
(cd "$work" && env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS "$work/test")
+38 -20
View File
@@ -10,6 +10,15 @@
"source": true,
"url": "https://github.com/LoupVaillant/Monocypher.git"
},
{
"commit": "d4f7ab7bcbb66388ab99292dbcd357fcc26b8dcc",
"dependencies": {"curl": "p8da229d15597ab5c", "daochi_client": "p6af0b5bd9fd0cd31", "kryon": "p79167729f20b4a95", "monocypher": "p002f6ed23e3a3576", "oqs": "p7098ac9cd92f7e5f", "qrcode": "p0dfa70137405b096", "zlib": "p82dbc05081cd4d96"},
"dependency_refs": {"curl": "19b299005fbe2d895f4ad525cfdae62a2220c3ea", "daochi_client": "970d5e44b1702158cb16469892da6ff50f142427", "kryon": "ead3eb7aa63535447a1116ecae7bb4d712d72034", "monocypher": "master", "oqs": "master", "qrcode": "master", "zlib": "51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf"},
"id": "p08b4b3a8d566df13",
"name": "Entity",
"ref": "d4f7ab7bcbb66388ab99292dbcd357fcc26b8dcc",
"url": "https://github.com/waozixyz/entity.git"
},
{
"commit": "2944b2e668e735438d8ce24e47a39be3f5c36af5",
"dependencies": {},
@@ -45,15 +54,6 @@
"ref": "f7ff3e546657a0f90de16802fc9fc4a700412481",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "43701aaf0da1e114df7793bf9876a044b96572e1",
"dependencies": {"curl": "p8da229d15597ab5c", "daochi_client": "p6af0b5bd9fd0cd31", "kryon": "p2a656232910109dd", "monocypher": "p002f6ed23e3a3576", "oqs": "p7098ac9cd92f7e5f", "qrcode": "p0dfa70137405b096", "zlib": "p82dbc05081cd4d96"},
"dependency_refs": {"curl": "19b299005fbe2d895f4ad525cfdae62a2220c3ea", "daochi_client": "970d5e44b1702158cb16469892da6ff50f142427", "kryon": "f7ff3e546657a0f90de16802fc9fc4a700412481", "monocypher": "master", "oqs": "master", "qrcode": "master", "zlib": "51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf"},
"id": "p300040f426184cc0",
"name": "Entity",
"ref": "43701aaf0da1e114df7793bf9876a044b96572e1",
"url": "https://github.com/waozixyz/entity.git"
},
{
"commit": "1844042d1ca751e62e61df7617dba19c98588339",
"dependencies": {},
@@ -99,6 +99,15 @@
"source": true,
"url": "https://github.com/curl/curl.git"
},
{
"commit": "ead3eb7aa63535447a1116ecae7bb4d712d72034",
"dependencies": {"libwebp": "p3b3c785a0e17e605", "raylib": "pcc7aa76725f2fb2f"},
"dependency_refs": {"libwebp": "1844042d1ca751e62e61df7617dba19c98588339", "raylib": "fafa2cea97d0cb379d832086ba45a989fa6f9c8e"},
"id": "p79167729f20b4a95",
"name": "kryon",
"ref": "ead3eb7aa63535447a1116ecae7bb4d712d72034",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf",
"dependencies": {},
@@ -126,6 +135,15 @@
"source": true,
"url": "https://github.com/raysan5/rini.git"
},
{
"commit": "329ad781a2d396836344789ffc0bd4b90a831e25",
"dependencies": {},
"id": "p948d09611e15b580",
"name": "practices",
"ref": "329ad781a2d396836344789ffc0bd4b90a831e25",
"source": true,
"url": "https://github.com/waozixyz/practices.git"
},
{
"commit": "5157b63b703981c1e637c78c71b4c475d9699932",
"dependencies": {"crypto": "pc23fbf455e97614d", "daochi_client": "p6af0b5bd9fd0cd31", "kryon": "p2a656232910109dd"},
@@ -179,6 +197,15 @@
"source": true,
"url": "https://github.com/raysan5/raylib.git"
},
{
"commit": "9886717e6bf87d5bf77f1acd14462018dc8f39d2",
"dependencies": {"libwebp": "p3b3c785a0e17e605", "raylib": "pcc7aa76725f2fb2f"},
"dependency_refs": {"libwebp": "1844042d1ca751e62e61df7617dba19c98588339", "raylib": "fafa2cea97d0cb379d832086ba45a989fa6f9c8e"},
"id": "pcd0d5ab648bbb8dd",
"name": "kryon",
"ref": "9886717e6bf87d5bf77f1acd14462018dc8f39d2",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "9cc6872f75447c3a24c16764f9829d0f58751cb0",
"dependencies": {},
@@ -186,20 +213,11 @@
"name": "mingcute",
"ref": "master",
"url": "https://github.com/kryonlabs/mingcute.git"
},
{
"commit": "6e98d8486fe560bde76cb0ce8b841a3884cf42da",
"dependencies": {},
"id": "pfde6fe30458cad7d",
"name": "practices",
"ref": "master",
"source": true,
"url": "https://github.com/waozixyz/practices.git"
}
],
"root": {
"dependencies": {"apps": "pa53467b904293b28", "crypto": "pc23fbf455e97614d", "curl": "p739f5b821e102505", "daochi_client": "p6af0b5bd9fd0cd31", "entity": "p300040f426184cc0", "game2d": "p20eb23d3e6db3711", "kryon": "p2a656232910109dd", "kss": "p1b13dda539ed2a39", "liboqs": "p60ff905f3a963886", "mingcute": "pe1027b9d16704793", "monocypher": "p002f6ed23e3a3576", "oqs": "p7098ac9cd92f7e5f", "plot": "pab5377a2950368a2", "practices": "pfde6fe30458cad7d", "qrcode": "p0dfa70137405b096", "rini": "p8ea355e8cb04093e", "sqlite": "pb6abbb780a670e17"},
"dependency_refs": {"apps": "5157b63b703981c1e637c78c71b4c475d9699932", "crypto": "master", "curl": "master", "daochi_client": "master", "entity": "43701aaf0da1e114df7793bf9876a044b96572e1", "game2d": "bad2caaa84ef3eae61e40c99bf572d2b060d0ca2", "kryon": "f7ff3e546657a0f90de16802fc9fc4a700412481", "kss": "1cb9df183089a77c8a16448a556186f30b261a98", "liboqs": "main", "mingcute": "master", "monocypher": "master", "oqs": "master", "plot": "master", "practices": "master", "qrcode": "master", "rini": "main", "sqlite": "master"},
"dependencies": {"apps": "pa53467b904293b28", "crypto": "pc23fbf455e97614d", "curl": "p739f5b821e102505", "daochi_client": "p6af0b5bd9fd0cd31", "entity": "p08b4b3a8d566df13", "game2d": "p20eb23d3e6db3711", "kryon": "pcd0d5ab648bbb8dd", "kss": "p1b13dda539ed2a39", "liboqs": "p60ff905f3a963886", "mingcute": "pe1027b9d16704793", "monocypher": "p002f6ed23e3a3576", "oqs": "p7098ac9cd92f7e5f", "plot": "pab5377a2950368a2", "practices": "p948d09611e15b580", "qrcode": "p0dfa70137405b096", "rini": "p8ea355e8cb04093e", "sqlite": "pb6abbb780a670e17"},
"dependency_refs": {"apps": "5157b63b703981c1e637c78c71b4c475d9699932", "crypto": "master", "curl": "master", "daochi_client": "master", "entity": "d4f7ab7bcbb66388ab99292dbcd357fcc26b8dcc", "game2d": "bad2caaa84ef3eae61e40c99bf572d2b060d0ca2", "kryon": "9886717e6bf87d5bf77f1acd14462018dc8f39d2", "kss": "1cb9df183089a77c8a16448a556186f30b261a98", "liboqs": "main", "mingcute": "master", "monocypher": "master", "oqs": "master", "plot": "master", "practices": "329ad781a2d396836344789ffc0bd4b90a831e25", "qrcode": "master", "rini": "main", "sqlite": "master"},
"name": "Inbe"
},
"toolchain": {
+3 -3
View File
@@ -9,7 +9,7 @@ ref = "c47f927ca316a0494dff4f2389de3333bc8e08b4"
[dependencies.kryon]
git = "https://github.com/kryonlabs/kryon.git"
ref = "f7ff3e546657a0f90de16802fc9fc4a700412481"
ref = "9886717e6bf87d5bf77f1acd14462018dc8f39d2"
[dependencies.kss]
git = "https://github.com/kryonlabs/kss.git"
@@ -66,7 +66,7 @@ ref = "master"
[dependencies.entity]
git = "https://github.com/waozixyz/entity.git"
ref = "43701aaf0da1e114df7793bf9876a044b96572e1"
ref = "d4f7ab7bcbb66388ab99292dbcd357fcc26b8dcc"
[dependencies.crypto]
git = "https://github.com/ziranlang/crypto.git"
@@ -79,5 +79,5 @@ ref = "5157b63b703981c1e637c78c71b4c475d9699932"
# The practices' pictures, course data and recordings (scripts/practice_media.py).
[dependencies.practices]
git = "https://github.com/waozixyz/practices.git"
ref = "master"
ref = "329ad781a2d396836344789ffc0bd4b90a831e25"
source = true