Bitmap/Bézier curves/Cubic: Difference between revisions
Content added Content deleted
m (→{{header|zkl}}: update) |
(→{{header|XPL0}}: More efficient version) |
||
Line 1,009: | Line 1,009: | ||
[[File:CubicXPL0.png|right]] |
[[File:CubicXPL0.png|right]] |
||
<lang XPL0>include c:\cxpl\codes; \intrinsic 'code' declarations |
<lang XPL0>include c:\cxpl\codes; \intrinsic 'code' declarations |
||
func real Power(X, Y); \X raised to the Y power; (X > 0.0) |
|||
real X, Y; |
|||
return Exp(Y * Ln(X)); |
|||
proc Bezier(P0, P1, P2, P3); \Draw cubic Bezier curve |
proc Bezier(P0, P1, P2, P3); \Draw cubic Bezier curve |
||
Line 1,017: | Line 1,014: | ||
def Segments = 8; |
def Segments = 8; |
||
int I; |
int I; |
||
real T, |
real S1, T, T2, T3, U, U2, U3, B, C, X, Y; |
||
[Move(fix(P0(0)), fix(P0(1))); |
[Move(fix(P0(0)), fix(P0(1))); |
||
S1:= 1./float(Segments); |
|||
T:= 0.; |
|||
for I:= 1 to Segments-1 do |
for I:= 1 to Segments-1 do |
||
[T:= |
[T:= T+S1; |
||
T2:= T*T; |
|||
T3:= T2*T; |
|||
U:= 1.-T; |
|||
U2:= U*U; |
|||
U3:= U2*U; |
|||
B:= 3.*T*U2; |
|||
C:= 3.*T2*U; |
|||
X:= U3*P0(0) + B*P1(0) + C*P2(0) + T3*P3(0); |
|||
Y:= U3*P0(1) + B*P1(1) + C*P2(1) + T3*P3(1); |
|||
Line(fix(X), fix(Y), $00FFFF); \cyan line segments |
Line(fix(X), fix(Y), $00FFFF); \cyan line segments |
||
]; |
]; |