Page 1 of 1

Curve functions

Posted: Fri Aug 07, 2015 4:15 pm
by Dutchman
Based on the Bezier3-function posted by Henko, I have made a 'library' of "curve functions" by which bezier-curves can be designed and plot.
In order to compact the code I have used complex numbers for the coordinates. It made the code a lot simpler and indeed more compact. An x,y coordinate is now handled as x+y*1i.
I added some gain to the handles so that the top of the curve can reach the length of the handles. Otherwise the 'handling'-area should be larger then the drawing area.
Touch-info is handled such that the point which is moved can be moved close to or on other points.

The file "curve functions" contains the functions with info on usage
The file "Curve functions demo" is a test and demo-program.
The file "- Read Me" gives some basic information.

The files are available on Dropbox at:
https://www.dropbox.com/sh/8gk14ixlg5x4 ... rBWAa?dl=0.

The following screenshot is a reduced version from iPad
reduced screenshot.PNG
reduced screenshot.PNG (66.84 KiB) Viewed 1248 times
The following is a screenshot from ipad in which the display is tested on iPhone-size.
iPhone size on iPad.PNG
iPhone size on iPad.PNG (34.05 KiB) Viewed 1248 times

Re: Curve functions

Posted: Sat Aug 08, 2015 7:02 am
by Dutchman
I forgot to simplify the equations in the Bezier-function.
It is corrected now in the Dropbox-files as follows:

Code: Select all

DEF Bezier3G(p(),xx(),yy())
'gain' and 'points' should be preset
'---- apply gain to handlesize
DIM q(2)
q(1)=p(1)+gain*(p(2)-p(1))
q(2)=p(4)+gain*(p(3)-p(4))
'---- draw curve
DRAW TO REAL(p(1)),IMAG(p(1))
t=0 ! delta=1/(points-1)
FOR i=1 TO points
  tm=1-t ! tt=3*t*tm
  a=tm^3 ! b=tm*tt ! c=t*tt ! d=t^3
  xy=a*p(1)+b*q(1)+c*q(2)+d*p(4)
  x=REAL(xy) ! y=IMAG(xy)
  xx(i)=x ! yy(i)=y
  DRAW LINE TO x,y 'in current color
  t+=delta
NEXT i
END DEF