{"id":20400332,"url":"https://github.com/fschutt/marching-squares","last_synced_at":"2025-09-24T02:32:25.546Z","repository":{"id":57636669,"uuid":"258505907","full_name":"fschutt/marching-squares","owner":"fschutt","description":"Parallelized marching squares algorithm for constructing closed isolines / contour lines","archived":false,"fork":false,"pushed_at":"2020-04-24T21:18:15.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-15T04:39:27.751Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fschutt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-24T12:26:44.000Z","updated_at":"2024-08-29T16:36:32.000Z","dependencies_parsed_at":"2022-08-30T10:30:35.782Z","dependency_job_id":null,"html_url":"https://github.com/fschutt/marching-squares","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fschutt%2Fmarching-squares","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fschutt%2Fmarching-squares/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fschutt%2Fmarching-squares/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fschutt%2Fmarching-squares/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fschutt","download_url":"https://codeload.github.com/fschutt/marching-squares/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234029362,"owners_count":18768451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T04:39:37.023Z","updated_at":"2025-09-24T02:32:20.235Z","avatar_url":"https://github.com/fschutt.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# marching-squares\n\nThis crate provides an (optionally parallelizable)\nmarching squares algorithm to generate isolines from\na heightmap of `Vec\u003cVec\u003ci16\u003e\u003e` values.\n\nAdapted from [https://github.com/d-dorazio/marching-squares](https://github.com/d-dorazio/marching-squares)\n\n## Warning\n\n- The returned lines may only have two points.\n\n## Example\n\n```rust\nuse marching_squares::{Field, Point};\n\nfn main() {\n\n    let width = 1600_usize;\n    let height = 1600_usize;\n\n    let n_steps = 10_usize;\n    let mut min_val = 0;\n    let mut max_val = 0;\n\n    // Build the heightmap data (here: randomly generated from a function)\n    let z_values = (0..height).map(|y| {\n        (0..width).map(|x| {\n            let x = (x as f64 - width as f64 / 2.0) / 150.0;\n            let y = (y as f64 - height as f64 / 2.0) / 150.0;\n            let val = ((1.3 * x).sin() * (0.9 * y).cos() + (0.8 * x).cos() * (1.9 * y).sin() + (y * 0.2 * x).cos()) as i16;\n            min_val = min_val.min(val);\n            max_val = max_val.max(val);\n            val\n        }).collect()\n    }).collect::\u003cVec\u003cVec\u003ci16\u003e\u003e\u003e();\n\n    let field = Field {\n        dimensions: (width, height),\n        top_left: Point { x: 0.0, y: 0.0 },\n        pixel_size: (1.0, 1.0),\n        values: \u0026z_values,\n    };\n\n    let step_size = (max_val - min_val) as f32 / n_steps as f32;\n\n    // Generate 10 isolines\n    // note: you could do this in parallel using rayon\n    for step in 0..n_steps {\n        let isoline_height = min_val as f32 + (step_size * step as f32);\n        println!(\"{:#?}\", field.get_contours(isoline_height as i16));\n    }\n}\n```\n\nLicense: MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffschutt%2Fmarching-squares","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffschutt%2Fmarching-squares","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffschutt%2Fmarching-squares/lists"}