import computedBrush from ABR
This commit is contained in:
34
src/abr.cpp
34
src/abr.cpp
@@ -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"))
|
||||
|
||||
@@ -225,8 +225,7 @@ void CanvasModePen::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const
|
||||
const auto& s = Canvas::I->m_current_stroke->m_prev_sample;
|
||||
if (s.size > 0.f)
|
||||
{
|
||||
tip_scale = glm::vec2(brush->m_tip_width, 1.f) *
|
||||
(brush->m_tip_size * tip_scale_fix) * s.scale;
|
||||
tip_scale = (brush->m_tip_size * tip_scale_fix) * s.scale;
|
||||
tip_angle = s.angle;
|
||||
tip_offset = s.pos - s.origin;
|
||||
tip_color = glm::vec4(s.col, s.flow);
|
||||
|
||||
@@ -101,6 +101,17 @@ bool NodePanelStroke::import_abr(const std::string& path)
|
||||
thumb.save(path_thumb);
|
||||
|
||||
async_start();
|
||||
NodeButtonBrush* brush = new NodeButtonBrush;
|
||||
m_pattern_popup->m_container->add_child(brush);
|
||||
brush->init();
|
||||
brush->create();
|
||||
brush->loaded();
|
||||
brush->set_icon(path_thumb.c_str());
|
||||
brush->thumb_path = path_thumb;
|
||||
brush->high_path = path_high;
|
||||
brush->brush_name = name;
|
||||
brush->m_user_brush = true;
|
||||
brush->on_click = std::bind(&NodePanelBrush::handle_click, m_pattern_popup, std::placeholders::_1);
|
||||
count++;
|
||||
float prog = (float)count / (float)tot;
|
||||
pb->m_progress->SetWidthP(prog * 100.f);
|
||||
|
||||
Reference in New Issue
Block a user