GraphicsPath axis offset?

  1. 5 days ago

    Craig J

    Jun 28 Boulder, Colorado

    I must be missing something but whenever I try to use a GraphicsPath object, it wants to set y=0 exactly halfway down the canvas. I don't see this documented anywhere, but I don't see anybody complaining about it either, which makes me wonder if there is somewhere something I've set wrong somehow.

    Anyways, simply code in a canvas paint method:

    Var gp As New GraphicsPath
    
    g.AntiAlias = True
    //some regular lines
    g.DrawingColor = &cffffff
    g.FillRectangle(5,5,g.Width-10,g.Height-10)
    g.DrawingColor = &c000000
    g.DrawLine(g.Width/2,0,g.Width/2,g.Height)
    g.DrawLine(0,g.Height/2,g.Width,g.Height/2)
    
    //some lines that should be...elsewhere
    g.DrawingColor = &ccc1233
    gp.MoveToPoint(0,0)
    gp.AddLineToPoint(g.width,0)
    gp.AddLineToPoint(g.width,g.Height)
    gp.AddLineToPoint(g.width/2,-g.height/2)
    g.DrawPath gp
    
    //and a rectangle that should outline the fill rectangle above, but doesn't (for me).
    var g2 as new GraphicsPath
    g2.AddRectangle(5,5,g.Width-10,g.Height-10)
    g.DrawingColor=&cFFAAAA
    g.DrawPath g2

    Yields the black lines from the DrawLine calls right in the middle as expected and the filled rectangle inset 5 pixels from all sides, but then the GraphicsPath objects are all halfway down the window.

    -image-

    I presume there is something stupid I have missed, either a document describing this...um, unique... coordinate system, or I have something somewhere that influences GraphicsPaths all on their own. Mac OS Mojave, Xojo 2019R3.1. Thanks for insights.

  2. Norman P

    Jun 28 Testers, Xojo Pro outside admiring the sunshine,...

    I'd say file a bug report as it definitely looks like something is wrong
    x=0, y=0 is at the left edge half way down which seems really wrong

    this is code to draw from the middle to all for corners of a canvas but it makes no sense

    Var gp As New GraphicsPath
    
    g.DrawingColor = &cFFFF0000
    
    gp.MoveToPoint(g.width/2,0)
    gp.AddLineToPoint(0,g.height/2)
    
    gp.MoveToPoint(g.width/2,0)
    gp.AddLineToPoint(0,-g.height/2)
    
    gp.MoveToPoint(g.width/2,0)
    gp.AddLineToPoint(g.width,-g.height/2)
    
    gp.MoveToPoint(g.width/2,0)
    gp.AddLineToPoint(g.width,g.height/2)
    
    g.DrawPath gp
  3. Craig J

    Jun 28 Boulder, Colorado

    Thanks for confirming I'm not insane.

    Bug report 60769 - Y-axis mislocated for GraphicsPath

  4. Markus R

    Jun 29 Testers, Xojo Pro Europe / Germany / Lower Saxon...

    seems mac specific

  5. 4 days ago

    Craig J

    Jun 29 Boulder, Colorado
    Edited 4 days ago

    Actually gets crazier. If I now embed this within a pretty standard print wrapper and save as pdf, the Y-axis ends up about 40 points below the regular y=0 position near the top of the page. But x=0 is the very edge of the page while the regular DrawLine calls are honoring margins. (The wrapper, from the reference, if anyone cares

    Var ps As New PrinterSetup
    If ps.ShowPageSetupDialog Then
      Var g As Graphics
      g = ps.ShowPrinterDialog()
      If g <> Nil Then
      (code as in original post)

    thought this was going to do nice things for me, but heading back to Object2D stuff while this gets sorted out...

or Sign Up to reply!