-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added comments everywhere and fixed lints
- Loading branch information
Showing
32 changed files
with
934 additions
and
403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2024 Calli Evers | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
![Check and Deploy](https://img.shields.io/github/check-runs/callieve/metro-map-editor/main?style=flat-square) | ||
![GitHub License](https://img.shields.io/github/license/callieve/metro-map-editor?style=flat-square) | ||
![Website](https://img.shields.io/website?url=https%3A%2F%2Fcalli.dev%2Funiversity%2Fmetro-map&up_message=Online%20editor&up_color=blue&down_message=Temporarily%20unavailable&down_color=red&style=flat-square&label=try%20it%20out!) | ||
|
||
# Algorithmically Assisted Metro Map Editor | ||
|
||
This project is being made as part of my master thesis / graduation project at the [TU/e] as part of the [algo] research group. | ||
|
||
Try it out over at the deployed [site]. | ||
|
||
## Deploy it yourself | ||
|
||
### Prerequisites: | ||
|
||
Ensure you have [Rust] installed. | ||
Then, install and enable the rust nightly toolchain for this repository using `rustup toolchain install nightly && rustup override set nightly`. | ||
Since this repository uses WASM, ensure the wasm target has been added to your rust install with `rustup target add wasm32-unknown-unknown`. | ||
As tailwindcss is being used, [npm] is needed. | ||
Once npm has been installed, run `npm install -D` to install the tailwindcss package. | ||
Lastly ensure [trunk] has been installed using `cargo install --locked trunk`. | ||
|
||
### Deploy locally | ||
|
||
To deploy and run the editor on your local machine, you only need to run `trunk serve --open`. | ||
This will build the project, start listening on localhost:8080 and then open it in your browser. | ||
It will also watch for changes to the project files. | ||
|
||
[TU/e]: https://www.tue.nl/en/ | ||
[ALGO]: https://algo.win.tue.nl/ | ||
[site]: https://calli.dev/university/metro-map | ||
[Rust]: https://www.rust-lang.org/learn/get-started | ||
[NPM]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm | ||
[trunk]: https://trunkrs.dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
doc-valid-idents = ["GraphML", ".."] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
match_block_trailing_comma = true | ||
struct_lit_width = 0 | ||
use_field_init_shorthand = true | ||
chain_width = 0 | ||
array_width = 40 | ||
fn_call_width = 40 | ||
|
||
# unstable features: require nightly | ||
# call using `cargo +nightly fmt` | ||
wrap_comments = true | ||
combine_control_expr = false | ||
group_imports = "StdExternalCrate" | ||
imports_layout = "Vertical" | ||
imports_granularity = "Crate" | ||
normalize_doc_attributes = true | ||
reorder_impl_items = true | ||
condense_wildcard_suffixes = true | ||
force_multiline_blocks = true | ||
format_macro_matchers = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,56 @@ | ||
//! Contains everything for depicting the grid onto the canvas. | ||
use wasm_bindgen::JsValue; | ||
use web_sys::CanvasRenderingContext2d; | ||
|
||
/// Draws the grid onto the canvas based on the given screen size and grid | ||
/// square size. This should be called before anything else is drawn, so the | ||
/// grid is in the background. | ||
pub fn draw_grid(canvas: &CanvasRenderingContext2d, size: (u32, u32), square_size: u32) { | ||
canvas.begin_path(); | ||
canvas.set_line_width(1.0); | ||
canvas.set_stroke_style(&JsValue::from_str("grey")); | ||
|
||
draw_vertical_lines(canvas, size.0, square_size, size.1 / square_size); | ||
draw_horizontal_lines(canvas, size.1, square_size, size.0 / square_size); | ||
draw_vertical_lines( | ||
canvas, | ||
size.0, | ||
square_size, | ||
size.1 / square_size, | ||
); | ||
draw_horizontal_lines( | ||
canvas, | ||
size.1, | ||
square_size, | ||
size.0 / square_size, | ||
); | ||
|
||
canvas.stroke(); | ||
} | ||
|
||
/// Draw all vertical grid lines | ||
fn draw_vertical_lines( | ||
canvas: &CanvasRenderingContext2d, | ||
length: u32, | ||
square_size: u32, | ||
count: u32, | ||
) { | ||
for i in 0..count { | ||
let x = (i * square_size + square_size) as f64; | ||
let x = f64::from(i * square_size + square_size); | ||
canvas.move_to(x, 0.0); | ||
canvas.line_to(x, length as f64); | ||
canvas.line_to(x, f64::from(length)); | ||
} | ||
} | ||
|
||
/// Draw all horizontal grid lines | ||
fn draw_horizontal_lines( | ||
canvas: &CanvasRenderingContext2d, | ||
length: u32, | ||
square_size: u32, | ||
count: u32, | ||
) { | ||
for i in 0..count { | ||
let y = (i * square_size + square_size) as f64; | ||
let y = f64::from(i * square_size + square_size); | ||
canvas.move_to(0.0, y); | ||
canvas.line_to(length as f64, y); | ||
canvas.line_to(f64::from(length), y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.