Bezier

Post Reply
DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Bezier

Post by DrChip »

Code: Select all

rem bezier
rem iPhone 6 Plus / 8.3 b2
rem enjoy...

gosub initialize


main:
 do
  de=de-1
  if de=0 then
   de=cd
   dm=(dm+1)%mdm
  end if

  ang=ang+1
  if ang>360 then ang=ang-360

  
  graphics clear 0,0,0

  for a=1 to mp
   ax=asi(ang+a*mlt)*sw/2
   ay=aco(ang+a*mlt)*sh/2
   avx=asi(ang*10)*80
   avy=aco(ang*10)*80
   aaa=a+1
   if a=mp then aaa=1
   dx=asi(ang+aaa*mlt)*sw/2
   dy=aco(ang+aaa*mlt)*sh/2
   dvx=aco(ang*10)*80
   dvy=asi(ang*10)*80
   gosub drawbezier '(ax,ay,dx,dy,avx,avy,dvx,dvy)
  next a
 until 1=2
return



drawbezier: '(ax,ay,dx,dy,avx,avy,dvx,dvy)
 'new curve
 bx=ax+avx
 by=ay+avy
 cx=dx+dvx
 cy=dy+dvy

 for t=0 to 1 step 0.05
  aa=t
  bb=1-t
  x=ax*bb^3+3*bx*bb^2*aa+(3*cx)*bb*aa^2+dx*aa^3
  y=ay*bb^3+3*by*bb^2*aa+(3*cy)*bb*aa^2+dy*aa^3
  fill color x,y,-x-y
  draw color x,y,-x-y
  si=asi(ang)*20
  if dm=0 then fill rect x,y to x+1,y+1
  if dm=1 then draw line to x,y
  if dm=2 then draw line 0,0 to x,y
  if dm=3 then draw line x,y to -x,-y
  if dm=4 then fill rect x-si,y-si to x+si,y+si
  if dm=5 then draw line x,y to y,x
  if dm=6 then draw line x,y to x*4,y*4
  if dm=6 then draw line 0,0 to y,x
  if dm=7 then draw line x,0 to 0,y
  if dm=8 then draw line x,y to asi(ang*10)*100,aco(ang*10)*100
 next t
return

initialize:
 graphics
 
 sw=screen_width()
 sh=screen_height()
 pi=3.1415
 mdm=9
 cd=200
 de=cd

 dim aco(3601),asi(3601)
 f=3.14/180
 for a=0 to 3600
  aco(a)=cos(a*f)
  asi(a)=sin(a*f)
 next a

 mp=4
 mlt=360/mp
return
Attachments
image.jpg
image.jpg (111.71 KiB) Viewed 3155 times
image.jpg
image.jpg (91.84 KiB) Viewed 3155 times
image.jpg
image.jpg (251.83 KiB) Viewed 3155 times
image.jpg
image.jpg (234.08 KiB) Viewed 3155 times
image.jpg
image.jpg (228.88 KiB) Viewed 3155 times
image.jpg
image.jpg (109.72 KiB) Viewed 3155 times
image.jpg
image.jpg (114.15 KiB) Viewed 3155 times
image.jpg
image.jpg (102.67 KiB) Viewed 3155 times

Post Reply