import dual brush from abr
This commit is contained in:
103
src/abr.cpp
103
src/abr.cpp
@@ -124,10 +124,10 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
|
||||
b->m_tip_size = samp->value<UnitFloat>("Dmtr");
|
||||
b->m_tip_spacing = samp->value<UnitFloat>("Spcn") * 0.01f;
|
||||
b->m_tip_angle = samp->value<UnitFloat>("Angl") / 360.f + 0.5f; // [-180, 180] -> [0, 1]
|
||||
//b->m_tip_mix = i.m_tip_mix;
|
||||
//b->m_tip_stencil = i.m_tip_stencil;
|
||||
b->m_tip_wet = p->value<UnitFloat>("Wtdg");
|
||||
b->m_tip_noise = (float)samp->value<UnitFloat>("Nose");
|
||||
b->m_tip_noise = samp->value<UnitFloat>("Nose");
|
||||
b->m_tip_flipx = samp->value<Boolean>("flipX");
|
||||
b->m_tip_flipy = samp->value<Boolean>("flipY");
|
||||
|
||||
// brush sample
|
||||
if (samp->class_id == "sampledBrush")
|
||||
@@ -153,6 +153,20 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> modes = {
|
||||
"normal", // normal (not in Photoshop)
|
||||
"Mltp", // multiply
|
||||
"Sbtr", // subtract
|
||||
"Drkn", // darken
|
||||
"Ovrl", // overlay
|
||||
"CDdg", // color dodge
|
||||
"CBrn", // color burn
|
||||
"linearBurn", // linear burn
|
||||
"hardMix", // hard mix
|
||||
"linearHeight", // linear height
|
||||
"Hght", // height
|
||||
};
|
||||
|
||||
// pattern
|
||||
if (auto patt = p->get<Descriptor>("Txtr"))
|
||||
{
|
||||
@@ -171,25 +185,80 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
|
||||
|
||||
// blending mode
|
||||
std::string blend_mode = p->value<Enum>("textureBlendMode");
|
||||
std::vector<std::string> modes = {
|
||||
"normal", // normal (not in Photoshop)
|
||||
"Mltp", // multiply
|
||||
"Sbtr", // subtract
|
||||
"Drkn", // darken
|
||||
"Ovrl", // overlay
|
||||
"CDdg", // color dodge
|
||||
"CBrn", // color burn
|
||||
"linearBurn", // linear burn
|
||||
"hardMix", // hard mix
|
||||
"linearHeight", // linear height
|
||||
"Hght", // height
|
||||
};
|
||||
auto bm_it = std::find(modes.begin(), modes.end(), blend_mode);
|
||||
if (bm_it != modes.end())
|
||||
b->m_pattern_blend_mode = std::distance(modes.begin(), bm_it);
|
||||
|
||||
b->m_pattern_enabled = true;
|
||||
b->m_pattern_enabled = p->value<Boolean>("useTexture");
|
||||
}
|
||||
|
||||
// dual brush
|
||||
if (auto db = p->get<Descriptor>("dualBrush"))
|
||||
{
|
||||
auto samp = db->get<Descriptor>("Brsh");
|
||||
if (samp->class_id != "sampledBrush" && samp->class_id != "computedBrush")
|
||||
{
|
||||
LOG("unsupported brush type %s", samp->class_id.c_str());
|
||||
continue;
|
||||
}
|
||||
//b->m_name = wstr2str(p->value<String>("Nm "));
|
||||
|
||||
// default values
|
||||
//b->m_tip_color = { 0, 0, 0, 1 };
|
||||
b->m_dual_flow = .90f;
|
||||
b->m_dual_opacity = 1.f;
|
||||
|
||||
//b->m_tip_aspect = (1.f - samp->value<UnitFloat>("Rndn") * 0.01) * 0.5f + 0.5f;
|
||||
b->m_dual_size = samp->value<UnitFloat>("Dmtr");
|
||||
b->m_dual_spacing = samp->value<UnitFloat>("Spcn") * 0.01f;
|
||||
//b->m_tip_angle = samp->value<UnitFloat>("Angl") / 360.f + 0.5f; // [-180, 180] -> [0, 1]
|
||||
//b->m_tip_wet = p->value<UnitFloat>("Wtdg");
|
||||
//b->m_tip_noise = (float)samp->value<UnitFloat>("Nose");
|
||||
b->m_tip_flipx = samp->value<Boolean>("flipX");
|
||||
b->m_tip_flipy = samp->value<Boolean>("flipY");
|
||||
|
||||
b->m_dual_randflip = db->value<Boolean>("Flip");
|
||||
b->m_dual_scatter_axis = db->value<Boolean>("bothAxes");
|
||||
|
||||
if (db->value<Boolean>("useScatter"))
|
||||
{
|
||||
auto scatter = db->get<Descriptor>("scatterDynamics");
|
||||
b->m_dual_scatter = scatter->value<UnitFloat>("jitter");
|
||||
}
|
||||
|
||||
// brush sample
|
||||
if (samp->class_id == "sampledBrush")
|
||||
{
|
||||
auto tip_uid = wstr2str(samp->value<String>("sampledData"));
|
||||
b->m_dual_path = path + "/brushes/" + tip_uid + ".png";
|
||||
b->m_dual_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;
|
||||
}
|
||||
else if (samp->class_id == "computedBrush")
|
||||
{
|
||||
if (samp->value<UnitFloat>("Hrdn") > 50.f)
|
||||
{
|
||||
b->m_dual_path = "data/brushes/Round-Hard.png";
|
||||
b->m_dual_thumb_path = "data/brushes/thumbs/Round-Hard.png";
|
||||
}
|
||||
else
|
||||
{
|
||||
b->m_dual_path = "data/brushes/Round-Brush.png";
|
||||
b->m_dual_thumb_path = "data/brushes/thumbs/Round-Brush.png";
|
||||
}
|
||||
}
|
||||
|
||||
// blending mode
|
||||
std::string blend_mode = db->value<Enum>("BlnM");
|
||||
auto bm_it = std::find(modes.begin(), modes.end(), blend_mode);
|
||||
if (bm_it != modes.end())
|
||||
b->m_dual_blend_mode = std::distance(modes.begin(), bm_it);
|
||||
|
||||
b->m_dual_enabled = db->value<Boolean>("useDualBrush");
|
||||
}
|
||||
|
||||
ret.push_back(b);
|
||||
}
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user