[Gambas-user] gb.image: how to keep a rotated image centered

Jussi Lahtinen jussi.lahtinen at ...626...
Fri Aug 6 22:35:34 CEST 2010


There is probably more efficient ways, but quick and dirty...
Here:

DIM background AS Image = Image.Load("kuva1.jpg")
DIM bg2 AS Image
DIM f AS Float
DIM ii AS Integer
DIM jj AS Integer

ii = background.Width / 2
jj = background.Height / 2

 FOR f = 0 TO 6.2831853 STEP 0.01
 Draw.Begin(DrawingArea1)
 bg2 = background.Rotate(f)
 Draw.Image(bg2, (ii - (bg2.Width / 2)), (jj - (bg2.Height / 2)))
 Draw.End
 WAIT
 NEXT

Jussi


On Fri, Aug 6, 2010 at 21:09, kevinfishburne
<kevinfishburne at ...1887...> wrote:
>
> I'm attempting to rotate an image about its center point, using something
> like:
>
> DIM background AS Image = Image.Load("grass.png")
> DIM f AS Float
>
> FOR f = 0 TO 6.2831853 STEP 0.01
>  Draw.Begin(DrawingArea)
>    Draw.Image(background.Rotate(f), 0, 0)
>  Draw.End
>  WAIT
> NEXT
>
> The resolution of the returned rotated image actually changes based on the
> angle, such that the entire original image is preserved (no clipping
> occurs). This would be extremely useful in most cases, but not in mine as
> I'm making a game.
>
> Anyone know what math I should use to try to keep the rotated image centered
> about its mid-point while being rotated? Thanks all.
>
> -----
> Kevin Fishburne, Eight Virtues
> www:  http://sales.eightvirtues.com http://sales.eightvirtues.com
> e-mail:  mailto:sales at ...1887... sales at ...1887...
> phone: (770) 853-6271
> --
> View this message in context: http://old.nabble.com/gb.image%3A-how-to-keep-a-rotated-image-centered-tp29356475p29356475.html
> Sent from the gambas-user mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>




More information about the User mailing list