```
Method drawTexture(x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float, x4:Float, y4:Float)
Local curX:Float = x1
If x2 < curX Then curX = x2
If x3 < curX Then curX = x3
If x4 < curX Then curX = x4
Local startX:Float = curX
Local maxX:Float = x1
If x2 > maxX Then maxX = x2
If x3 > maxX Then maxX = x3
If x4 > maxX Then maxX = x4
Local sw:Float = (maxX - curX) / 256.0
If sw = 0 Then Return
Local ys:Float[4]
ys[0] = y1
ys[1] = y2
ys[2] = y3
ys[3] = y4
'yuck!
For Local i:Int = 0 To 2
If ys[i+1] < ys[i] Then
Local f:Float = ys[i]
ys[i] = ys[i+1]
ys[i+1] = f
i-=1
End If
Next
Local minY:Float = ys[0]
Local minY2:Float = ys[1]
Local maxY:Float = ys[3]
Local curY:Float = minY
Local curY2:Float = maxY
Local sh:Float = (minY2-minY) / 256.0
If angle>90 And angle<=180 Or angle>=270 Then curY = ys[1]; curY2 = ys[2]
For Local curX:Int = 0 To 255
PushMatrix()
Translate startX + curX*sw, curY
Local sy:Float
sy = (curY2 - curY) / 256.0
Scale sw, sy
If angle>90 And angle<270 Then
DrawImageRect Resources.imgCard.image, 0, 0, 255-curX, 0,1,256
Else
DrawImageRect Resources.imgCard.image, 0, 0, curX, 0,1,256
End If
PopMatrix()
If angle<=90 Or (angle>=180 And angle<270) Then
curY+=sh
curY2-=sh
Else
If angle<=180 Or angle>=270 Then
curY-=sh
curY2+=sh
End If
End If
Next
End Method
```