Graphics Drawing Tutorial

Scantech

Well-Known Member
Licensed User
Longtime User
Sub Timer1_Tick
Dim Angle1 As Float

Angle1 = Angle
Angle = (Angle+AngleStep) Mod 360
If Mode = True Then
csvNeedle.DrawRectRotated(DRectNeedle,Colors.Transparent,True,1,Angle1)
csvNeedle.DrawBitmapRotated(bmpNeedle,SRectNeedle,DRectNeedle,Angle)
imvNeedle.Invalidate2(RectCompass)
Else
csvCompass.DrawBitmapRotated(bmpCompass,RectCompass,RectCompass,-Angle)
imvCompass.Invalidate2(RectCompass)
End If
End Sub

I am reading the Beginning Tutorial and checking out the Drawing section. I am confused at something I spotted.

Look at Mode = true
imvNeedle.Invalidate2(RectCompass)??? Should it be imvNeedle.Invalidate2(DRectNeedle)
 

kickaha

Well-Known Member
Licensed User
Longtime User
I am not familiar with that code, but it could be because it is as quick to redraw RectCompass as it is to redraw both DRectNeedle and SRectNeedle.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
imvNeedle.Invalidate2(RectCompass)??? Should it be imvNeedle.Invalidate2(DRectNeedle)
No, it must be RectCompass !
Try it and you will see the difference. When the needle position is horizontal only the center of it will be shown!
DRectNeedle is the rectangle of the needle in vertical position that means that only that area will be updated.
imvNeedle has the dimensions of the compass to be able to show the needle in any position. I choose to Invalidate the whole compass surface instead of calculating the surrounding rectangle of the needle image depending on its orientation.

Best regards.
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
No, it must be RectCompass !
Try it and you will see the difference. When the needle position is horizontal only the center of it will be shown!
DRectNeedle is the rectangle of the needle in vertical position that means that only that area will be updated.
imvNeedle has the dimensions of the compass to be able to show the needle in any position. I choose to Invalidate the whole compass surface instead of calculating the surrounding rectangle of the needle image depending on its orientation.

Best regards.

Thanks Klaus. I see your point. It would not matter which to use if both image files has same dimension. Thanks

I love the support here. Thank you B4A!!
 
Upvote 0
Top