ANN: Stars

Alejandro Tejada capellan2000 at gmail.com
Sat Jun 23 22:08:59 EDT 2012


Hi Francois,


François Chaplais-3 wrote
> 
> Thanks Alejandro. The actual link is
> http://www.jamesphurley.com/RunRev/BezierLine.rev
> I will have a deep look at the stack and how it relates to interpolation.
> Best regards
> 

I used these 3 different Bezier drawing handlers in this stack:
http://andregarzia.on-rev.com/alejandro/stacks/Eps_Import_V04.zip

One handler is based in Don Lancaster's code,
other handler uses Matrices and another
handler uses the very first code that
I published many, many years ago...

Could you guess which is faster? :-)

Although I have not looked in detail, the stack
SVGL must have different handlers to draw
Quadratic and Bezier curves.

http://revonline2.runrev.com/stack/112/SVGL

NOTE: 
global varBezierSegment contains
a series of coordinates points
that draw the graphic on the card.

for example:

145,234
146,236
148,239
149,241
150,244
etc...
 
global variables named a,b,c,d
contains four coordinates points
of the bezier segment

for example:
A segment of an Adobe illustrator file:
96 62 m
96 69 101 1555 107 1555 C

a = 96,62 
b = 96,69
c = 101,1555
d = 107,1555

The field named fld "BezierResolution" and 
the variable named "cde" should contain
a number from 16 to 800.
This is the number of rectilinear segments
in a bezier segment...

on bezier1
  global varBezierSegment,a,b,c,d
  put the first item of a into x1
  put the first item of d into x2
  put the first item of b into xa
  put the first item of c into xb
  put the second item of a into y1
  put the second item of d into y2
  put the second item of b into ya
  put the second item of c into yb
  put 0 into v1
  
  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 -- a number from 16 to 800
    put i * ( 1 / cde ) into v1
    put 1 - v1 into v2
    put (x1 * (v2 ^ 3) + (3 * xa * v1 * v2 * v2) + (3 * xb * v1 * v1 * v2) +
(x2 * (v1 ^ 3))) into x
    put (y1 * (v2 ^ 3) + (3 * ya * v1 * v2 * v2) + (3 * yb * v1 * v1 * v2) +
(y2 * (v1 ^ 3))) into y
    if varBezierSegment is not empty then put last line of varBezierSegment
into varTemp
    if x div 1,y div 1 <> varTemp then put x div 1,y div 1 & return after
varBezierSegment
  end repeat
end bezier1
----------------------------------------------------------------
on bezier2

  /* this is the custom property bm1
  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
  */

 /* this is the custom property bm2
  [p0]
  [p1]
  [p2]
  [p3]
  1,1 0
  1,2 0
  1,3 0
  1,4 0
  */
  
  /* this is the custom property bm3
  1,1 0
  2,1 0
  3,1 0
  4,1 0
  */

  global varBezierSegment,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
  
  put 0 into v1
  
  put the bm1 of me into qwe12
  split qwe12 by return and space

  put the bm2 of me into qwy12
  put the bm2 of me into qwx12
  
  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
  
  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 varBezierSegment is not empty then put last line of varBezierSegment
into varTemp
    if pX div 1,pY div 1 <> varTemp then put pX div 1,pY div 1 & return
after varBezierSegment
    
  end repeat
end bezier2
----------------------------------------------------------------
on bezier3
  global varBezierSegment,a,b,c,d
  
  put the first item of a into x3
  put the second item of a into y3
  put the first item of b into x2
  put the second item of b into y2
  put the first item of c into x1
  put the second item of c into y1
  put the first item of d into x0
  put the second item of d into y0
  put 0 into v1
  
  put (x3 - 3 * x2 + 3 * x1 - x0) into A
  put (3 * x2 - 6 * x1 + 3 * x0) into B
  put (3 * x1 - 3 * x0)  into C
  put (x0) into D
  put (y3 - 3 * y2 + 3 * y1 - y0) into E
  put (3*y2 - 6 * y1 + 3 * y0) into F
  put (3 * y1 - 3 * y0) into G
  put (y0) into H
  
 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 -- a number from 16 to 800
    put i * ( 1 / cde ) into v1
    put 1 - v1 into t
    put ((((A * t) + B)* t) + C) * t + D into x
    put ((((E* t) + F)* t) + G) * t + H into y
    if varBezierSegment is not empty then put last line of varBezierSegment
into varTemp
    if x div 1,y div 1 <> varTemp then put x div 1,y div 1 & return after
varBezierSegment
  end repeat
  
end bezier3

Have a nice weekend!

Al

--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/ANN-Stars-tp4651129p4651208.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list