Bitmap/Bézier curves/Cubic: Difference between revisions

Content added Content deleted
(Added solution for Action!)
(Using Real Math module)
Line 124: Line 124:
{{libheader|Action! Bitmap tools}}
{{libheader|Action! Bitmap tools}}
{{libheader|Action! Tool Kit}}
{{libheader|Action! Tool Kit}}
{{libheader|Action! Real Math}}
<lang Action!>INCLUDE "H6:RGBLINE.ACT" ;from task Bresenham's line algorithm
<lang Action!>INCLUDE "H6:RGBLINE.ACT" ;from task Bresenham's line algorithm
INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
INCLUDE "H6:REALMATH.ACT"


RGB black,yellow,violet,blue
RGB black,yellow,violet,blue


TYPE IntPoint=[INT x,y]
TYPE IntPoint=[INT x,y]

INT FUNC MyRealToInt(REAL POINTER r)
BYTE ARRAY x
REAL tmp
INT i

x=r
IF (x(0)&$80)=0 THEN
i=RealToInt(r)
ELSE
RealAssign(r,tmp)
x=tmp
x(0)==&$7F
i=-RealToInt(tmp)
FI
RETURN (i)


PROC CubicBezier(RgbImage POINTER img
PROC CubicBezier(RgbImage POINTER img
Line 188: Line 173:
RealMult(rd,x4,tmp1) ;tmp1=d*x4
RealMult(rd,x4,tmp1) ;tmp1=d*x4
RealAdd(tmp2,tmp1,tmp3) ;tmp3=a*x1+b*x2+c*x3+d*x4
RealAdd(tmp2,tmp1,tmp3) ;tmp3=a*x1+b*x2+c*x3+d*x4
nextX=MyRealToInt(tmp3)
nextX=Round(tmp3)


RealMult(ra,y1,tmp1) ;tmp1=a*y1
RealMult(ra,y1,tmp1) ;tmp1=a*y1
Line 197: Line 182:
RealMult(rd,y4,tmp1) ;tmp1=d*y4
RealMult(rd,y4,tmp1) ;tmp1=d*y4
RealAdd(tmp2,tmp1,tmp3) ;tmp3=a*y1+b*y2+c*y3+d*y4
RealAdd(tmp2,tmp1,tmp3) ;tmp3=a*y1+b*y2+c*y3+d*y4
nextY=MyRealToInt(tmp3)
nextY=Round(tmp3)


IF i>0 THEN
IF i>0 THEN