}
elseif command_name == "background" {
r, g, b := parse_color(^parse_context);
- current_slide.background = Color.{ r, g, b };
+ current_slide.background = .{ r, g, b };
}
elseif command_name == "y" {
y := parse_numeric_value(^parse_context);
if style_name == "color" {
r, g, b := parse_color(pc);
- text_style.color = Color.{ r, g, b };
+ text_style.color = .{ r, g, b };
}
elseif style_name == "font_size" {
text_style.font_size = parse_numeric_value(pc);
}
elseif style_name == "border_color" {
r, g, b := parse_color(pc);
- image_style.border_color = Color.{ r, g, b };
+ image_style.border_color = .{ r, g, b };
}
else {
printf("Unknown style option: '%s'\n", style_name);
}
elseif style_name == "color" {
r, g, b := parse_color(pc);
- rect_style.color = Color.{ r, g, b };
+ rect_style.color = .{ r, g, b };
}
else {
printf("Unknown style option: '%s'\n", style_name);
handle: i32 = -1;
width: i32 = 1; // To avoid dividing by 0
height: i32 = 1;
+ size_initialized := false;
}
Color :: struct {
arena = alloc.arena.make(allocator, arena_size = 16 * 1024);
array.init(^slides, 4);
- map.init(^image_map, default = HTML_Image.{});
+ map.init(^image_map, default=.{});
}
slideshow_reset :: (use s: ^Slideshow) {
slideshow_make_item :: (use s: ^Slideshow) -> ^Slide_Item {
allocator := alloc.arena.make_allocator(^arena);
- ret := new(Slide_Item, allocator = allocator);
+ ret := new(Slide_Item, allocator=allocator, initialize=false);
memory.set(ret, 0, sizeof Slide_Item);
return ret;
}
+// @Cleanup
+use package core.intrinsics.wasm { __initialize }
+
slideshow_load_image :: (use s: ^Slideshow, image_name: str, image_path: str) -> HTML_Image {
if map.has(^image_map, image_name) {
printf("Warning: the image '%s' was already defined.", image_name);
html_image_load :: (path: str, out_image: ^HTML_Image) -> void #foreign "html" "load_image" ---
image: HTML_Image;
+ __initialize(^image);
html_image_load(image_path, ^image);
map.put(^image_map, image_name, image);
}
case Image {
- if html_image := map.get(^the_slideshow.image_map, image.name); html_image.handle != -1 {
- // @Speed: There is a much better way of doing this...
- // @Robustness: Currently, because HTML images are asynchronously loaded,
- // the image dimensions are not known when the load_image call is made.
- // These means that the dimensions need to be queried later once the image
- // has been loaded. The real bad thing here, is that the 'html_image' being
- // passed is a local copy from the image_map. This means everytime this image
- // is drawn, it has to requery the image dimensions... Uck...
- store_image_size :: (html_image: ^HTML_Image) -> void #foreign "html" "store_image_size" ---
- store_image_size(^html_image);
+ if html_image := map.get_ptr(^the_slideshow.image_map, image.name); html_image != null {
+ if !html_image.size_initialized {
+ store_image_size :: (html_image: ^HTML_Image) -> void #foreign "html" "store_image_size" ---
+ store_image_size(html_image);
+
+ html_image.size_initialized = true;
+ }
x := image.x * width;
y := image.y * height;
t : f32 = 0;
dt : f32 = 0.03;
-
make :: (allocator := context.allocator) -> ^Slide_Animation_Swipe {
- anim := new(Slide_Animation_Swipe, allocator=allocator);
- *anim = Slide_Animation_Swipe.{};
-
- return anim;
+ return new(Slide_Animation_Swipe, allocator=allocator);
}
init :: (use anim: ^Slide_Animation_Swipe, source := -1, target := -1) {
make :: (allocator := context.allocator) -> ^Slide_Animation_Fade {
- anim := new(Slide_Animation_Fade, allocator=allocator);
- *anim = Slide_Animation_Fade.{};
-
- return anim;
+ return new(Slide_Animation_Fade, allocator=allocator);
}
init :: (use anim: ^Slide_Animation_Fade, source := -1, target := -1) {
draw_line := false;
make :: (allocator := context.allocator) -> ^Slide_Animation_Wiper {
- anim := new(Slide_Animation_Wiper, allocator=allocator);
- *anim = Slide_Animation_Wiper.{};
-
- return anim;
+ return new(Slide_Animation_Wiper, allocator=allocator);
}
init :: (use anim: ^Slide_Animation_Wiper, source := -1, target := -1) {