realbasic-betas.mbox
[Top] [All Lists]

Re: Tile window background?

To: REALbasic Betas <realbasic-betas at lists dot realsoftware dot com>
Subject: Re: Tile window background?
From: Jörg Pressel <joergp at three-2-one dot com>
Date: Sat, 29 Jun 2002 17:27:14 +0200
on 29.06.2002 16:37 Uhr, Jon Johnson at jonj at realsoftware dot com wrote:

> Create a property "myBackdrop as picture"
> 
> in the window's open event:
> 
> dim x,y as integer
> 
> myBackdrop=newPicture(me.width,me.height,32)
> 
> for x = 0 to me.width-1 step sourcePicture.width
> for y = 0 to me.height-1 step sourcePicture.height
> myBackdrop.graphics.drawPicture sourcePicture,x,y
> next
> next
> 
> me.backdrop=myBackdrop

That's a bit overkill, because you're using plenty of memory for just a
background picture - I think it's better to tile your graphic in the
window.Paint event. Storing me.width - 1 and sourcePicture.width etc. into
variables is also much faster:

dim x, y, w, h, sw, sh as integer

sw = sourcePicture.width
sh = sourcePicture.height
w = me.width - 1
h = me.height - 1

for x = 0 to w step sw
    for y = 0 to h step sh
        g.drawpicture sourcePicture, x, y
    next
next

Depending on the size of your sourcePicture it should be fast enough, too.

HTH,

Jörg

____________________________________________
three-2-one interaktive Medien GmbH

joergp at three-2-one dot com
http://www.three-2-one.com
fon: +49 2151 319450



<Prev in Thread] Current Thread [Next in Thread>