VectorLib Coordinate Bug PB573

Post bugreports for the Windows version here
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

VectorLib Coordinate Bug PB573

Post by Saki »

VectorLib Coordinate Bug PB573

Here's an explanation, since it's all rather convoluted.

Now finally after developing the Vector based Rotate and Mirror tool my findings.
https://www.purebasic.fr/english/viewto ... 12&t=77009

Thread because the bug :
https://www.purebasic.fr/english/viewto ... =5&t=76988

A basic problem is that the coordinate origin is offset by one pixel.

So you have to set MovePathCursor(-1, -1) like this to get to zero.

Therefore the Vector output starts at 1, 1, not at 0, 0

This results in problems with truncated image edges when rotating, for example, because the drawing area is

ends 1 pixel outside a given plane.

You can compensate this by setting the path cursor accordingly.

Up to now, however, everyone had failed in the handling, because everything seems very suspect.

FlipCoordinates has a real bug.
I think it is due to the Vector Lib.
The coordinate origin shifts x and y by an amount of +-1, depending on the dimensions of the source plane.
For example, at 340*340 there is no offset, but at 420*420 there is. ( Try simple different values )
420*421 is OK 420*422 gives an offset,
422> then goes again, until at some point it doesn't. (As far as I can remember these sizes )
Horizontal mirroring, for example, gets an offset when the tarp is enlarged vertically and vice versa.
Absolutely no pattern or coherence can be found in this.

On Linux and Mac everything works fine, except that the zero coordinate is not correct either.
Last edited by Saki on Sun Apr 18, 2021 3:32 pm, edited 1 time in total.
地球上の平和
User avatar
STARGÅTE
Addict
Addict
Posts: 2088
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: VectorLib Zero Coordinate Bug PB573

Post by STARGÅTE »

Saki wrote:A basic problem is that the coordinate origin is offset by one pixel.
So you have to set MovePathCursor(-1, -1) like this to get to zero.
Therefore the Vector output starts at 1, 1, not at 0, 0
How did you come to this conclusion?

In this example, the image is exactly drawn at (0,0) when I use MovePathCursor(0,0):

Code: Select all

Enumeration
	#Window
	#Gadget
	#VectorImage
	#Image
EndEnumeration

