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

Using Real Math module
(Added solution for Action!)
(Using Real Math module)
Line 124:
{{libheader|Action! Bitmap tools}}
{{libheader|Action! Tool Kit}}
{{libheader|Action! Real Math}}
<lang Action!>INCLUDE "H6:RGBLINE.ACT" ;from task Bresenham's line algorithm
INCLUDE "D2H6:REALREALMATH.ACT" ;from the Action! Tool Kit
 
RGB black,yellow,violet,blue
 
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
Line 188 ⟶ 173:
RealMult(rd,x4,tmp1) ;tmp1=d*x4
RealAdd(tmp2,tmp1,tmp3) ;tmp3=a*x1+b*x2+c*x3+d*x4
nextX=MyRealToIntRound(tmp3)
 
RealMult(ra,y1,tmp1) ;tmp1=a*y1
Line 197 ⟶ 182:
RealMult(rd,y4,tmp1) ;tmp1=d*y4
RealAdd(tmp2,tmp1,tmp3) ;tmp3=a*y1+b*y2+c*y3+d*y4
nextY=MyRealToIntRound(tmp3)
 
IF i>0 THEN
Anonymous user