English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 22 April 2018, 20:15   #1
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
Rotate Shape - adds one pixel from left and top

Is that normal behavior (still blitz 2.1)?

I have a shape 16x16. After doing same rotation (0.25 or 0.5 or 0.75) my shape becomes 17x17 (checked with ShapeWidth/ShapeHeight).
The very first row and column is empty (background color) and the original shape (drawing) starts at 1,1

Thanks
peceha is offline  
Old 23 April 2018, 17:08   #2
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Hmmm, I haven't noticed it myself - that's very odd. I'll check when I go home, it's possible that it has happened to me and I simply haven't noticed the graphics being a pixel out. But I would say it shouldn't happen. Perhaps it's a bug, or a floating point imprecision. Are you using a literal value in the code (Rotate 0, 0.25) or a variable (Rotate 0, MyAngle)?
Daedalus is offline  
Old 23 April 2018, 18:09   #3
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
This is the code (literal value for rotation):
Code:
WbToScreen 0
ShowScreen 0

BitMap 0,640,600,2
LoadBitMap 0,"ram:test.iff"

GetaShape 0,0,0,16,16

CopyShape 0,1
Rotate 1,0.25

CopyShape 0,2
Rotate 2,0.5

CopyShape 0,3
Rotate 3,0.75

Window 0,0,15,128,128,$2|$4|$8|$400|$1000,"my game",1,2

WBlit 0,0,0
WLocate 0,20
Print ShapeWidth(0)

WBlit 1,16,0
WLocate 16,20
Print ShapeWidth(1)

WBlit 2,32,0
WLocate 32,20
Print ShapeWidth(2)

WBlit 3,48,0
WLocate 48,20
Print ShapeWidth(3)
and this is the result. I'm not sure if you can see on the picture but second and third tiles from left are shifted by 1 px and their width is 17 (printed below). Original tile has left, top and right edge white
peceha is offline  
Old 23 April 2018, 19:37   #4
Dunny
Registered User
 
Dunny's Avatar
 
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 1,975
I'm assuming this is rotated in degrees rather than radians?

If you rotate a bitmap through non-90 degree rotations, it will get bigger. That's just the way it is - it's either that or you lose pixels. Rounding errors means that sometimes you get empty space at the edges.

You can test that by rotating by 45 degrees and see what happens.
Dunny is online now  
Old 23 April 2018, 19:42   #5
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
This is taken from manual:
Quote:
The Rotate command allows you to rotate a shape object.
Angle Ratio specifies how much clockwise rotation to apply, and should be in the range zero to one. For instance, an Angle Ratio of .5 will cause a shape to be rotated 180 degrees, while an Angle Ratio of .25 will cause a shape to be rotated 90 degrees clockwise.
All the rotations that take place in a code are: 90 deg, 180 deg, 270 deg (0.25, 0.5, 0.75)
peceha is offline  
Old 23 April 2018, 21:52   #6
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Hmmm, it seems there's something funky going on. I've used that command in a game to rotate a shape that's 20x9 in size. The sizes the shape ends up with the various rotations are:

0.25 (90 degrees): 21x9
0.5 (180 degrees): 10x21
0.75 (270 degrees): 20x10

So, while the pixels look fine on screen, it's adding an extra line in most cases. Not consistently in both directions with my shapes. I'm guessing it must be some sort of imprecision in the algorithm, which is probably fine when rotating an arbitrary angle, but for an exact 90, 180 or 270 rotation it's quite annoying. This is in Amiblitz 3 too, so it doesn't appear to have ever been fixed...

At least you know it's not you I would suggest doing the rotation in DPaint or PPaint instead if it turns out to be a critical issue, as it would be for a tile-based engine. Alternatively, you could write your own routines in Blitz - so long as they don't need to be time-critical, you could use a couple of for...next loops to do precise 90 degree rotations to a dummy bitmap.
Daedalus is offline  
Old 23 April 2018, 22:18   #7
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 282
Thanks for testing !! I was actually waiting for the results

I think I will choose the easy way (dPaint) - the number of tiles will increase a little bit.
Anyway XFlip and YFlip are working fine so I can still use them for 180 deg.

Thanks.
peceha is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need explanation of a demo effect - screen zoom/rotate Dunny support.Demos 21 21 April 2023 20:47
Alien Breed II title pixel by pixel logo removal dex project.Sprites 17 06 May 2020 15:23
Blitting part of a shape? earok Coders. Blitz Basic 3 01 December 2017 03:45
How do you get the Handle of an existing Shape? earok Coders. Blitz Basic 1 22 April 2017 11:00
AmiWest 2009 adds Amiga Game Competition to Show AmigaDave News 4 15 September 2009 02:29

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:16.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07404 seconds with 15 queries