import computedBrush from ABR

This commit is contained in:
2019-02-24 00:40:22 +01:00
parent 3a1a48a0d0
commit 4d5b64e5bc
3 changed files with 38 additions and 10 deletions

View File

@@ -107,14 +107,17 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
for (auto const& p : m_presets)
{
auto samp = p->get<Descriptor>("Brsh");
if (samp->class_id != "sampledBrush")
if (samp->class_id != "sampledBrush" && samp->class_id != "computedBrush")
{
LOG("unsupported brush type %s", samp->class_id.c_str());
continue;
}
auto b = std::make_shared<Brush>();
b->m_name = wstr2str(p->value<String>("Nm "));
// default values
b->m_tip_color = { 0, 0, 0, 1 };
b->m_tip_flow = .25f;
b->m_tip_flow = .90f;
b->m_tip_opacity = 1.f;
b->m_tip_aspect = (1.f - samp->value<UnitFloat>("Rndn") * 0.01) * 0.5f + 0.5f;
@@ -127,13 +130,28 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
b->m_tip_noise = (float)samp->value<UnitFloat>("Nose");
// brush sample
auto tip_uid = wstr2str(samp->value<String>("sampledData"));
LOG("tip uid %d %s", tip_uid.size(), tip_uid.c_str());
b->m_brush_path = path + "/brushes/" + tip_uid + ".png";
b->m_brush_thumb_path = path + "/brushes/thumbs/" + tip_uid + ".png";
if (samp->class_id == "sampledBrush")
{
auto tip_uid = wstr2str(samp->value<String>("sampledData"));
b->m_brush_path = path + "/brushes/" + tip_uid + ".png";
b->m_brush_thumb_path = path + "/brushes/thumbs/" + tip_uid + ".png";
const auto& samp_img = m_samples[tip_uid];
b->m_tip_width = (float)samp_img->width / (float)samp_img->height;
const auto& samp_img = m_samples[tip_uid];
b->m_tip_width = (float)samp_img->width / (float)samp_img->height;
}
else if (samp->class_id == "computedBrush")
{
if (samp->value<UnitFloat>("Hrdn") > 50.f)
{
b->m_brush_path = "data/brushes/Round-Hard.png";
b->m_brush_thumb_path = "data/brushes/thumbs/Round-Hard.png";
}
else
{
b->m_brush_path = "data/brushes/Round-Brush.png";
b->m_brush_thumb_path = "data/brushes/thumbs/Round-Brush.png";
}
}
// pattern
if (auto patt = p->get<Descriptor>("Txtr"))