Correctly draw vector text for constraints free in 3d.

This commit is contained in:
whitequark 2016-08-13 10:48:48 +00:00
parent efd358d734
commit 4c30c09792
7 changed files with 10 additions and 3 deletions

View File

@ -437,7 +437,7 @@ void Constraint::DoArcForAngle(Canvas *canvas, Canvas::hStroke hcs,
Vector trans = Vector trans =
(*ref).Plus(gu.ScaledBy(-1.5*VectorFont::Builtin()->GetCapHeight(textHeight))); (*ref).Plus(gu.ScaledBy(-1.5*VectorFont::Builtin()->GetCapHeight(textHeight)));
canvas->DrawVectorText("angle between skew lines", textHeight, canvas->DrawVectorText("angle between skew lines", textHeight,
trans, gr.WithMagnitude(pixels), gu.WithMagnitude(pixels), trans, gr.WithMagnitude(1), gu.WithMagnitude(1),
hcs); hcs);
} }
} }
@ -925,7 +925,8 @@ void Constraint::DoLayout(DrawAs how, Canvas *canvas,
} }
Vector ex = VectorFont::Builtin()->GetExtents(textHeight, "T"); Vector ex = VectorFont::Builtin()->GetExtents(textHeight, "T");
canvas->DrawVectorText("T", textHeight, textAt.Minus(ex.ScaledBy(0.5)), u, v, hcs); canvas->DrawVectorText("T", textHeight, textAt.Minus(ex.ScaledBy(0.5)),
u.WithMagnitude(1), v.WithMagnitude(1), hcs);
if(refs) refs->push_back(textAt); if(refs) refs->push_back(textAt);
return; return;
} }
@ -1122,7 +1123,8 @@ s:
} }
Vector o = m.Plus(offset).Plus(u.WithMagnitude(textHeight/5)), Vector o = m.Plus(offset).Plus(u.WithMagnitude(textHeight/5)),
ex = VectorFont::Builtin()->GetExtents(textHeight, s); ex = VectorFont::Builtin()->GetExtents(textHeight, s);
canvas->DrawVectorText(s, textHeight, o.Minus(ex.ScaledBy(0.5)), r, u, hcs); canvas->DrawVectorText(s, textHeight, o.Minus(ex.ScaledBy(0.5)),
r.WithMagnitude(1), u.WithMagnitude(1), hcs);
if(refs) refs->push_back(o); if(refs) refs->push_back(o);
} else { } else {
Vector a = SK.GetEntity(ptA)->PointGetNum(); Vector a = SK.GetEntity(ptA)->PointGetNum();

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

View File

@ -47,3 +47,8 @@ TEST_CASE(reference_free_in_3d_migrate_from_v20) {
CHECK_RENDER("reference_free_in_3d.png"); CHECK_RENDER("reference_free_in_3d.png");
CHECK_SAVE("reference_free_in_3d.slvs"); CHECK_SAVE("reference_free_in_3d.slvs");
} }
TEST_CASE(skew_render) {
CHECK_LOAD("skew.slvs");
CHECK_RENDER("skew.png");
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB