04-08-2017, 12:19 PM
(This post was last modified: 04-09-2017, 06:59 AM by Rick Johnson.)
Following C code that's worked perfectly to reset a pattern's transformations, I did the CORE equivalent when iterating through an artVector. I'm reporting this as a bug because although there's no indication to that effect in the header notes, Xcode tells me the four marked properties are "not assignable:"
I could, of course, mix SDK with CORE, but I'd really rather not make a patchwork of two libraries, and I figured if this wasn't the behavior you had intended, you'd want to fix it.
In doing more experiments to try to understand the unexpected behaviors of matrices in CORE, I added several std::cout statements and found this:
Shouldn't tx be 0 rather than 128? Running the same code again, tx is usually the inverse double but, I might also get this:
matrix inverted = -0 128 1 -0 -0 1
matrix transformed = 0 -146.358 1 0 0 1
matrix set to identity = 0 -146.358 1 0 0 1
This code, however, works as expected:
Thanks! -- Rick
Code:
// switch (hdi::core::ArtType typ) {
case hdi::core::ArtTypePath:{
hdi::core::PathStyle pStyl = (*iter)->path()->style();
if (pStyl.fill.color.colorType() == hdi::core::ArtColor::TypePattern){
pStyl.fill.color.pattern().transform.setIdentity(); // <====== see more notes below
pStyl.fill.color.pattern().shiftDistance = 0.0; // <========= won't assign value
pStyl.fill.color.pattern().shiftAngle = hdi::core::Angle::Zero();
pStyl.fill.color.pattern().scaleX = 1.0; // <=========== won't assign value
pStyl.fill.color.pattern().scaleY = 1.0; // <============= won't assign value
pStyl.fill.color.pattern().rotation = 0.0;
pStyl.fill.color.pattern().reflect = false; // <============ won't assign value
pStyl.fill.color.pattern().reflectAngle = 0.0;
pStyl.fill.color.pattern().shearAngle = 0.0;
pStyl.fill.color.pattern().shearAxis = 0.0;
(*iter)->path()->setStyle(pStyl);
{
I could, of course, mix SDK with CORE, but I'd really rather not make a patchwork of two libraries, and I figured if this wasn't the behavior you had intended, you'd want to fix it.
In doing more experiments to try to understand the unexpected behaviors of matrices in CORE, I added several std::cout statements and found this:
Code:
hdi::core::TransformMatrix tmx = (*iter)->path()->style().fill.color.pattern().transform;
// original matrix tmx = tx ty a b c d: 0 -64 1 0 0 1
if (pStyl.fill.color.pattern().transform.invert(tmx)){
// inverted matrix = -0 64 1 -0 -0 1
(*iter)->transformWithOptions(tmx, hdi::core::Art::TransformOptionFillPatterns);
// transformed matrix = 0 -128 1 0 0 1, expected to see 0 0 1 0 0 1
(*iter)->path()->style().fill.color.pattern().transform.setIdentity();
// matrix set to identity = 0 -128 1 0 0 1
}
Shouldn't tx be 0 rather than 128? Running the same code again, tx is usually the inverse double but, I might also get this:
matrix inverted = -0 128 1 -0 -0 1
matrix transformed = 0 -146.358 1 0 0 1
matrix set to identity = 0 -146.358 1 0 0 1
This code, however, works as expected:
Code:
tmx.concatTranslate(h,v);
(*iter)->transformWithOptions(tmx, hdi::core::Art::TransformOptionFillPatterns);
Thanks! -- Rick