Skip to content

Commit

Permalink
Add radial grids (#177)
Browse files Browse the repository at this point in the history
Closes #172
Closes #178

Intended use is for a more interesting grid for use in asemic writing.

* [ ] (deferred to #6 and #179) Add `simplify` (and `densify`) tool
* [ ] (deferred to #180) Add generic `rhai` script to `transform` tool
* [x] Generate radial grid in x,y in `grid` tool
* [x] Make `--output-format=lines` output the rings as `POLYGON`s, so
that `smooth` smooths just them, and not the radial spokes.
  * [x] Maybe tunable enough that it should be its own `radial` tool?
  • Loading branch information
Notgnoshi committed May 26, 2024
2 parents 5b2d874 + 330bc75 commit 65ebe81
Show file tree
Hide file tree
Showing 12 changed files with 404 additions and 81 deletions.
4 changes: 2 additions & 2 deletions generative/io/wkt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use log::warn;
use wkb::{geom_to_wkb, wkb_to_geom, write_geom_to_wkb};
use wkt::{ToWkt, Wkt};

#[derive(Debug, Clone, ValueEnum)]
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum GeometryFormat {
/// One WKT geometry per line. Ignores trailing garbage; does not skip over leading garbage.
Wkt,
Expand Down Expand Up @@ -168,7 +168,7 @@ where
}
}

pub fn write_geometries<W, G>(writer: W, geometries: G, format: &GeometryFormat)
pub fn write_geometries<W, G>(writer: W, geometries: G, format: GeometryFormat)
where
W: Write,
G: IntoIterator<Item = Geometry<f64>>,
Expand Down
10 changes: 5 additions & 5 deletions tools/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn expression(engine: &Engine, ast: &AST, x: i64, y: i64) -> Result<i64, Box<Eva
engine.eval_ast_with_scope::<i64>(&mut scope, ast)
}

fn write_line<W>(writer: W, format: &GeometryFormat, x1: i64, y1: i64, x2: i64, y2: i64)
fn write_line<W>(writer: W, format: GeometryFormat, x1: i64, y1: i64, x2: i64, y2: i64)
where
W: Write,
{
Expand All @@ -79,7 +79,7 @@ where
write_geometries(writer, geometries, format);
}

fn write_point<W>(writer: W, format: &GeometryFormat, x1: i64, y1: i64)
fn write_point<W>(writer: W, format: GeometryFormat, x1: i64, y1: i64)
where
W: Write,
{
Expand Down Expand Up @@ -163,7 +163,7 @@ fn main() -> Result<(), Box<EvalAltResult>> {
None
});

write_geometries(writer, geometries, &args.output_format);
write_geometries(writer, geometries, args.output_format);
} else {
log::info!(
"Searching neighbors in order: {:?}",
Expand All @@ -175,13 +175,13 @@ fn main() -> Result<(), Box<EvalAltResult>> {
for n in args.neighbor_search_order.iter() {
let (x2, y2) = neighbor(x, y, n.clone());
if expression(&engine, &ast, x2, y2)? > 0 {
write_line(&mut writer, &args.output_format, x, y, x2, y2);
write_line(&mut writer, args.output_format, x, y, x2, y2);
wrote_line = true;
break;
}
}
if !wrote_line {
write_point(&mut writer, &args.output_format, x, y);
write_point(&mut writer, args.output_format, x, y);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tools/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ fn main() {
let geometries = std::iter::once(geo::Geometry::GeometryCollection(bundle));

let writer = get_output_writer(&args.output).unwrap();
write_geometries(writer, geometries, &args.output_format);
write_geometries(writer, geometries, args.output_format);
}
2 changes: 1 addition & 1 deletion tools/geom2graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ fn main() {
Box::new(geometries)
};

write_geometries(writer, geometries, &args.geometry_format);
write_geometries(writer, geometries, args.geometry_format);
}
}
Loading

0 comments on commit 65ebe81

Please sign in to comment.