Nice Leonardo da Vinci Bezier, just a click away

Michael Kristensen michael-kristensen at dsa-net.dk
Thu Nov 3 06:25:32 EDT 2011


Hi there

Here is a nice Leonardo da Vinci Bezier, just a click away

Make a new big wd

Make a new button up in the left corner
Make a Custom Prop of the button called LeoPoints and fill in these points:

640,265
670,256
697,268
690,293
682,325
717,281
716,334
712,386
671,374
668,378
676,388
693,394
698,400
698,400
768,392
791,411
797,411
827,399
851,414
878,399
963,416
977,407
990,396
1059,383
1065,408
1072,432
996,446
986,440
964,427
905,465
851,446
805,462
733,432
723,476
720,496
706,540
708,575
716,591
706,597
708,605
714,643
708,677
709,683
723,718
706,838
695,857
698,877
692,888
687,902
689,976
681,1053
695,1071
709,1089
766,1091
774,1104
782,1116
741,1116
706,1110
687,1108
670,1115
662,1115
651,1105
659,1102
659,1088
657,1053
638,1031
642,997
623,975
634,905
637,896
648,847
642,803
640,748
634,776
629,811
629,844
627,874
616,894
610,910
615,931
624,973
615,993
619,1017
623,1017
621,1052
630,1058
635,1069
634,1077
632,1085
665,1118
646,1119
612,1119
607,1123
597,1111
590,1100
596,1091
599,1069
588,1047
547,964
571,899
567,885
575,858
580,842
569,824
556,743
564,687
563,663
561,635
572,608
575,600
575,575
582,558
571,528
561,498
556,477
549,432
479,462
434,446
380,465
319,427
297,440
287,446
212,436
218,408
224,383
293,399
306,410
320,419
405,399
432,414
460,394
497,416
503,411
525,392
585,400
585,400
590,394
607,394
616,378
613,374
571,386
569,334
566,281
599,325
594,293
594,293
590,259
640,265

Then set the script of the button to:

on mouseUp
   lock screen
   new grc
   set the style of last grc to "Polygon"   --the Bezier control cage, going to be invisible
   set the name of last grc to "cLine1"
   set the visible of grc "cLine1" to false
   set the points of grc "cLine1" to the LeoPoints of me
   
   new grc
   set the style of last grc to "Polygon"   --the visible figure
   set the name of last grc to "Poly1"
   set the opaque of grc "Poly1" to true
   set the backgroundColor of grc "Poly1" to 237,205,147
   
   put the points of grc "cLine1" into cList
   
   put number of lines of clist into nLines
   
   repeat with i = 1 to nLines-3 step 3
      --startpoint
      put item 1 of line i of cList into x0
      put item 2 of line i of cList into y0
      
      --first control point
      put item 1 of line i+1 of cList into x1
      put item 2 of line i+1 of cList into y1
      
      --second control point
      put item 1 of line i+2 of cList into x2
      put item 2 of line i+2 of cList into y2
      
      --endpoint
      put item 1 of line i+3 of cList into x3
      put item 2 of line i+3 of cList into y3
      
      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
      
      put 17 into PT  --so many points for each curve

   repeat with z = 0 to PT
      put z/PT into t
      put A*t^3 + B*t^2 + C*t + D into x
      put E*t^3 + F*t^2 + G*t + H into y
      put round(x) & "," & round(y) & return after pList
   end repeat
end repeat

set the points of grc "Poly1" to pList

new grc
set the style of last grc to "Rectangle"
set the height of last grc to height of grc "Poly1"
set the width of last grc to width of grc "Poly1"
set the loc of last grc to loc of grc "Poly1"

new grc
set the style of last grc to "Oval"
set the height of last grc to (height of grc "Poly1")*1.2
set the width of last grc to (width of grc "Poly1")*1.2
set the loc of last grc to loc of grc "Poly1"
set the bottom of last grc to bottom of grc "Poly1"
end mouseUp

Now CLICK the button!

Michael



More information about the use-livecode mailing list