Dim source() As Float = Array As Float(4.0, 4.0, 29.0, 16.0, 27.0, 37.0, 5.0, 20.0)
Dim destination() As Float = Array As Float(0, 0, anchopantalla, 0, anchopantalla, altopantalla, 0, altopantalla)
For X = 0 To anchopantalla
For Y = 0 to altopantalla
Dim ToXY() As Float = Array As Float(X, Y)
Dim FromXY() As Float = WhereDidItComeFrom(source, destination, ToXY)
Log(ToXY(0) & Tab & ToXY(1) & Tab & FromXY(0) & Tab & FromXY(1))
Next 'X
Next 'Y
Sub WhereDidItComeFrom(src() As Float, dst() As Float, dstxy() As Float) As Float()
'dst must be rectangle with top-left = (0, 0)
Dim dstwidth As Float = dst(4)
Dim dstheight As Float = dst(5)
Dim dstx As Float = dstxy(0)
Dim dsty As Float = dstxy(1)
Dim HowMuchRight As Float = dstx / dstwidth
Dim HowMuchLeft As Float = 1 - HowMuchRight
Dim HowMuchBottom As Float = dsty / dstheight
Dim HowMuchTop As Float = 1 - HowMuchBottom
'if we are lucky then these should sum to 1.0
Dim HowMuchTopLeft As Float = HowMuchTop * HowMuchLeft
Dim HowMuchTopRight As Float = HowMuchTop * HowMuchRight
Dim HowMuchBottomLeft As Float = HowMuchBottom * HowMuchLeft
Dim HowMuchBottomRight As Float = HowMuchBottom * HowMuchRight
Dim srcx As Float = src(0) * HowMuchTopLeft _
+ src(2) * HowMuchTopRight _
+ src(4) * HowMuchBottomRight _
+ src(6) * HowMuchBottomLeft
Dim srcy As Float = src(1) * HowMuchTopLeft _
+ src(3) * HowMuchTopRight _
+ src(5) * HowMuchBottomRight _
+ src(7) * HowMuchBottomLeft
Dim srcxy() As Float = Array As Float(srcx, srcy)
Return srcxy()
End Sub