wasm32 build

This commit is contained in:
djmil 2024-08-04 16:58:19 +02:00
parent b730f7640c
commit a23a328e50
7 changed files with 54 additions and 24 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "eGUI Circles", "name": "eGUI Circles",
"short_name": "circles", "short_name": "egui-circles",
"icons": [ "icons": [
{ {
"src": "/icon-192.png", "src": "/icon-192.png",

View File

@ -1,9 +1,9 @@
var cacheName = 'egui-template-pwa'; var cacheName = 'egui-circles';
var filesToCache = [ var filesToCache = [
'./', './',
'./index.html', './index.html',
'./eframe_template.js', './egui-circles.js',
'./eframe_template_bg.wasm', './egui-circles_bg.wasm',
]; ];
/* Start the service worker and cache all of the app's content */ /* Start the service worker and cache all of the app's content */

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -euxo pipefail
docker build --tag egui-circles-builder:0.0.1 .

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
PROJECT_NAME=egui-circles
docker run \
--volume $(pwd)/..:/$PROJECT_NAME \
--name vsc-$PROJECT_NAME \
-p 8080:8080 \
$PROJECT_NAME-builder:0.0.1

View File

@ -32,6 +32,11 @@ impl eframe::App for Simulation {
// Looks better on 4k montior // Looks better on 4k montior
ctx.set_pixels_per_point(1.5); ctx.set_pixels_per_point(1.5);
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar:
egui::widgets::global_dark_light_mode_buttons(ui);
});
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
if ui.button("halt").clicked() { if ui.button("halt").clicked() {
self.circles.iter_mut().for_each(|c| (*c).v = Vec2{x: 0.0, y: 0.0}); self.circles.iter_mut().for_each(|c| (*c).v = Vec2{x: 0.0, y: 0.0});
@ -53,10 +58,10 @@ impl eframe::App for Simulation {
self.circles.push(Circle::default()); self.circles.push(Circle::default());
self.colors.push( self.colors.push(
egui::Color32::from_rgba_premultiplied( egui::Color32::from_rgba_premultiplied(
rand::thread_rng().gen_range(0..255), rand::thread_rng().gen_range(64..255),
rand::thread_rng().gen_range(0..255), rand::thread_rng().gen_range(64..255),
rand::thread_rng().gen_range(0..255), rand::thread_rng().gen_range(64..255),
64) 128)
); );
} }
} }
@ -92,7 +97,7 @@ impl eframe::App for Simulation {
self.circles[i].c, self.circles[i].c,
self.circles[i].r, self.circles[i].r,
self.colors[i] /*Color32::TRANSPARENT*/, self.colors[i] /*Color32::TRANSPARENT*/,
Stroke{width: 2.0, color: Color32::from_rgb(255, 255, 255)} Stroke{width: 2.0, color: Color32::from_rgb(200, 255, 255)}
); );
} }
}); });

View File

@ -9,4 +9,3 @@ ENTRYPOINT ["trunk"]
CMD ["serve"] CMD ["serve"]
WORKDIR /egui-circles WORKDIR /egui-circles

40
wasm32/build.sh Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -euo pipefail
NAME=egui-circles
BUILDER=djmil/$NAME-builder:0.0.1
TRAGET=$NAME-wasm32
has_docker_image() {
docker manifest inspect $1
} &> /dev/null
has_docker_container() {
docker container inspect $1
} &> /dev/null
if ! has_docker_image $BUILDER; then
echo "Docker $BUILDER was not found"
read -p "Would you like to create builder image (y/n)? "
case "$REPLY" in
y|Y )
docker build --tag $BUILDER . ;;
* )
exit 1 ;;
esac
fi
echo "Initiate WASM32 target build.."
if has_docker_container $TRAGET; then
docker start \
$TRAGET \
--attach
else
docker run \
--volume $(pwd)/..:/$NAME \
--name $TRAGET \
$BUILDER \
build --release
fi