it's happening
This commit is contained in:
parent
210a6cfb64
commit
200e4b4cb7
@ -267,60 +267,69 @@ pub fn smiley(id: Uuid) -> Result<Uuid, Error> {
|
|||||||
let l_dist = Normal::new(50.0, 10.0);
|
let l_dist = Normal::new(50.0, 10.0);
|
||||||
let s_dist = Normal::new(50.0, 20.0);
|
let s_dist = Normal::new(50.0, 20.0);
|
||||||
|
|
||||||
|
// let stroke_width = rng.gen_range(1, 3);
|
||||||
|
let stroke_width = 3;
|
||||||
|
|
||||||
|
// basic layout is 200x200 box w/ 100 padding
|
||||||
|
// 2:1 for each x,y
|
||||||
|
|
||||||
|
// left eye is at 0,0
|
||||||
|
// 50W 25H
|
||||||
let eyes_left = [
|
let eyes_left = [
|
||||||
("M50,800 L300,550 L550,800", 1), // ^
|
("M0,0 L25,25 L50,0", 1), // v
|
||||||
("M50,550 L300,800 L550,550", 1), // v
|
("M0,25 L25,0 L50,25", 1), // ^
|
||||||
("M50,550 L300,800 L550,550", 1), // v
|
("M0,0 L50,0", 1), // -
|
||||||
|
("M0,25 L50,25", 1), // _
|
||||||
|
("M0,0 L50,25 M50,0 L0,25", 1), // x
|
||||||
|
("M0,0 L50,12.5 L0,25", 1), // >
|
||||||
|
("M50,0 L0,12.5 L50,25", 1), // <
|
||||||
];
|
];
|
||||||
let eye_left_dist = WeightedIndex::new(eyes_left.iter().map(|v| v.1))?;
|
let eye_left_dist = WeightedIndex::new(eyes_left.iter().map(|v| v.1))?;
|
||||||
|
|
||||||
|
// right eye is 150,0
|
||||||
|
// 50W 25H
|
||||||
let eyes_right = [
|
let eyes_right = [
|
||||||
("M1550,800 L1800,550 L2050,800", 1), // ^
|
("M150,0 L175,25 L200,0", 1), // v
|
||||||
("M1550,550 L1800,800 L2050,550", 1), // v
|
("M150,25 L175,0 L200,25", 1), // ^
|
||||||
("M1550,550 L1800,800 L2050,550", 1), // v
|
("M150,0 L200,0", 1), // -
|
||||||
|
("M150,25 L200,25", 1), // -
|
||||||
|
("M150,0 L200,25 M200,0 L150,25", 1), // x
|
||||||
|
("M150,0 L200,12.5 L150,25", 1), // >
|
||||||
|
("M200,0 L150,12.5 L200,25", 1), // <
|
||||||
];
|
];
|
||||||
let eye_right_dist= WeightedIndex::new(eyes_right.iter().map(|v| v.1))?;
|
let eye_right_dist= WeightedIndex::new(eyes_right.iter().map(|v| v.1))?;
|
||||||
|
|
||||||
|
// mouth is 50,75
|
||||||
|
// 100W 25H
|
||||||
let mouths = [
|
let mouths = [
|
||||||
("M550,1800 L1550,1800", 1), // ^
|
("M50,100 L150,100", 1), // _
|
||||||
|
("M50,75 L150,75 L150,100 L50,100 L50,75", 1), // box
|
||||||
|
("M50,75 L75,100 L100,75 L125,100 L150,75", 1), // w
|
||||||
|
("M50,75 L75,75 L75,87.5 M75,75 L125,75 L125,87.5 M125,75 L150,75", 1), // vamp
|
||||||
|
("M75,75 L125,75 L125,100 L75,100 L75,75", 1), // o
|
||||||
];
|
];
|
||||||
let mouth_dist = WeightedIndex::new(mouths.iter().map(|v| v.1))?;
|
let mouth_dist = WeightedIndex::new(mouths.iter().map(|v| v.1))?;
|
||||||
|
|
||||||
// basic layout is 2000x2000 box w/ 50 padding
|
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='-50 -100 300 300' width='200' height='200'><g>")?;
|
||||||
// 2:1 for each x,y
|
|
||||||
|
|
||||||
// left eye is top left
|
|
||||||
// x = 50 left padding + point offset
|
|
||||||
// y = 750 + 50 top padding + point offset
|
|
||||||
|
|
||||||
// right eye is top right
|
|
||||||
// x = 50 left padding + 1500 + point offset
|
|
||||||
// y = 50 top padding + point offset
|
|
||||||
|
|
||||||
// mouth is bottom centre
|
|
||||||
// x = 50 + 500 + xoffset
|
|
||||||
// y = 50 + 750 + yoffset
|
|
||||||
|
|
||||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='0 0 2100 2100'><g>")?;
|
|
||||||
|
|
||||||
let left_eye_path = eyes_left[eye_left_dist.sample(&mut rng)].0;
|
let left_eye_path = eyes_left[eye_left_dist.sample(&mut rng)].0;
|
||||||
|
|
||||||
// left eye
|
// left eye
|
||||||
write!(&mut svg,
|
write!(&mut svg,
|
||||||
"<path fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"30px\" d=\"{:}\" />",
|
"<path fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"{:}px\" d=\"{:}\" />",
|
||||||
left_eye_path)?;
|
stroke_width, left_eye_path)?;
|
||||||
|
|
||||||
let right_eye_path = eyes_right[eye_right_dist.sample(&mut rng)].0;
|
let right_eye_path = eyes_right[eye_right_dist.sample(&mut rng)].0;
|
||||||
// right eye
|
// right eye
|
||||||
write!(&mut svg,
|
write!(&mut svg,
|
||||||
"<path fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"30px\" d=\"{:}\" />",
|
"<path fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"{:}px\" d=\"{:}\" />",
|
||||||
right_eye_path)?;
|
stroke_width, right_eye_path)?;
|
||||||
|
|
||||||
let mouth_path = mouths[mouth_dist.sample(&mut rng)].0;
|
let mouth_path = mouths[mouth_dist.sample(&mut rng)].0;
|
||||||
// mouth
|
// mouth
|
||||||
write!(&mut svg,
|
write!(&mut svg,
|
||||||
"<path fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"30px\" d=\"{:}\" />",
|
"<path fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"{:}px\" d=\"{:}\" />",
|
||||||
mouth_path)?;
|
stroke_width, mouth_path)?;
|
||||||
|
|
||||||
write!(&mut svg, "</g></svg>")?;
|
write!(&mut svg, "</g></svg>")?;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user