.Drawline is being covered by a canvas

Greetings,

I am attempting to draw a line onto a canvas, but it is being overdrawn by another canvas. I have tried to set the other canvas such that it is instantiated in code to the back, with no luck. My line code is:

canvasPicture.Graphics.DrawLine(x1, y1, x, y)
opticalBenchCanvas2018.Invalidate

The other canvas has a group2D object with a FigureShape. I tried to put the 2D object into a backdrop using: me.backdrop.objects=groupD, with no luck. However the 2D object did appear without this statement.

The line works fine without the other canvas.

Help would be appreciated. Thanks

overlapping canvas (or any control for that matter) is not a reccommended practice.

Why not just do all your drawing on a single canvas.

The idea of the project (which use to work long before strict adherence to the paint event) is to allow "laser"beams to refract, or reflect through or off of prisms and mirrors of multiple optical characteristics. Each mirror or prism is on its own canvas, which can be moved about, rotated and changes to optical characteristics, Here in this very simple example a laser beam is being refracted through the prism. The beam is being masked by the prism. It is there as when I move the prism the beam is visible.

The color of the prism embeds data about the prism (index of refraction, canvas# and prism#. The coordinates of the edges embed the normal angle.

There must be a way to draw on top of things. The laser line is on a canvas that overlays the entire blue surface. Do I needs a canvas for the laser line? (i didn’t use to.)

Thanks
/Users/cgibson/Desktop/OpticalSimulation.jpg

Especially under Windows, overlapping canvases is a recipe for flicker.

I have an app I started on Mac with overlapping canvases. Once compiled on Windows, it was unusable. I had to refactor it so all drawing is now done in a single canvas.

again… one canvas… or use picture objects for the “layers”
then in the canvas paint event, draw the pictures over each other (of course THEY need transparent backgrounds)

FYI… you can’t post a link to a file on your personal computer :slight_smile:

I did a game using a similar description, it had mirrors, lasers etc… and the lasers were animated… all in ONE canvas

similar to this

You REALLY should read the SuperDraw article in xDev 12.5 … because basically you are doing it all wrong.

P.S. can be purchased and downloaded instantly via GumRoad (http://gum.co/DXbT ).

Thanks! I will try one canvas.

Best regards

Here is the simplified code for SuperDraw https://www.dropbox.com/s/r0mltxqqd4nas3a/SuperDraw%20simple.zip?dl=0

Basically what you do:

One canvas with an array of drawingObjects
Each drawingObject knows how to draw itself and reacts to events like drag
A draw mehod that calls each drawingObjects paint method so that they draw to the canvas