fix shapes img
This commit is contained in:
parent
6b545fd2c5
commit
8b1ddbc57e
@ -62,7 +62,7 @@ pub fn invader_write(id: Uuid) -> Result<Uuid, Error> {
|
||||
];
|
||||
let colour_dist = WeightedIndex::new(&weights)?;
|
||||
|
||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='-250 -250 1000 1000' width='375' height='375'><g>")?;
|
||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='-500 -500 1500 1500' width='375' height='375'><g>")?;
|
||||
for i in 0..50 {
|
||||
let x = (i % 5) * 50;
|
||||
let y = (i / 5) * 50;
|
||||
@ -103,7 +103,7 @@ pub fn shapes_write(id: Uuid) -> Result<Uuid, Error> {
|
||||
// distribution for lightness
|
||||
// bellcurve around 75%
|
||||
let l_dist = Normal::new(50.0, 10.0);
|
||||
let s_dist = Normal::new(75.0, 10.0);
|
||||
let s_dist = Normal::new(50.0, 20.0);
|
||||
|
||||
// 8 6 or 4 points in shape
|
||||
// 1 head point
|
||||
@ -124,7 +124,8 @@ pub fn shapes_write(id: Uuid) -> Result<Uuid, Error> {
|
||||
let shape_dist = WeightedIndex::new(shapes.iter().map(|v| v.1))?;
|
||||
|
||||
let n_shapes_items = [
|
||||
(2, 1),
|
||||
(1, 1),
|
||||
(2, 2),
|
||||
(3, 5),
|
||||
(4, 10),
|
||||
(5, 10),
|
||||
@ -132,7 +133,7 @@ pub fn shapes_write(id: Uuid) -> Result<Uuid, Error> {
|
||||
let num_dist = WeightedIndex::new(n_shapes_items.iter().map(|v| v.1))?;
|
||||
let n_shapes = num_dist.sample(&mut rng) as usize;
|
||||
|
||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='-500 -500 1000 1000' width='1000' height='1000'><g>")?;
|
||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='-250 -250 500 500' width='1000' height='1000'><g>")?;
|
||||
for i in 0..n_shapes + 1 {
|
||||
let h = rng.gen_range(0, 360);
|
||||
let s = s_dist.sample(&mut rng) as usize;
|
||||
@ -203,6 +204,7 @@ pub fn shapes_write(id: Uuid) -> Result<Uuid, Error> {
|
||||
write!(&mut svg, "</g></svg>")?;
|
||||
|
||||
let dest = format!("/var/lib/mnml/public/imgs/{}.svg", id);
|
||||
println!("/var/lib/mnml/public/imgs/{}.svg", id);
|
||||
|
||||
let mut file = File::create(dest)?;
|
||||
file.write_all(&svg)?;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user