diff --git a/src/abr.cpp b/src/abr.cpp index 930ae2d..2041118 100644 --- a/src/abr.cpp +++ b/src/abr.cpp @@ -107,14 +107,17 @@ std::vector> ABR::compute_brushes(const std::string& path for (auto const& p : m_presets) { auto samp = p->get("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(); b->m_name = wstr2str(p->value("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("Rndn") * 0.01) * 0.5f + 0.5f; @@ -127,13 +130,28 @@ std::vector> ABR::compute_brushes(const std::string& path b->m_tip_noise = (float)samp->value("Nose"); // brush sample - auto tip_uid = wstr2str(samp->value("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("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("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("Txtr")) diff --git a/src/canvas_modes.cpp b/src/canvas_modes.cpp index 00302e2..b0245a7 100644 --- a/src/canvas_modes.cpp +++ b/src/canvas_modes.cpp @@ -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); diff --git a/src/node_panel_stroke.cpp b/src/node_panel_stroke.cpp index 112d934..b0b36f9 100644 --- a/src/node_panel_stroke.cpp +++ b/src/node_panel_stroke.cpp @@ -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);