Slow bezier function using matrices
Alejandro Tejada
capellan2000 at yahoo.com
Mon Jun 7 12:55:36 EDT 2004
Hi Developers,
I have included a bezier drawing function that
uses matrices in the stack "EPS Import v04n"
that you could download from my website:
http://geocities.com/capellan2000/Eps_Import_V04.zip
I expect that matrix operations where always faster
than other math operations but this is not the case,
so i want that you comment my use of matrices in this
handler.
With your help, maybe this could be made faster or
at least as fast like the other two handlers used to
draw the bezier lines.
You could see this handler in the button "bz2" of
the stack ""EPS Import v04n"
on bezier2
global variablezxc,a,b,c,d
put the first item of a into x1
put the second item of a into y1
put the first item of b into xa
put the second item of b into ya
put the first item of c into xb
put the second item of c into yb
put the first item of d into x2
put the second item of d into y2
-- the variables a,b,c,d contains numbers derived
-- from lines of adobe ilustrator code like these:
-- 32.7526 m
-- 12.45589 25.1687 45.6821 C
put 0 into v1
put the bm1 of me into qwe12
split qwe12 by return and space
-- converts qwe12 in array
/* The custom property bm1 contains:
1,1 -1
1,2 3
1,3 -3
1,4 1
2,1 3
2,2 -6
2,3 3
2,4 0
3,1 -3
3,2 3
3,3 0
3,4 0
4,1 1
4,2 0
4,3 0
4,4 0
*/
put the bm2 of me into qwy12
put the bm2 of me into qwx12
/* The custom property bm2 contains:
[p0]
[p1]
[p2]
[p3]
1,1 0
1,2 0
1,3 0
1,4 0
*/
put x2 into word 2 of line 1 of qwx12
put xb into word 2 of line 2 of qwx12
put xa into word 2 of line 3 of qwx12
put x1 into word 2 of line 4 of qwx12
put y2 into word 2 of line 1 of qwy12
put yb into word 2 of line 2 of qwy12
put ya into word 2 of line 3 of qwy12
put y1 into word 2 of line 4 of qwy12
split qwx12 by return and space
split qwy12 by return and space
/* [t^3 t^2 t 1] this is the custom property bm3
1,1 0
2,1 0
3,1 0
4,1 0
*/
if there is a fld "BezierResolution" then put /
fld "BezierResolution" into cde
if cde is not a number then put "32" into cde
Repeat with i = 1 TO cde
put i * (1/cde) into v1
put 1 - v1 into v2
put the bm3 of me into qws12
put v2^3 into word 2 of line 1 of qws12
put v2^2 into word 2 of line 2 of qws12
put v2 into word 2 of line 3 of qws12
put 1 into word 2 of line 4 of qws12
split qws12 by return and space
put matrixMultiply(qwe12,qws12) into qwz12
put matrixMultiply(qwx12,qwz12) into pX
put matrixMultiply(qwy12,qwz12) into pY
combine pX using space
combine pY using space
if variablezxc is not empty then put last line of
/
variablezxc into mlpokn
if pX div 1,pY div 1 <> mlpokn then /
put pX div 1,pY div 1 & return after variablezxc
-- put pX div 1,pY div 1 & return after
variablezxc
end repeat
end bezier2
Thanks in advance.
al
=====
Visit my site:
http://www.geocities.com/capellan2000/
Search the mail list:
http://mindlube.com/cgi-bin/search-use-rev.cgi
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
More information about the metacard
mailing list