That 3rd vector has been my bugaboo all along. When I don’t use it, I get a graphics parameter. I’ll try again.
I’m having some success with your suggestions. For a canvas, this works. Thanks. But still very unclear how to move all this into a Picture.
That works. Thank you. What I was unable to see was how to use the “Objects” property. Maybe this is in the docs but I sure could never find it.
Again, I do appreciate the personal help. Softened a miserable evening after watching my fav bb team, Purdue, go down in flames to a #16 seed.
I will now go about rewriting code to get my original purpose accomplished: two puzzles on one page.
Original example:
Var o As New OvalShape
o.Width = 60
o.Height = 120
o.FillColor = RGB(127, 127, 255)
g.DrawObject(o, o.Width, o.Height)
You put that example in the Paint Event of a Canvas…
Now, the reworked example:
Var VectorPict As New Picture(300,300,0)
Var o As New OvalShape
o.Width = 60
o.Height = 120
o.FillColor = RGB(127, 127, 255)
VectorPict.Objects.AddObject(o)
cVector.Backdrop = VectorPict
cVector is a Canvas I placed in Window1.
The code is located in Window1.Open.
Is it clear now ?
What you may have missed is Objects; look carefully the line:
VectorPict.Objects.AddObject(o)
vs what the doc says:
g.DrawObject(o, o.Width, o.Height)
Is it clear now ?
PS: now, you have an object (the Picture I called VectorPict) you can use to draw on screen (as seen above) or print, or save, or… whatever.
Jeff beats me on that. I read back the whole thread and notice that right now.
Yes, this is precisely why the docs failed me. They kept using the g graphics of a canvas to illustrate never explaining — at least not anywhere I could find — how to use Objects in a vector-picture.
Thanks for clarifying.
Also, Emile solved it as well with a slightly different take. Both were very helpful.
This looks like a good answer except that the saving line “thepicture.Save(f,thepicture.SaveAsDefaultVector)” throws an “UnsupportedFormatException”. I rewrote this line for Xojo 2025 r1.1, but that should not have introduced the error, no? In the attached example, clicking the Draw button and then the Save button will show this.
vDraw.zip (5.8 KB)
I hope I am missing something. Did the picture vector format for saving get abandoned because theicture.Objects does not contain all the information needed to redraw the picture when it is reloaded from disk? For instance, the CurveShape does not contain the ControlX and ControlY information because these are not Properties of the CurveShape, they are Methods used to affect the bitmap and are not accessible.
In the example below the values 120 and -40 can’t be found in the picture.
Var testPic As Picture = New Picture(300,300,0)
Var c As New CurveShape
c.ControlX(0) = 120
c.ControlY(0) = -40
c.Order = 1
c.X = 10
c.Y = 100
c.X2 = 250
c.Y2 = 100
testPic.Objects.AddObject(c)
Var theCurveShape as Object2D = testPic.Objects.Item(0)
’ add more objects here
Break
On the other hand, "g.DrawObject(thePic.Objects.item(0),0,0) " in the Paint event of the Canvas only paints the curve and does faithfully recreate it. So, the ControlXY information is somewhere…
I’m pretty sure it stopped working because Apple helpfully dropped support for the PICT file format which was the picture format that supported vectors.
On Windows it would be EMF, and nobody really uses that any more, either.
SVG might help, but Xojo doesn’t support that, and it seems that world wide, the programming community couldn’t care less about having a transportable vector format.
Some would argue that PDF goes some way towards it, but some will then argue.. (watch the replies) ![]()
anyway
the values 120 and -40 can’t be found in the picture.
Why would they be? They are properties of the curveshape.
The curveshape is a property of the first object in Objects()
The objects can be grouped together into a Group2d object, and having the graphic draw that group will get all the objects draw in one command.
The Apple suggestion when they dropped PICT was to use PDF instead. Not that I would be able to find the documentation from that long ago.
Illustration definitely comes in a distant second place to text. SVG would be my choice.
I meant to include the CurveShape in that statement too. The ControlX and ControlY aren’t included in the property list of the CurveShape and I can’t find them elsewhere in the picture, but the CurveShape still knows it is curved when drawn by itself: g.DrawObject(thePic.Objects.item(0),0,0). Wondering where are those numbers are kept.


