#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::fs;
use pittore::prelude::*;
struct App {
f: i32,
}
impl PittoreApp for App {
fn init(&mut self, _ctx: &mut Context) {
println!("Press S to take a screen shot");
fs::create_dir_all("tmp").unwrap();
}
fn update(&mut self, c: &mut Context) {
if c.key_just_pressed(KeyCode::KeyS) {
c.save_screen_shot(format!("tmp/{:04}.png", self.f));
}
let pos1 = Vec2::from_angle(self.f as f32 * 0.01) * 200.0;
let pos2 = Vec2::from_angle(self.f as f32 * 0.04) * 300.0;
c.draw_circles([
Instance2d {
transform: Transform2d::from_translation(pos1).with_scale(Vec2::splat(64.0)),
color: Color::BLUE,
..Default::default()
},
Instance2d {
transform: Transform2d::from_translation(pos2).with_scale(Vec2::splat(64.0)),
color: Color::RED,
..Default::default()
},
]);
self.f += 1;
}
}
fn main() {
pittore::run("pittore", App { f: 0 });
}