Our Ideas Page.Google wrote:Applications for organizations open January 22 to February 6
Mentors, administrators, ideas are welcome.
I can be an administrator and a mentor.
Residents of United States embargoed countries are ineligible this year.
Our Ideas Page.Google wrote:Applications for organizations open January 22 to February 6
Code: Select all
#![no_std]
#![no_main]
use alloc::vec::Vec;
use cstr_core::{cstr, CStr};
use kos::{
graphics::{display_message, Color, Dot, Size},
input::fetch_key,
system::{get_lang, Lang},
threads::{exit, fetch_event, Event},
windows::{
define_button, define_window, end_window_draw, get_button_id, start_window_draw,
WindowKind, WindowParams, CLOSE_BUTTON,
},
};
const HEADER: &CStr = cstr!("Hey Kolibri");
const MSG: &CStr = cstr!("Hello GSoC 2024");
const BTN: u32 = 42;
const COLORS: [(u8, u8, u8); 3] = [(255, 0, 0), (0, 255, 0), (0, 0, 255)];
#[macro_use]
extern crate alloc;
fn draw_window(c: usize) {
start_window_draw();
define_window(
Dot { x: 50, y: 50 },
Size {
width: 300,
height: 400,
},
WindowParams {
color: Color::rgb(0xff, 0xff, 0xff),
kind: WindowKind::Themed,
title: Some(HEADER),
},
);
let color = COLORS[c % 3];
display_message(
Dot { x: 10, y: 10 },
Color::rgb(color.0, color.1, color.2),
MSG,
None,
);
define_button(
Dot { x: 10, y: 70 },
Size {
width: 70,
height: 15,
},
BTN,
true,
true,
Some(Color::rgb(128, 255, 128)),
);
display_message(
Dot { x: 10, y: 70 },
Color::rgb(0, 0, 0),
cstr!("Paint"),
None,
);
end_window_draw();
return;
}
fn button_handler(c: &mut usize) {
let btn_id = get_button_id();
if btn_id.is_some() {
match btn_id.unwrap() {
CLOSE_BUTTON => exit(),
BTN => {
*c += 1;
draw_window(*c);
}
_ => {}
}
}
}
#[no_mangle]
fn kol_main() {
let mut c = 0;
while let Some(ev) =
fetch_event((Event::Redraw as u32) | (Event::KeyPress as u32) | (Event::BtnPress as u32))
{
match ev {
Event::Redraw => draw_window(c),
Event::KeyPress => drop(fetch_key()),
Event::BtnPress => button_handler(&mut c),
_ => break,
}
}
}
Users browsing this forum: No registered users and 1 guest