If CreateImage(#Image, 16, 16, 32, #PB_Image_Transparent)
	If StartDrawing(ImageOutput(#Image))
		DrawingMode(#PB_2DDrawing_AlphaBlend)
		Box(1,1,6,6,$FF00FF00)
		Box(9,1,6,6,$FFFF0000)
		Box(1,9,6,6,$FF0000FF)
		StopDrawing()
	EndIf
EndIf

If CreateImage(#VectorImage, 16, 16, 32, #PB_Image_Transparent)
	If StartVectorDrawing(ImageVectorOutput(#VectorImage))
		MovePathCursor(0, 0)
		DrawVectorImage(ImageID(#Image))
		StopVectorDrawing()
	EndIf
EndIf

ResizeImage(#VectorImage, ImageWidth(#VectorImage)*16, ImageHeight(#VectorImage)*16, #PB_Image_Raw)

OpenWindow(#Window, 0, 0, ImageWidth(#VectorImage), ImageHeight(#VectorImage), "MovePathCursor", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
ImageGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), ImageID(#VectorImage))

Repeat
	Select WaitWindowEvent()
		Case #PB_Event_CloseWindow
			Break
	EndSelect
ForEver
On the other hand you are right, that something is strange during rotation, but it is an issue with DrawVectorImage().
Here the box is drawn correctly, but not the image:

Code: Select all

Enumeration
	#Window
	#Gadget
	#VectorImage
	#Image
EndEnumeration

If CreateImage(#Image, 16, 16, 32, #PB_Image_Transparent)
	If StartDrawing(ImageOutput(#Image))
		DrawingMode(#PB_2DDrawing_AlphaBlend)
		Box(1,1,6,6,$FF00FF00)
		Box(9,1,6,6,$FFFF0000)
		Box(1,9,6,6,$FF0000FF)
		StopDrawing()
	EndIf
EndIf

If CreateImage(#VectorImage, 16, 16, 32, #PB_Image_Transparent)
	If StartVectorDrawing(ImageVectorOutput(#VectorImage))
		RotateCoordinates(8, 8, 180)
		MovePathCursor(0, 0)
		DrawVectorImage(ImageID(#Image))
		MovePathCursor(0, 0)
		AddPathBox(1,1,14,14,#PB_Path_Relative)
		VectorSourceColor($40808080)
		FillPath()
		StopVectorDrawing()
	EndIf
EndIf

ResizeImage(#VectorImage, ImageWidth(#VectorImage)*16, ImageHeight(#VectorImage)*16, #PB_Image_Raw)

OpenWindow(#Window, 0, 0, ImageWidth(#VectorImage), ImageHeight(#VectorImage), "MovePathCursor", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
ImageGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), ImageID(#VectorImage))

Repeat
	Select WaitWindowEvent()
		Case #PB_Event_CloseWindow
			Break
	EndSelect
ForEver
So there is probably a bug, but not with MovePathCursor() it is probably a bug in DrawVectorImage().
You mide change your title.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: VectorLib Zero Coordinate Bug PB573

Post by Saki »

I agree with this, since the effect is then the same.

It's hard to see through what exactly is happening.

Keep in mind that, as far as I know, everyone has failed so far to get an error-free rotation.

It is important to start the discussion to define the error exactly.

Define it exactly.

Then try FlipCoordinates()
If you can uncover the mathematical relationships for the failure, you are the king on the balcony.
Last edited by Saki on Sat Apr 03, 2021 12:53 am, edited 1 time in total.
地球上の平和
User avatar
STARGÅTE
Addict
Addict
Posts: 2088
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: VectorLib Zero Coordinate Bug PB573

Post by STARGÅTE »

It is even more strange, because it seems like, some angles are working fine.
Here in this example I added a slider to change the rotation of coordinates between 85° and 95°.
Only 90° is drawed correctly. For larger or smaller angles you can see the "shift" by 1px.

Code: Select all

Enumeration
	#Window
	#Gadget
	#VectorImage
	#Image
	#TrackBarGadget
	#TextGadget
EndEnumeration

Global Time.i = ElapsedMilliseconds()

If CreateImage(#Image, 16, 16, 32, #PB_Image_Transparent)
	If StartDrawing(ImageOutput(#Image))
		DrawingMode(#PB_2DDrawing_AlphaBlend)
		Box(1,1,6,6,$FF00FF00)
		Box(9,1,6,6,$FFFF0000)
		Box(1,9,6,6,$FF0000FF)
		StopDrawing()
	EndIf
EndIf


Procedure Update(Angle.i)
	If CreateImage(#VectorImage, 16, 16, 32, #PB_Image_Transparent)
		If StartVectorDrawing(ImageVectorOutput(#VectorImage))
			RotateCoordinates(8, 8, Angle)
			MovePathCursor(0, 0)
			DrawVectorImage(ImageID(#Image))
			MovePathCursor(0, 0)
			AddPathBox(1,1,14,14,#PB_Path_Relative)
			VectorSourceColor($40808080)
			FillPath()
			StopVectorDrawing()
		EndIf
	EndIf
	ResizeImage(#VectorImage, ImageWidth(#VectorImage)*16, ImageHeight(#VectorImage)*16, #PB_Image_Raw)
	ImageGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), ImageID(#VectorImage))
EndProcedure


OpenWindow(#Window, 0, 0, 16*16, 16*16 + 30, "MovePathCursor", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
Update(90)
TrackBarGadget(#TrackBarGadget, 0, 16*16, 200, 30, 85, 95, #PB_TrackBar_Ticks)
SetGadgetState(#TrackBarGadget, 90)
TextGadget(#TextGadget, 200, 16*16, 56, 30, "90°")

Repeat
	Select WaitWindowEvent()
		Case #PB_Event_CloseWindow
			Break
		Case #PB_Event_Gadget
			Select EventGadget()
				Case #TrackBarGadget
					Update(GetGadgetState(#TrackBarGadget))
					SetGadgetText(#TextGadget, Str(GetGadgetState(#TrackBarGadget))+"°")

			EndSelect
	EndSelect
ForEver
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: VectorLib Zero Coordinate Bug PB573

Post by Saki »

Yes, it is.
I have tried to uncover the mathematical relationships:
Whenever I thought it was working, it occurred again:

After two days, I now have no nerfs for it.
So I thought I'd give my info and findings, since others may see things I'm missing.

The first and best step would probably be to update the Vector Lib under Windows OS.
地球上の平和
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

VectorLib Zero Coordinate Bug PB573

Post by JHPJHP »

Hi STARGÅTE,

Nice method to test rotation; slightly modified your example.

Instead of chasing the missing pixels, it helped to follow the centre point.

Didn’t spend more then 10 minutes on it, so I’m not sure if this is the path to a complete resolution, but it seems to solve the rotation problem with this example.

Code: Select all

Enumeration
   #Window
   #Gadget
   #VectorImage
   #Image
   #TrackBarGadget
   #TextGadget
EndEnumeration

If CreateImage(#Image, 16, 16, 32, #PB_Image_Transparent)
  If StartVectorDrawing(ImageVectorOutput(#Image))
    AddPathBox(1, 1, 6, 6)
    VectorSourceColor($FF00FF00)
    FillPath()
    AddPathBox(9, 1, 6, 6)
    VectorSourceColor($FFFF0000)
    FillPath()
    AddPathCircle(8, 8, 1)
    VectorSourceColor($FF000000)
    FillPath()
    AddPathBox(1, 9, 6, 6)
    VectorSourceColor($FF0000FF)
    FillPath()
    AddPathBox(9, 9, 6, 6)
    VectorSourceColor($FF00FFFF)
    FillPath()
    StopVectorDrawing()
  EndIf
EndIf

Procedure Update(Angle.d)
  If CreateImage(#VectorImage, 16, 16, 32, #PB_Image_Transparent)
    If StartVectorDrawing(ImageVectorOutput(#VectorImage))
      Select Angle
        Case 90
          RotateCoordinates(8, 8, Angle)
        Case 180
          RotateCoordinates(7.5, 7.5, Angle - 0.1)
        Default
          RotateCoordinates(7.5, 7.5, Angle)
      EndSelect
      MovePathCursor(0, 0)
      DrawVectorImage(ImageID(#Image))
      StopVectorDrawing()
    EndIf
  EndIf
  ResizeImage(#VectorImage, ImageWidth(#VectorImage) * 16, ImageHeight(#VectorImage) * 16, #PB_Image_Raw)
  ImageGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), ImageID(#VectorImage))
EndProcedure

OpenWindow(#Window, 0, 0, 16 * 16, 16 * 16 + 40, "RotateCoordinates", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
Update(180)
TrackBarGadget(#TrackBarGadget, 10, 16 * 16, 200, 30, 0, 360, #PB_TrackBar_Ticks)
SetGadgetState(#TrackBarGadget, 180)
TextGadget(#TextGadget, 210, 16 * 16, 56, 30, "180°")

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #TrackBarGadget
          Update(GetGadgetState(#TrackBarGadget))
          SetGadgetText(#TextGadget, Str(GetGadgetState(#TrackBarGadget)) + "°")
    EndSelect
  EndSelect
ForEver
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: VectorLib Zero Coordinate Bug PB573

Post by Saki »

After all, rotating was not the problem.
The problem was that you can't mirror images of any size.
地球上の平和
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

VectorLib Zero Coordinate Bug PB573

Post by JHPJHP »

Saki/walbus wrote:After all, rotating was not the problem.
viewtopic.php?p=568240#p568240
Saki/walbus wrote:This results in problems with truncated image edges when rotating
viewtopic.php?p=568242#p568242
STARGÅTE wrote:On the other hand you are right, that something is strange during rotation
viewtopic.php?p=568244#p568244
Saki/walbus wrote:Keep in mind that, as far as I know, everyone has failed so far to get an error-free rotation.
viewtopic.php?p=568245#p568245
STARGÅTE wrote:Here in this example I added a slider to change the rotation of coordinates between 85° and 95°.
Only 90° is drawed correctly. For larger or smaller angles you can see the "shift" by 1px.
viewtopic.php?f=5&t=76988
IdeasVacuum wrote:Vector Lib: Rotate: Lost Pixels
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: VectorLib Zero Coordinate Bug PB573

Post by Saki »

As you may have noticed my rotation works, only the mirroring not. :wink:

Make a working all size mirroring !
地球上の平和
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: VectorLib Zero Coordinate Bug PB573

Post by JHPJHP »

Maybe the following example can help correct the problem in future releases of PureBasic.

Sticking with the same principle of a half pixel discrepancy, FlipX/Y was included to work naturally with degrees of 0, 90, 180, 270, 360.
- didn’t spend more then 30 minutes on it, so I’m not sure if this is the path to a complete resolution.

Code: Select all

Enumeration
   #Window
   #Gadget
   #VectorImage
   #Image
   #TrackBarGadget
   #TextGadget
   #CheckBoxGadget1
   #CheckBoxGadget2
EndEnumeration

If CreateImage(#Image, 16, 16, 32, #PB_Image_Transparent)
  If StartVectorDrawing(ImageVectorOutput(#Image))
    AddPathBox(1, 1, 6, 6)
    VectorSourceColor($FF00FF00)
    FillPath()
    AddPathBox(9, 1, 6, 6)
    VectorSourceColor($FFFF0000)
    FillPath()
    AddPathCircle(8, 8, 1)
    VectorSourceColor($FF000000)
    FillPath()
    AddPathBox(1, 9, 6, 6)
    VectorSourceColor($FF0000FF)
    FillPath()
    AddPathBox(9, 9, 6, 6)
    VectorSourceColor($FF00FFFF)
    FillPath()
    StopVectorDrawing()
  EndIf
EndIf

Procedure Update(Angle.d)
  FlipX = GetGadgetState(#CheckBoxGadget1)
  FlipY = GetGadgetState(#CheckBoxGadget2)

  If CreateImage(#VectorImage, 16, 16, 32, #PB_Image_Transparent)
    If StartVectorDrawing(ImageVectorOutput(#VectorImage))
      Select #True
        Case Bool(Angle = 180)
          RotateCoordinates(7.5, 7.5, Angle - 0.1)
        Case Bool(Angle = 360 And (FlipX Or FlipY))
          RotateCoordinates(7.5, 7.5, Angle - 0.1)
        Default
          RotateCoordinates(7.5, 7.5, Angle)
      EndSelect

      Select Angle
        Case 0
          Select #True
            Case Bool(FlipX And FlipY)
              FlipCoordinatesX(8)
              FlipCoordinatesY(8)
            Case FlipX
              FlipCoordinatesX(8)
            Case FlipY
              FlipCoordinatesY(8)
          EndSelect
        Case 90
          Select #True
            Case Bool(FlipX And FlipY)
              FlipCoordinatesX(8)
              FlipCoordinatesY(7.5)
              FlipCoordinatesX(8)
              FlipCoordinatesY(8)
            Case FlipX
              FlipCoordinatesX(8)
              FlipCoordinatesY(7.5)
              FlipCoordinatesY(8)
            Case FlipY
              FlipCoordinatesY(7.5)
            Default
              FlipCoordinatesX(8)
              FlipCoordinatesY(7.5)
          EndSelect
        Case 270
          Select #True
            Case Bool(FlipX And FlipY)
              FlipCoordinatesX(7.5)
              FlipCoordinatesY(7.5)
            Case FlipX
              FlipCoordinatesY(7.5)
            Case FlipY
              FlipCoordinatesX(7.5)
          EndSelect
        Default
          Select #True
            Case Bool(FlipX And FlipY)
              FlipCoordinatesX(7.5)
              FlipCoordinatesY(7.5)
            Case FlipX
              FlipCoordinatesX(7.5)
            Case FlipY
              FlipCoordinatesY(7.5)
          EndSelect
      EndSelect
      MovePathCursor(0, 0)
      DrawVectorImage(ImageID(#Image))
      StopVectorDrawing()
    EndIf
  EndIf
  ResizeImage(#VectorImage, ImageWidth(#VectorImage) * 16, ImageHeight(#VectorImage) * 16, #PB_Image_Raw)
  ImageGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), ImageID(#VectorImage))
EndProcedure

OpenWindow(#Window, 0, 0, 16 * 16, 16 * 16 + 80, "RotateCoordinates", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
TrackBarGadget(#TrackBarGadget, 10, 16 * 16, 200, 30, 0, 360, #PB_TrackBar_Ticks)
SetGadgetState(#TrackBarGadget, 180)
TextGadget(#TextGadget, 210, 16 * 16, 56, 30, "180°")
CheckBoxGadget(#CheckBoxGadget1, 50, 16 * 16 + 40, 60, 20, "Flip X")
CheckBoxGadget(#CheckBoxGadget2, 150, 16 * 16 + 40, 60, 20, "Flip Y")
Update(180)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #TrackBarGadget
          Update(GetGadgetState(#TrackBarGadget))
          SetGadgetText(#TextGadget, Str(GetGadgetState(#TrackBarGadget)) + "°")
        Case #CheckBoxGadget1, #CheckBoxGadget2
          Update(GetGadgetState(#TrackBarGadget))
    EndSelect
  EndSelect
ForEver
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: VectorLib Zero Coordinate Bug PB573

Post by Saki »

I don't know now if the behavior with AddPathBox() is the same as with DrawVectorImage()
With DrawVectorImage() the offset changes depending on the width and height of the image completely unpredictable, that's the problem.
Even if you mirror horizontally, the vertical offset changes when the image height changes.
But not with every change.
The values where this happens cannot be calculated.

Image
地球上の平和
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: VectorLib Zero Coordinate Bug PB573

Post by JHPJHP »

Not sure what your animation is proving?
Saki/walbus wrote:I don't know now if the behavior with AddPathBox() is the same as with DrawVectorImage()
With DrawVectorImage() the offset changes depending on the width and height of the image completely unpredictable, that's the problem.
The example provided by STARGÅTE creates an image with AddPathBox, but DrawVectorImage is used during the rotation, that was the point.
STARGÅTE wrote:... something is strange during rotation, but it is an issue with DrawVectorImage().
Here the box is drawn correctly, but not the image:
My previous examples proves that DrawVectorImage of equal sizes can be calculated and fixed.
This next example modifies the width of the vector image and its rotation center point and flip X coordinate; fix of a half pixel discrepancy still applies.
Obviously this doesn't take all images sizes into consideration, but it is a starting point.

Code: Select all

Enumeration
   #Window
   #Gadget
   #VectorImage
   #Image
   #TrackBarGadget
   #TextGadget
   #CheckBoxGadget1
   #CheckBoxGadget2
EndEnumeration

If CreateImage(#Image, 32, 16, 32, #PB_Image_Transparent)
  If StartVectorDrawing(ImageVectorOutput(#Image))
    AddPathBox(1, 1, 12, 6)
    VectorSourceColor($FF00FF00)
    FillPath()
    AddPathBox(19, 1, 12, 6)
    VectorSourceColor($FFFF0000)
    FillPath()
    AddPathCircle(16, 8, 1)
    VectorSourceColor($FF000000)
    FillPath()
    AddPathBox(1, 9, 12, 6)
    VectorSourceColor($FF0000FF)
    FillPath()
    AddPathBox(19, 9, 12, 6)
    VectorSourceColor($FF00FFFF)
    FillPath()
    StopVectorDrawing()
  EndIf
EndIf

Procedure Update(Angle.d)
  FlipX = GetGadgetState(#CheckBoxGadget1)
  FlipY = GetGadgetState(#CheckBoxGadget2)

  If CreateImage(#VectorImage, 32, 16, 32, #PB_Image_Transparent)
    If StartVectorDrawing(ImageVectorOutput(#VectorImage))
      Select #True
        Case Bool(Angle = 180)
          RotateCoordinates(15.5, 7.5, Angle - 0.1)
        Case Bool(Angle = 360 And (FlipX Or FlipY))
          RotateCoordinates(15.5, 7.5, Angle - 0.1)
        Default
          RotateCoordinates(15.5, 7.5, Angle)
      EndSelect

      Select Angle
        Case 0
          Select #True
            Case Bool(FlipX And FlipY)
              FlipCoordinatesX(16)
              FlipCoordinatesY(8)
            Case FlipX
              FlipCoordinatesX(16)
            Case FlipY
              FlipCoordinatesY(8)
          EndSelect
        Case 90
          Select #True
            Case Bool(FlipX And FlipY)
              FlipCoordinatesX(16)
              FlipCoordinatesY(7.5)
              FlipCoordinatesX(16)
              FlipCoordinatesY(8)
            Case FlipX
              FlipCoordinatesX(16)
              FlipCoordinatesY(7.5)
              FlipCoordinatesY(8)
            Case FlipY
              FlipCoordinatesY(7.5)
            Default
              FlipCoordinatesX(16)
              FlipCoordinatesY(7.5)
          EndSelect
        Case 270
          Select #True
            Case Bool(FlipX And FlipY)
              FlipCoordinatesX(15.5)
              FlipCoordinatesY(7.5)
            Case FlipX
              FlipCoordinatesY(7.5)
            Case FlipY
              FlipCoordinatesX(15.5)
          EndSelect
        Default
          Select #True
            Case Bool(FlipX And FlipY)
              FlipCoordinatesX(15.5)
              FlipCoordinatesY(7.5)
            Case FlipX
              FlipCoordinatesX(15.5)
            Case FlipY
              FlipCoordinatesY(7.5)
          EndSelect
      EndSelect
      MovePathCursor(0, 0)
      DrawVectorImage(ImageID(#Image))
      StopVectorDrawing()
    EndIf
  EndIf
  ResizeImage(#VectorImage, ImageWidth(#VectorImage) * 16, ImageHeight(#VectorImage) * 16, #PB_Image_Raw)
  ImageGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), ImageID(#VectorImage))
EndProcedure

OpenWindow(#Window, 0, 0, 16 * 32, 16 * 16 + 80, "RotateCoordinates", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
TrackBarGadget(#TrackBarGadget, 10, 16 * 16, 200, 30, 0, 360, #PB_TrackBar_Ticks)
SetGadgetState(#TrackBarGadget, 180)
TextGadget(#TextGadget, 210, 16 * 16, 56, 30, "180°")
CheckBoxGadget(#CheckBoxGadget1, 50, 16 * 16 + 40, 60, 20, "Flip X")
CheckBoxGadget(#CheckBoxGadget2, 150, 16 * 16 + 40, 60, 20, "Flip Y")
Update(180)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #TrackBarGadget
          Update(GetGadgetState(#TrackBarGadget))
          SetGadgetText(#TextGadget, Str(GetGadgetState(#TrackBarGadget)) + "°")
        Case #CheckBoxGadget1, #CheckBoxGadget2
          Update(GetGadgetState(#TrackBarGadget))
    EndSelect
  EndSelect
ForEver
Last edited by JHPJHP on Sun Apr 04, 2021 9:46 pm, edited 1 time in total.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: VectorLib Zero Coordinate Bug PB573

Post by Saki »

Well, you can see the problem in the gif.
There is no way to predict when which offset is needed.
Under Linux and Mac there is no problem, no offset is needed.
地球上の平和
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

VectorLib Zero Coordinate Bug PB573

Post by JHPJHP »

I'm done testing, but for anyone interested, logic would dictate (if my examples hold true) that any image of varying width and height can be placed into an image of equal width and height.
The patch used in my second post should compensate for the discrepancy during rotation and flip; no predicting necessary.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: VectorLib Zero Coordinate Bug PB573

Post by Saki »

Unfortunately, I do not believe it.
I had tried all conceivable variants.
In the end, it was just annoying and time consuming.

I think, the lib should be updated.

But anyway, many thanks for your effort.
地球上の平和
Post Reply