(long a demarrer plus l'image est grosse mais preferez des logos comme vos noms en couleurs differentes)
Code : Tout sélectionner
InitSprite()
InitMouse()
InitKeyboard()
;SetPriorityClass_ ( GetCurrentProcess_ (), #IDLE_PRIORITY_CLASS )
Global dw.w,dh.w,SPH_Z,SPH_NOMBRE
If ExamineDesktops()
dw=DesktopWidth(0)
dh=DesktopHeight(0)
If OpenScreen(dw,dh,32,"")
Else
Goto autre
EndIf
Else
autre:
dw=1280
dh=1024
If OpenScreen(dw,dh,32,"")
Else
dw=1280
dh=960
If OpenScreen(dw,dh,32,"")
Else
dw=1280
dh=800
If OpenScreen(dw,dh,32,"")
Else
dw=1280
dh=768
If OpenScreen(dw,dh,32,"")
Else
dw=1280
dh=720
If OpenScreen(dw,dh,32,"")
Else
dw=1024
dh=768
If OpenScreen(dw,dh,32,"")
Else
dw=1024
dh=600
If OpenScreen(dw,dh,32,"")
Else
MessageRequester("Erreur", "OpenScreen impossible")
End
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
;;;;;;;;;;;;;;
;LoadSprite(0,"d:\PureBasic\PB\SPH.bmp")
LoadSprite(0,"d:\image.bmp")
;LoadSprite(0,"SPH.bmp")
DisplaySprite(0,0,0)
SPH_x=SpriteWidth(0)
SPH_y=SpriteHeight(0)
;;;;;;;;;;;
;;;;;;;;;;;
cmb=0
StartDrawing(ScreenOutput())
For u=0 To SPH_y-1
For i=0 To SPH_x-1
x=Point(i,u)
If x>0
cmb+1
EndIf
Next
Next
StopDrawing()
xx1=Random(dw-1-SPH_x)
yy1=Random(dh-1-SPH_y)
xx2=Random(dw-1-SPH_x)
yy2=Random(dh-1-SPH_y)
nb=cmb
nb2=0
cmb=0
;;;;;;;;;;;
nombre=9
Dim x.f(nombre)
Dim y.f(nombre)
Dim oux.w(40)
Dim ouy.w(40)
For i=0 To 40
oux(i)=Random(dw-1-SPH_x)
ouy(i)=Random(dh-1-SPH_y)
Next
;;;;;;;;;;;
Global Dim p.w(nb,2500)
Procedure bspline(x0,y0,x1,y1,x2,y2,x3,y3,n,cmb)
For z = 0 To SPH_Z-1;149
t1.f = z/SPH_Z;150
t2.f = t1*t1
t3.f = t1*t1*t1
k1.f = 1 - 3*t1 + 3*t2 - t3
k2.f = 4 - 6*t2 + 3*t3
k3.f = 1 + 3*t1 + 3*t2 - 3*t3
xfinal.f = (x0 * k1 + x1 * k2 + x2 * k3 + x3 * t3) / 6
yfinal.f = (y0 * k1 + y1 * k2 + y2 * k3 + y3 * t3) / 6
;Plot (xfinal,yfinal,RGB(0,255,0))
;Debug 9+z*2+n*140
If xfinal<0
xfinal=0
EndIf
If yfinal<0
yfinal=0
EndIf
If xfinal>dw-1-p(cmb,0)
xfinal=dw-1
EndIf
If yfinal>dh-1-p(cmb,1)
yfinal=dh-1
EndIf
;
;Plot(p(i,9+p(i,5)*2)+p(i,0),p(i,10+p(i,5)*2)+p(i,1),RGB(p(i,2),p(i,3),p(i,4)))
p(cmb,9+z*2+n*SPH_Z*2)=xfinal
p(cmb,10+z*2+n*SPH_Z*2)=yfinal
; If z=SPH_Z-1
; p(cmb,8)=(SPH_NOMBRE+1)*SPH_Z;900
; EndIf
Next z
EndProcedure
StartDrawing(ScreenOutput())
For u=0 To SPH_y-1
For i=0 To SPH_x-1
x=Point(i,u)
If x>0
cmb+1
p(cmb,0)=i
p(cmb,1)=u
p(cmb,2)=Red(x)
p(cmb,3)=Green(x)
p(cmb,4)=Blue(x)
x=Random(Random(2000))
p(cmb,5)=-Random(Random(Random(1000)))-x+Random(Random(x))
p(cmb,6)=xx1
p(cmb,7)=yy1
SPH_Z=120+Random(80)
SPH_NOMBRE=nombre-4-Random(2)
; SPH_Z=200
; SPH_NOMBRE=nombre-4
p(cmb,8)=(SPH_NOMBRE+1)*SPH_Z;900
For n=0 To nombre
x(n)=Random(dw-1-SPH_x)
y(n)=Random(dh-1-SPH_y)
x=Random(Random(Random(40)))
;x=Random(Random(40))
x(n)=oux(x)
y(n)=ouy(x)
;x(n)=oux(Random(Random(Random(20))))
;y(n)=ouy(Random(Random(Random(20))))
Next
x(0)=xx1 : y(0)=yy1
x(1)=xx1 : y(1)=yy1
x(2)=xx1 : y(2)=yy1
x(SPH_NOMBRE+1)=xx2 : y(SPH_NOMBRE+1)=yy2
x(SPH_NOMBRE+2)=xx2 : y(SPH_NOMBRE+2)=yy2
x(SPH_NOMBRE+3)=xx2 : y(SPH_NOMBRE+3)=yy2
For n=0 To SPH_NOMBRE;nombre-4 ; On trace la bspline
bspline(x(n),y(n),x(n+1),y(n+1),x(n+2),y(n+2),x(n+3),y(n+3),n,cmb)
Next
;End
;*********************************************
p(cmb,9+p(cmb,8)*2)=xx2
p(cmb,10+p(cmb,8)*2)=yy2
EndIf
Next
Next
StopDrawing()
; If cmb<>nb
; End
; EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
debut:
Repeat
ClearScreen(0)
;ExamineMouse()
;*****
StartDrawing(ScreenOutput())
;;;;;;;;;;;
For i=1 To nb
If p(i,5)<>32700
p(i,5)+1
If p(i,5)=p(i,8)
p(i,5)=32700
nb2+1
EndIf
EndIf
If p(i,5)<0
Plot(p(i,6)+p(i,0),p(i,7)+p(i,1),RGB(p(i,2),p(i,3),p(i,4)))
Else
; Plot(p(i,9+p(i,8))+p(i,0),p(i,10+p(i,8))+p(i,1),RGB(p(i,2),p(i,3),p(i,4)))
If p(i,5)<>32700
Plot(p(i,9+p(i,5)*2)+p(i,0),p(i,10+p(i,5)*2)+p(i,1),RGB(p(i,2),p(i,3),p(i,4)))
Else
Plot(p(i,9+p(i,8)*2)+p(i,0),p(i,10+p(i,8)*2)+p(i,1),RGB(p(i,2),p(i,3),p(i,4)))
EndIf
EndIf
Next
;zz+1 : zz%(dw) : Plot(zz,0,RGB(0,255,0))
;;;;;;;;;;;
StopDrawing()
;*****
FlipBuffers()
If nb2=nb
Gosub dta
Goto debut
EndIf
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
;;;;;;;
;;;;;;;
;;;;;;;
dta:
nb2=0
xx1=xx2
yy1=yy2
xx2=Random(dw-1-SPH_x)
yy2=Random(dh-1-SPH_y)
Dim oux.w(40)
Dim ouy.w(40)
For i=0 To 40
oux(i)=Random(dw-1-SPH_x)
ouy(i)=Random(dh-1-SPH_y)
Next
For ii=1 To nb
x=Random(Random(2000))
p(ii,5)=-Random(Random(Random(1000)))-x+Random(Random(x))
p(ii,6)=xx1
p(ii,7)=yy1
SPH_Z=120+Random(80)
SPH_NOMBRE=nombre-4-Random(2)
p(ii,8)=(SPH_NOMBRE+1)*SPH_Z;900
For n=0 To nombre
x(n)=Random(dw-1-SPH_x)
y(n)=Random(dh-1-SPH_y)
x=Random(Random(Random(40)))
;x=Random(Random(40))
x(n)=oux(x)
y(n)=ouy(x)
;x(n)=oux(Random(Random(Random(20))))
;y(n)=ouy(Random(Random(Random(20))))
Next
x(0)=xx1 : y(0)=yy1
x(1)=xx1 : y(1)=yy1
x(2)=xx1 : y(2)=yy1
x(SPH_NOMBRE+1)=xx2 : y(SPH_NOMBRE+1)=yy2
x(SPH_NOMBRE+2)=xx2 : y(SPH_NOMBRE+2)=yy2
x(SPH_NOMBRE+3)=xx2 : y(SPH_NOMBRE+3)=yy2
For n=0 To SPH_NOMBRE;nombre-4 ; On trace la bspline
bspline(x(n),y(n),x(n+1),y(n+1),x(n+2),y(n+2),x(n+3),y(n+3),n,ii)
Next
p(ii,9+p(ii,8)*2)=xx2
p(ii,10+p(ii,8)*2)=yy2
Next
Return