More slides + code slide
This commit is contained in:
parent
1751dfaa62
commit
425150b3a8
1805
Cargo.lock
generated
1805
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -7,4 +7,6 @@ edition = "2024"
|
|||||||
config = "0.15.18"
|
config = "0.15.18"
|
||||||
macroquad = "0.4.14"
|
macroquad = "0.4.14"
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
rand = "0.9.0"
|
rand = "0.10.1"
|
||||||
|
reqwest = { version = "0.13.3", features = ["blocking", "json"] }
|
||||||
|
serde_json = "1.0.149"
|
||||||
|
|||||||
7
cfg/04_wait_what.toml
Normal file
7
cfg/04_wait_what.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
title = "You code outside of work too?"
|
||||||
|
image = "cfg/img/slide_code.png"
|
||||||
|
body = """
|
||||||
|
* Yes, I spent a lot of time doing it too
|
||||||
|
* Code for this slide shown on the right
|
||||||
|
* (Yes it's Rust)
|
||||||
|
"""
|
||||||
BIN
cfg/img/slide_code.png
Normal file
BIN
cfg/img/slide_code.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 134 KiB |
@ -1,7 +1,7 @@
|
|||||||
use macroquad::color::Color;
|
use macroquad::color::Color;
|
||||||
use macroquad::prelude::{draw_circle, screen_height, screen_width};
|
use macroquad::prelude::{draw_circle, screen_height, screen_width};
|
||||||
use rand::prelude::SmallRng;
|
use rand::prelude::SmallRng;
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{RngExt, SeedableRng};
|
||||||
|
|
||||||
pub fn star_field() {
|
pub fn star_field() {
|
||||||
let mut rng = SmallRng::seed_from_u64(0x55);
|
let mut rng = SmallRng::seed_from_u64(0x55);
|
||||||
|
|||||||
@ -8,6 +8,7 @@ mod utils;
|
|||||||
use crate::slide_show_config::{Context, SlideShowTheme};
|
use crate::slide_show_config::{Context, SlideShowTheme};
|
||||||
use crate::slides::Slideshow;
|
use crate::slides::Slideshow;
|
||||||
use crate::slides::demo::Demo;
|
use crate::slides::demo::Demo;
|
||||||
|
use crate::slides::projects::Projects;
|
||||||
use crate::slides::standard_slide::StandardSlide;
|
use crate::slides::standard_slide::StandardSlide;
|
||||||
use crate::slides::title::Title;
|
use crate::slides::title::Title;
|
||||||
use crate::text_drawer::{Justified, TextConfigBuilder};
|
use crate::text_drawer::{Justified, TextConfigBuilder};
|
||||||
@ -56,8 +57,11 @@ async fn main() {
|
|||||||
slideshow.add_slide(Title::new("Software As a Bit".to_string()));
|
slideshow.add_slide(Title::new("Software As a Bit".to_string()));
|
||||||
slideshow.add_slide(Demo::new());
|
slideshow.add_slide(Demo::new());
|
||||||
slideshow.add_slide(StandardSlide::new(&PathBuf::from("cfg/01_author_intro.toml")).await);
|
slideshow.add_slide(StandardSlide::new(&PathBuf::from("cfg/01_author_intro.toml")).await);
|
||||||
slideshow.add_slide(StandardSlide::new(&PathBuf::from("cfg/02_things_i_have_worked_on.toml")).await);
|
slideshow
|
||||||
|
.add_slide(StandardSlide::new(&PathBuf::from("cfg/02_things_i_have_worked_on.toml")).await);
|
||||||
slideshow.add_slide(StandardSlide::new(&PathBuf::from("cfg/03_me_outside_work.toml")).await);
|
slideshow.add_slide(StandardSlide::new(&PathBuf::from("cfg/03_me_outside_work.toml")).await);
|
||||||
|
slideshow.add_slide(StandardSlide::new(&PathBuf::from("cfg/04_wait_what.toml")).await);
|
||||||
|
slideshow.add_slide(Projects::new());
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if slideshow.handle_slide_show() {
|
if slideshow.handle_slide_show() {
|
||||||
|
|||||||
@ -49,8 +49,7 @@ impl Slide for Demo {
|
|||||||
|
|
||||||
pop_camera_state();
|
pop_camera_state();
|
||||||
|
|
||||||
ctx
|
ctx.slide_show_theme
|
||||||
.slide_show_theme
|
|
||||||
.heading_config
|
.heading_config
|
||||||
.draw_text("This Ain't No Powerpoint", screen_center());
|
.draw_text("This Ain't No Powerpoint", screen_center());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ use macroquad::camera::set_default_camera;
|
|||||||
use macroquad::input::{KeyCode, is_key_pressed};
|
use macroquad::input::{KeyCode, is_key_pressed};
|
||||||
|
|
||||||
pub mod demo;
|
pub mod demo;
|
||||||
|
pub mod projects;
|
||||||
pub mod standard_slide;
|
pub mod standard_slide;
|
||||||
pub mod title;
|
pub mod title;
|
||||||
|
|
||||||
|
|||||||
119
src/slides/projects.rs
Normal file
119
src/slides/projects.rs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
use crate::effects::star_field;
|
||||||
|
use crate::slide::Slide;
|
||||||
|
use crate::slide_show_config::Context;
|
||||||
|
use crate::text_drawer::{Justified, TextConfigBuilder};
|
||||||
|
use crate::utils::{draw_rectangle_with_border, screen_center};
|
||||||
|
use macroquad::color::{BLACK, DARKGREEN, GREEN};
|
||||||
|
use macroquad::math::Vec2;
|
||||||
|
use macroquad::prelude::{clear_background, draw_rectangle, screen_height, screen_width};
|
||||||
|
use rand::prelude::IndexedRandom;
|
||||||
|
use rand::rng;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct GiteaRepo {
|
||||||
|
pub id: u64,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct GiteaResponse {
|
||||||
|
pub ok: bool,
|
||||||
|
pub data: Vec<GiteaRepo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct FloatingText {
|
||||||
|
pos: Vec2,
|
||||||
|
vel: Vec2,
|
||||||
|
text: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Projects {
|
||||||
|
repos: Vec<FloatingText>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Projects {
|
||||||
|
pub fn new() -> Box<Self> {
|
||||||
|
let resp: GiteaResponse =
|
||||||
|
reqwest::blocking::get("https://git.ahines.net/api/v1/repos/search")
|
||||||
|
.unwrap()
|
||||||
|
.json()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let repos: Vec<FloatingText> = resp
|
||||||
|
.data
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|r| {
|
||||||
|
if !r.name.starts_with("_") {
|
||||||
|
Some(FloatingText {
|
||||||
|
pos: Default::default(),
|
||||||
|
vel: Default::default(),
|
||||||
|
text: r.name,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
Box::new(Self { repos })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Slide for Projects {
|
||||||
|
fn display(&mut self, ctx: &Context<'_>) {
|
||||||
|
clear_background(BLACK);
|
||||||
|
star_field();
|
||||||
|
|
||||||
|
let text_cfg = TextConfigBuilder::new(ctx.slide_show_theme.body_config.clone())
|
||||||
|
.font_size(75)
|
||||||
|
.justification(Justified::Center)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
for repo in &mut self.repos {
|
||||||
|
if repo.pos.x <= 0.0
|
||||||
|
|| repo.pos.y <= 0.0
|
||||||
|
|| repo.pos.x > screen_width()
|
||||||
|
|| repo.pos.y > screen_height()
|
||||||
|
{
|
||||||
|
repo.pos = screen_center();
|
||||||
|
let vel: f32 = rand::random_range(1.0..1.5);
|
||||||
|
let angle: f32 = rand::random_range(0.0..2.0 * PI);
|
||||||
|
|
||||||
|
repo.vel = Vec2::new(vel, 0.0).rotate(Vec2::from(angle.sin_cos()));
|
||||||
|
|
||||||
|
repo.vel = Vec2::new(rand::random_range(0.1..1.5), rand::random_range(0.1..1.5));
|
||||||
|
|
||||||
|
repo.vel.x *= [-1.0, 1.0].choose(&mut rng()).unwrap();
|
||||||
|
repo.vel.y *= [-1.0, 1.0].choose(&mut rng()).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
text_cfg.draw_text(&repo.text, repo.pos);
|
||||||
|
|
||||||
|
repo.pos += repo.vel
|
||||||
|
}
|
||||||
|
let dim = ctx
|
||||||
|
.slide_show_theme
|
||||||
|
.heading_config
|
||||||
|
.measure_text("https://git.ahines.net");
|
||||||
|
|
||||||
|
let background_rectangle_size = Vec2::new(dim.width * 1.2, dim.height * 1.2);
|
||||||
|
let pos =
|
||||||
|
screen_center() - background_rectangle_size * 0.5 - Vec2::new(0.0, dim.offset_y * 0.5);
|
||||||
|
|
||||||
|
draw_rectangle_with_border(
|
||||||
|
pos,
|
||||||
|
background_rectangle_size,
|
||||||
|
background_rectangle_size.x * 0.01,
|
||||||
|
GREEN,
|
||||||
|
DARKGREEN,
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.slide_show_theme
|
||||||
|
.heading_config
|
||||||
|
.draw_text("https://git.ahines.net", screen_center());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,7 +5,9 @@ use config::Config;
|
|||||||
use macroquad::color::{BLACK, WHITE};
|
use macroquad::color::{BLACK, WHITE};
|
||||||
use macroquad::file::load_file;
|
use macroquad::file::load_file;
|
||||||
use macroquad::math::Vec2;
|
use macroquad::math::Vec2;
|
||||||
use macroquad::prelude::{Texture2D, clear_background, load_texture, draw_texture, draw_texture_ex, DrawTextureParams};
|
use macroquad::prelude::{
|
||||||
|
DrawTextureParams, Texture2D, clear_background, draw_texture, draw_texture_ex, load_texture,
|
||||||
|
};
|
||||||
use macroquad::window::{screen_height, screen_width};
|
use macroquad::window::{screen_height, screen_width};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
@ -70,7 +72,6 @@ impl Slide for StandardSlide {
|
|||||||
Vec2::new(screen_width() * 0.5, screen_height() * 0.8),
|
Vec2::new(screen_width() * 0.5, screen_height() * 0.8),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if let Some(image) = &self.image {
|
if let Some(image) = &self.image {
|
||||||
let size = image.size();
|
let size = image.size();
|
||||||
let image_center_pos = Vec2::new(screen_width() * 0.75, screen_height() * 0.5);
|
let image_center_pos = Vec2::new(screen_width() * 0.75, screen_height() * 0.5);
|
||||||
@ -83,10 +84,16 @@ impl Slide for StandardSlide {
|
|||||||
|
|
||||||
let image_pos = image_center_pos - new_image_size * 0.5;
|
let image_pos = image_center_pos - new_image_size * 0.5;
|
||||||
|
|
||||||
draw_texture_ex(image, image_pos.x, image_pos.y, WHITE, DrawTextureParams {
|
draw_texture_ex(
|
||||||
dest_size: Some(new_image_size),
|
image,
|
||||||
..Default::default()
|
image_pos.x,
|
||||||
});
|
image_pos.y,
|
||||||
|
WHITE,
|
||||||
|
DrawTextureParams {
|
||||||
|
dest_size: Some(new_image_size),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
22
src/utils.rs
22
src/utils.rs
@ -1,6 +1,28 @@
|
|||||||
|
use macroquad::color::Color;
|
||||||
use macroquad::math::Vec2;
|
use macroquad::math::Vec2;
|
||||||
use macroquad::miniquad::window::screen_size;
|
use macroquad::miniquad::window::screen_size;
|
||||||
|
use macroquad::prelude::draw_rectangle;
|
||||||
|
|
||||||
pub fn screen_center() -> Vec2 {
|
pub fn screen_center() -> Vec2 {
|
||||||
Vec2::from(screen_size()) * 0.5
|
Vec2::from(screen_size()) * 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn draw_rectangle_with_border(
|
||||||
|
rect_pos: Vec2,
|
||||||
|
rect_size: Vec2,
|
||||||
|
border_width: f32,
|
||||||
|
fg_color: Color,
|
||||||
|
bg_color: Color,
|
||||||
|
) {
|
||||||
|
let border_pos = rect_pos - border_width;
|
||||||
|
let border_size = rect_size + 2.0 * border_width;
|
||||||
|
|
||||||
|
draw_rectangle(
|
||||||
|
border_pos.x,
|
||||||
|
border_pos.y,
|
||||||
|
border_size.x,
|
||||||
|
border_size.y,
|
||||||
|
bg_color,
|
||||||
|
);
|
||||||
|
draw_rectangle(rect_pos.x, rect_pos.y, rect_size.x, rect_size.y, fg_color);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user