Recent

Author Topic: overlapping images  (Read 4109 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
overlapping images
« on: August 04, 2016, 02:19:51 pm »
Hello guys, who tells me how to get two overlapping images and the one that remains the front can move? Let me give an example, we shall have to draw a line on a TImage and this line must be able to move after it is drawn. How can I do? Are there examples? Thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Handoko

  • Hero Member
  • *****
  • Posts: 5416
  • My goal: build my own game engine using Lazarus
Re: overlapping images
« Reply #1 on: August 04, 2016, 02:43:58 pm »
It depends on what graphics engine you want to use.

If you just want to use the default Lazarus components, you can make use the onDraw (or sometimes it called as onPaint) event. Store all the objects' data in a list (array of object or TFPObjectList or your own create class). And paint them using the z-order you like on the onDraw event. You can move and animate each one or all of them any way you like.

Default Lazarus components aren't optimized for animation nor graphics performance. Usually, you will notice the performance issue if the total objects reaches about 10 or more. I suggest you to learn OpenGL. It's maybe the hardest but probably the fastest. I tested animation with hundreds of random moving object, it still run smoothly.
« Last Edit: August 04, 2016, 02:57:28 pm by Handoko »

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: overlapping images
« Reply #2 on: August 04, 2016, 02:54:07 pm »
Ok, we assume that you have an X-ray in a TImage, the line to be drawn on the radiograph the drawings in another TImage (with transparent background) and the other image positions?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Handoko

  • Hero Member
  • *****
  • Posts: 5416
  • My goal: build my own game engine using Lazarus
Re: overlapping images
« Reply #3 on: August 04, 2016, 02:59:49 pm »
Sorry, my English is limited. Please explain more clearly.

Do you know Z-order?
https://en.wikipedia.org/wiki/Z-order

Make use Z-order properly, there should be no problem, the transparent things will overlap correctly.
« Last Edit: August 04, 2016, 03:04:14 pm by Handoko »

 

TinyPortal © 2005-2018