[Lazarus] Adding shapes to TShape

Frederic Da Vitoria davitofrg at gmail.com
Thu Dec 26 13:03:55 CET 2013


Hello,

For a game, I need to be able to draw geometric shapes. TShape is perfect
except for one missing feature: TShape only draws triangles pointing up,
and I need also triangles pointing left, right and down. My first reaction
was to create a derived class, and try to somehow add the missing shapes by
overriding TShape.Paint and in the overriding method just handle the new
shapes. But TShape is designed in such a way that I can't figure out how to
do it. Then I thought that I'd create a derived class but that this class
Paint method would draw all the possible shapes (including the 3 new ones)
and that for that I'd override the Paint method with a modified
implementation of TShape.Paint. Much less clean, not really oo-ish, but it
should at least work. "Should", because when I tried this, I discovered
that it would be much more difficult that I had hoped, so that I decided to
stop trying and ask here first.

Does anybody have a good suggestion about how to handle this? Should I
forget about deriving TShape and should I directly modify TShape's code?

-- 
Frederic Da Vitoria
(davitof)

Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20131226/df45f52f/attachment-0002.html>


More information about the Lazarus mailing list