faces
This commit is contained in:
parent
d8bad68216
commit
7f159f6914
@ -267,13 +267,24 @@ 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 eyes = [
|
let eyes_left = [
|
||||||
("50 800, 300 550, 550 800", 1),
|
("M50,800 L300,550 L550,800", 1), // ^
|
||||||
("50 550, 300 800, 550 550", 1),
|
("M50,550 L300,800 L550,550", 1), // v
|
||||||
|
("M50,550 L300,800 L550,550", 1), // v
|
||||||
];
|
];
|
||||||
let shape_dist = WeightedIndex::new(eyes.iter().map(|v| v.1))?;
|
let eye_left_dist = WeightedIndex::new(eyes_left.iter().map(|v| v.1))?;
|
||||||
|
|
||||||
|
let eyes_right = [
|
||||||
|
("M1550,800 L1800,550 L2050,800", 1), // ^
|
||||||
|
("M1550,550 L1800,800 L2050,550", 1), // v
|
||||||
|
("M1550,550 L1800,800 L2050,550", 1), // v
|
||||||
|
];
|
||||||
|
let eye_right_dist= WeightedIndex::new(eyes_right.iter().map(|v| v.1))?;
|
||||||
|
|
||||||
|
let mouths = [
|
||||||
|
("M550,1800 L1550,1800", 1), // ^
|
||||||
|
];
|
||||||
|
let mouth_dist = WeightedIndex::new(mouths.iter().map(|v| v.1))?;
|
||||||
|
|
||||||
// basic layout is 2000x2000 box w/ 50 padding
|
// basic layout is 2000x2000 box w/ 50 padding
|
||||||
// 2:1 for each x,y
|
// 2:1 for each x,y
|
||||||
@ -290,25 +301,25 @@ pub fn smiley(id: Uuid) -> Result<Uuid, Error> {
|
|||||||
// x = 50 + 500 + xoffset
|
// x = 50 + 500 + xoffset
|
||||||
// y = 50 + 750 + yoffset
|
// y = 50 + 750 + yoffset
|
||||||
|
|
||||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='0 0 2100 2100' width='2000' height='2000' background=\"black\" ><g>")?;
|
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='0 0 2100 2100'><g>")?;
|
||||||
|
|
||||||
let left_eye_path = "50 800, 300 550, 550 800";
|
let left_eye_path = eyes_left[eye_left_dist.sample(&mut rng)].0;
|
||||||
|
|
||||||
// left eye
|
// left eye
|
||||||
write!(&mut svg,
|
write!(&mut svg,
|
||||||
"<polyline fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"30px\" x=\"50\" y=\"50\" points=\"{:}\" />",
|
"<path fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"30px\" d=\"{:}\" />",
|
||||||
left_eye_path)?;
|
left_eye_path)?;
|
||||||
|
|
||||||
let right_eye_path = "1550 800, 1800 550, 2050 800";
|
let right_eye_path = eyes_right[eye_right_dist.sample(&mut rng)].0;
|
||||||
// right eye
|
// right eye
|
||||||
write!(&mut svg,
|
write!(&mut svg,
|
||||||
"<polyline fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"30px\" x=\"1550\" y=\"50\" points=\"{:}\" />",
|
"<path fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"30px\" d=\"{:}\" />",
|
||||||
right_eye_path)?;
|
right_eye_path)?;
|
||||||
|
|
||||||
let mouth_path = "550 1550, 1550 1550";
|
let mouth_path = mouths[mouth_dist.sample(&mut rng)].0;
|
||||||
// mouth
|
// mouth
|
||||||
write!(&mut svg,
|
write!(&mut svg,
|
||||||
"<polyline fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"30px\" x=\"550\" y=\"800\" points=\"{:}\" />",
|
"<path fill=\"none\" stroke=\"whitesmoke\" stroke-width=\"30px\" d=\"{:}\" />",
|
||||||
mouth_path)?;
|
mouth_path)?;
|
||||||
|
|
||||||
write!(&mut svg, "</g></svg>")?;
|
write!(&mut svg, "</g></svg>")?;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user