Copy Canvas to ImageView

Did you run that on a server? I think the problem of not showing text has something to do with my Xojo Cloud server but I can’t be sure. Running locally works great. I think I remember you saying you don’t have a Xojo Cloud account so there is no way for you to test.

You are right. I could not test the XC “load above” for pictures Greg mentioned once. But I can test cgi.

Something is wrong with drawstring when using CGI :frowning:

Damn. Guess I should file a bug report. I really appreciate you persistence in helping me out with this. Even if I don’t end up using picture I learned a few things.

Hoping Brock comes back with some new insights about using Canvas Paint.

I hoped the problem was because I used the shown event, but after placing the code in a button, it does the same thing. Drawstring is indeed broken in WE cgi. Which Xojo Cloud is based on.

On the Canvas Paint front, I tried to save g to a window graphics property after drawing and reuse it the next time. No luck. For some reason, g gets erased anyway.

It is very aggravating that there is no way to put a graphics object into a picture. In WE, not even pixel is available.

I even looked at the content of the DOM in the developer console of the browser in the hope to find a picture and look at it, but Canvas does not use one.

Okay, thanks for doing that.

I am going to see if I can set successive paints to transparent (since I don’t see any way to override successive Paint events). Maybe that is what Brock was getting at.

Documentation talks about using EraseBackground and areas parameter to control what gets redrawn. Seems like what I need.

Two things from the document to note:

For WebCanvas:
The WebCanvas will cache the items to paint. So if you make change it will only send new elements to be drawn from the start of the first difference.

So if you do something like:
DrawBackground
DrawGuides
DrawDetails

If you make change to the steps you draw in DrawDetails it wont have to resend the commands to the Client’s Browser for DrawBackground or DrawGuides. This will cause it to render faster. I couldn’t find where in the documentation it talks about this but I know @Greg O’Lone has mentioned this a few times. (Please correct me Greg if I have any details of this wrong).

For WebImageView:

[quote]Pictures that are stored in properties of objects that are sent to the browser (like properties of web pages and controls) are cached locally on the client web browser. If you are always displaying the same picture on a page (or different pages), you can significantly improve performance by caching your picture so that it is not repeatedly sent to the web browser.
For example, if you are creating a custom button control using a subclass of an ImageView control, you could store the two images (normal and pressed states) in two picture properties of the ImageView subclass so that those pictures are only sent to the browser once.[/quote]

The problem is that I don’t have any changes. After I paint the WebCanvas the first time, I want it to stop painting. Unfortunately, every time I navigate away then back, paint is fired again.

The online manual describes EraseBackground and area parameter for Canvas but not for WebCanvas.

I think my only option is to just close the page with the WebCanvas on it. That’s inefficient but I don’t have any options because of inability to override WebCanvas.Paint. This seems like a flaw in the design of WebCanvas.

Anyone know how to use WebGraphics.Save and WebGraphics.Restore.

Interesting. Not documented anywhere.

I think there is a bug in the WebCanvas too (either CGI or Xojo Cloud). I am going to work up an example to demonstrate the problem.

Wait. The drawstring one is not a bug.

Set g.TextFont to “Arial” and you should be fine. Not long ago this was discussed in the forum ; since Helvetica exists only on the Mac, it is not part of the fonts available to a cgi application.

I just tested it works on my host.

I was using Arial. I will do a small test to see if it works on Xojo Cloud. I am betting XC doesn’t have Arial font.

See https://forum.xojo.com/15287-webcanvas-flickers-then-disappears-when-hosted-on-linux?search=textfont for a method that displays all fonts available.

Can someone post the list of fonts available on the Xojo Cloud server? The trick of not specifying a font (which should use the default font) doesn’t work. I have also tried System font and it doesn’t work.

My XC server is acting up (stuck on 0:00 Remaining).

[quote=130193:@Ken Gish]Can someone post the list of fonts available on the Xojo Cloud server? The trick of not specifying a font (which should use the default font) doesn’t work. I have also tried System font and it doesn’t work.

My XC server is acting up (stuck on 0:00 Remaining).[/quote]

If you look at the post I mentioned above, you can create a small app that will build that list.

Yes, I know. It lists the fonts just fine when I run locally. The problem is that I can’t deploy to XC right now.

When you say the user navigates away, do you mean to a different WebPage on the internet or a different WebPage in your WebApp. If it’s the WebApp and not a separate website then have a suggestion. I pretty much only use on WebPage with WebProjects. All the content is dynamically loaded and removed with WebContainers. In your case you could simply hide the WebContainer that was the WebCanvas make it visible again when the user does whatever they do to navigate back to it.

A different webpage in the app.

That’s a good idea but the page will be insane to edit. Lots of components. If I can’t solve this any other way, I’ll do that.

Thanks.

[quote=130209:@Ken Gish]A different webpage in the app.

That’s a good idea but the page will be insane to edit. Lots of components. If I can’t solve this any other way, I’ll do that.

Thanks.[/quote]

Essentially every WebPage just becomes one WebContainer. You might even be able to change them by editing their super from WebPage to WebContainer in the Xojo IDE. Then the main webpage just loads and locks the container to the full size of the webpage. When you want to show a new page you remove the ‘page’-container and load in the new one. But in your case with the drawing one you can hide it instead of removing the container.