otfried / ipe

The Ipe extensible drawing editor
http://ipe.otfried.org
125 stars 9 forks source link

Lua: Text Properties #481

Closed thobl closed 1 month ago

thobl commented 9 months ago

The documentation of Attributes/Properties (https://ipe.otfried.org/ipelib/luaobj.html) does not seem to match the actual behavior.

Specifically, the following code works:

local text = ipe.Text(
   {horizontalalignment="hcenter", 
    verticalalignment="vcenter"},
   "some text", ipe.Vector(0, 0))
text:set("transformations", "affine")

Judging from the documentation, the following should have the same effect, but it does not set the transformations to affine.

local text = ipe.Text(
   {horizontalalignment="hcenter", 
    verticalalignment="vcenter", 
    transformations="affine"},
   "some text", ipe.Vector(0, 0))

Also, the names for the alignment attributes in the documentation are horizontalAlignment/verticalAlignment and not horizontalalignment/verticalalignment (the latter works, the former does not).

otfried commented 1 month ago

The attributes in the constructor reflect the environment set in Ipe when creating objects. Text is by default not transformable, even if everything else is - to make it transformable, you also need to set transformabletext. So the following should work:

local text = ipe.Text(
   {horizontalalignment="hcenter", 
    verticalalignment="vcenter", 
    transformabletext=true,
    transformations="affine"},
   "some text", ipe.Vector(0, 0))

I've fixed the misspelled attribute names in the documentation - thanks!