Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Path2D getWidth() property — Gideros Forum

Path2D getWidth() property

totebototebo Member
edited February 2016 in General questions
I've noticed Path2D returning 0 in width and height when using the Sprite inherited property. Is there another way to get the width and height of the Path?
local p=Path2D.new()
local ms="MLLLLZ"
local mp={0,0, 100,0, 100,100, 0,100, 0,0}
p:setPath(ms,mp)
p:setLineThickness(5) 
p:setPosition(100,100)
stage:addChild(p)
 
print(p:getWidth()) -- Returns: 0
My Gideros games: www.totebo.com

Comments

  • Did you try getBounds()?
  • Aha, thought I'd read about it before. So getBounds() is the one to use?
    My Gideros games: www.totebo.com
  • totebototebo Member
    edited February 2016
    While I'm at it, I don't fully understand the "MLLLLZ" bit.

    If you need a coordinate for each "instruction", why does this work:
    local ms="MLLLLZ" -- 5 coordinates, 6 instructions
    local mp={0,0, 100,0, 100,100, 0,100, 0,0}
    And not this:
    local ms="MLLLZ"  -- 5 coordinates, 5 instructions
    local mp={0,0, 100,0, 100,100, 0,100, 0,0}
    Is it because Z simply closes the last and first coordinate, and so doesn't need coordinates itself?
    My Gideros games: www.totebo.com
  • hgy29hgy29 Maintainer
    Accepted Answer
    Nope, sorry getBounds() won't work either. I guess it makes Path2D unusable for now in some situations until next gideros release.

    For instructions and coordinates: coordinates count must match exactly what the instructions need. M and L need one coordinate, but Z doesn't need any. Here is a quick summary:
    - M,L: 2 values (x,y)
    - Q: 4 values (cx,cy,x,y)
    - C: 6 values (c0x,c0y,c1x,c1y,x,y)
    - Z: 0 values
    - H,V: 1 value (x or y)
    - A: 7 values (r1,r2,angle,largeArc,sweep,x,y)

    Likes: totebo

    +1 -1 (+1 / -0 )Share on Facebook
  • Great, thanks for the explanation! Look forward to the next release.
    My Gideros games: www.totebo.com
Sign In or Register to comment.