I am trying to use the TextUnit field in a Graphics object but encounter “This item does exist” error when building the web app. The TextUnit field autocompletes in the editor so I know the IDE knows something about the field.
Anyone have an idea why this is happening? Thanks in advance.
Nothing as far as text goes. I can draw lines in the buffer with no problem. I’m gonna throw this post out to the web target forum separately but the other bizarre thing thats happening is when I draw the resulting buffer/picture to the canvas (WebCanvas) it triggers a number of Paint events. I’m going to continue researching this one before I post.
Thanks for you help. BTW - I’m using your controls! Pretty cool.
The two things that come to mind are a missing font, or a font that’s not compatible with the console app. Does the code work in a desktop project?
Curious: why not draw everything to a WebCanvas or jCanvas (since you have wcc)? Sending drawing commands to the client browser is almost always faster then sending a bitmap.
I have options to pre-buffer the images and send them as a bitmap or draw directly to the WebCanvas. I have been testing both to see what would be more useful and efficient.
I had a Xojo guy tell me that the DrawPicture to the WebCanvas is causing the browser to generate a number of invalidate events.
Invalidating and painting a region isn’t a concept that’s native to the HTML5 canvas. Obviously the browser is doing something that the Xojo framework is interpreting as a situation requiring a redraw, but I’m not sure what that could be. Maybe it has to do with the buffer image downloading?
Since you have wcc, if you haven’t played with it yet, take a look at the jCanvas control. There’s more to it so you want to sit down with it when you have a bit of free time. And if you decide to work with it directly rather than using the jCanvasToRbGraphics wrapper you’ll have to rework your code a bit. But it can do a lot. You can treat it as a raster (paint) surface or a vector surface. If you treat it as a vector surface you don’t have to redraw everything when a change is made, you just change the object properties. If you want to move a rectangle for example, you just change the coordinates of that object. (In jCanvas terminology a vector object on the canvas is a jCanvasLayer. A bit confusing since in most drawing programs a “layer” is something that holds multiple vector objects, but I wanted the control to closely match the API and terminology of the underlying JavaScript library.)
There’s no “invalidate/paint” event cycle with jCanvas, and with vector objects on the surface I don’t think you would ever have to worry about the browser needing a repaint or refresh. You can also receive mouse events on vector objects. And since this started with a question related to TextUnit, you can obtain font metrics for precise positioning (LoadFontMetrics method and wccFontMetricsLoaded event).
In the online demo I focus too much on animation. Which is cool if you have the client/server bandwidth for it. But I’m not sure I’ve successfully communicated to wcc users that it’s a very powerful drawing surface, and not just something for animation.