ПроЭктировщик
Регистрация: 17.07.2009
Сообщений: 182
Написано 51 полезных сообщений (для 71 пользователей)
|
изображение на полигон 2d
Возможно ,вам пригодиться ...
код под спойлером :
;
Global x#[3] , y#[3] ,Dragging=False
Global grx,gry
Global mx#,my#,mz%
x[0] = 100 : y[0]=100
x[1] = 40 : y[1]=120
x[2] = 170 : y[2]=150
Graphics 800,600,32,2
SetBuffer BackBuffer()
grx = GraphicsWidth()/2 : gry = GraphicsHeight()/2
; ВАШЕ изображение
mm = LoadImage ("D:\blitz\numberscroll.bmp")
width =ImageWidth(mm ) : height =ImageHeight(mm )
ClsColor 128,128,128
While Not KeyHit(1)
Cls
mx = MouseX() : my = MouseY() : mz = MouseZ()
For i=0 To 2
If Dist( x[i], y[i], mx, my )<10 And Dragging=False Then
Rect x[i] - 4,y[i]-4,8,8,0
DragPoint=i
If MouseDown(1) Then Dragging=True
EndIf
If MouseDown(1)=False And Dragging=True Then
Dragging=False
EndIf
If Dragging Then
x[DragPoint]=MouseX()
y[DragPoint]=MouseY()
EndIf
Next
Color 28,28,28
tt# = 0.7/Dist( X[1], Y[1], X[2], Y[2] )
ss# =0.7/Dist( X[1], Y[1], X[0], Y[0] )
s# = 0.0
LockBuffer ImageBuffer(mm)
LockBuffer BackBuffer()
While s< 1
t# = 0.0
While t< 1
xxx# =( (width-2.7) *t)+0.7
yyy# =((height-2.7)*s )+0.7
If xxx>= 0 And xxx<GraphicsWidth() And yyy >= 0 And yyy < GraphicsHeight()
pix = ReadPixel (xxx,yyy,ImageBuffer(mm))
EndIf
xx# = x[0] + s*(x[1]-x[0]) + t*(x[2]-x[1])
yy# = y[0] + s*(y[1]-y[0]) + t*(y[2]-y[1])
If xx=> 0 And xx<GraphicsWidth() And yy => 0 And yy < GraphicsHeight()
WritePixel xx,yy,pix
EndIf
t = t + tt
Wend
s = s + ss
Wend
UnlockBuffer BackBuffer()
UnlockBuffer ImageBuffer(mm)
Color 0,255,0
For k = 0 To 2
Rect x[k]-2,y[k]-2,4,4,1
Next
;Text 20,20 , mt+" "
Flip
Wend
End
Function Dist#( X1#, Y1#, X2#, Y2# )
Return ((X1 - X2)*(X1 - X2) + (Y1 - Y2)*(Y1 - Y2))^0.5
End Function
__________________
Мой проект здесь
|