Show parameters for thumbnail as table.

This commit is contained in:
Bill Thiede 2018-10-11 19:01:48 -07:00
parent 67ba66bdf7
commit fa7d79b112
3 changed files with 46 additions and 8 deletions

View File

@ -84,6 +84,22 @@ impl NoiseType {
),
}
}
fn parameters(&self) -> Vec<(&str, String)> {
match &self {
NoiseType::Scale(scale) => vec![("Scale", scale.to_string())],
NoiseType::Turbulence(turbulence) => vec![("Turbulence", turbulence.to_string())],
NoiseType::Marble {
period,
power,
size,
} => vec![
("Period", period.to_string()),
("Power", power.to_string()),
("Size", size.to_string()),
],
}
}
}
#[derive(Debug, Deserialize)]
@ -289,12 +305,17 @@ fn build_specimens(width: u32, height: u32) -> Vec<Specimen> {
}
specimens.push(specimen);
let mut specimen = Specimen {
title: "Varying Marble".into(),
params: Vec::new(),
};
for power in 1..10 {
for size in 1..6 {
let max_size = 8;
for power in 1..12 {
let mut specimen = Specimen {
title: format!(
"Marble power {}, varying size 2-{}",
power,
1 << (max_size - 1)
),
params: Vec::new(),
};
for size in 1..max_size {
let params = NoiseParams {
width,
height,
@ -306,7 +327,13 @@ fn build_specimens(width: u32, height: u32) -> Vec<Specimen> {
};
specimen.params.push(params);
}
specimens.push(specimen);
}
let mut specimen = Specimen {
title: "Marble varying power, size = 32".into(),
params: Vec::new(),
};
for power in 1..10 {
let params = NoiseParams {
width,

View File

@ -14,7 +14,13 @@
<a href="{{ np.big_url()|safe }}">
<img width="{{ np.width }}" height="{{ np.height }}" src="{{ np.url()|safe }}"/>
</a>
<figcaption>{{ np.compact_string() }}</figcaption>
<figcaption>
<table>
{% for p in np.noise.parameters() %}
<tr><th>{{ p.0 }}</th><td>{{ p.1 }}</td></tr>
{% endfor %}
</table>
</figcaption>
</figure>
{% endfor %}
{% endfor %}

View File

@ -5,6 +5,11 @@ figure p {
figure {
display: inline-block;
margin: 0.25em;
text-align: center;
font-size: smaller;
text-align: left;
line-height: .75em;
}
figure table tr th {
font-weight: bold;
}