Recent

Author Topic: form canvas array?  (Read 6459 times)

jw

  • Full Member
  • ***
  • Posts: 126
form canvas array?
« on: April 14, 2010, 09:42:41 pm »
Is there a way to create an array of the forms canvas?

like so
form1.canvas[1].draw(etc......
form1.canvas[2].draw(etc...
form1.canvas
  • draw.........


this way each canvas could be updated independently of each other?

eny

  • Hero Member
  • *****
  • Posts: 1646
Re: form canvas array?
« Reply #1 on: April 14, 2010, 09:58:46 pm »
Code: [Select]
  TForm1 = class(TForm)
  private
    CanvasArray: array[0..<choose size>] of TCanvas; // ?
  end;

All posts based on: Win10 (Win64); Lazarus 3_4  (x64) 25-05-2024 (unless specified otherwise...)

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: form canvas array?
« Reply #2 on: April 14, 2010, 11:37:09 pm »
A from has only one canvas. if you want multiple canvases, use a paintbox and several TBitmaps, paint on the bitmap.canvas whenever you want, draw the bitmaps in the paintbox.onpait event.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

jw

  • Full Member
  • ***
  • Posts: 126
Re: form canvas array?
« Reply #3 on: April 15, 2010, 05:51:29 pm »
marc

I think the problem ends up being what you said in one of my other posts.

The LCL doesn't draw an alpha image on an exiting background, so the image replaces.


so is this how it works?

If I have 3 paintboxes I update paintbox 3 by animating the sprite.
this clears the form.canvas and redraws all paintbox canvases to the form.canvas in the zorder.


the reason I ask is because I've been trying to cordinate all sprites by drawing them to the form.canvas directly to make more effecient code.  I've found that no matter what any change to a paintbox leads to  canvas form redraw which is why I asked the dc windowless question in the graphics forum. 

I thought I could make an array of canvases for the form that could be altered independently then do an alpha blend by useing my post how do I make a transparent background.  I've already done something similar useing multiple form as I said in the dc windowless post but it has it's drawbacks.

 

TinyPortal © 2005-2018