Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Beziere curve example

 [1/12] from: rebol-list2::seznam::cz at: 15-Jan-2003 13:34


Hello rebol-list, I've just made one simple script without any serious reason... ... so injoy it if you want... =( Oliva David )=======================( [oliva--david--seznam--cz] )== =( Earth/Europe/Czech_Republic/Brno )============================= =( coords: [lat: 49.22 long: 16.67] )============================= -- Attached file included as plaintext by Listar -- -- File: bezier-curve.r REBOL [ title: "Bezier Curve" author: "Oldes" note: {Inspired by Cyphre's Spline demo and by one Flash file} ] drawcurve: has [result pp x0 x1 x2 x3 y0 y1 y2 y3 cx bx ax cy by ay t tx ty s] [ result: make block! 20 pp: p0/size/x / 2 x0: p0/offset/x + pp y0: p0/offset/y + pp x1: p1/offset/x + pp y1: p1/offset/y + pp x2: p2/offset/x + pp y2: p2/offset/y + pp x3: p3/offset/x + pp y3: p3/offset/y + pp insert result compose [ pen 155.0.0 line (p0/offset + pp) (p1/offset + pp) line (p2/offset + pp) (p3/offset + pp) pen 255.255.255 line (p0/offset + pp) ] cx: 3 * (x1 - x0) bx: 3 * (x2 - x1) - cx ax: x3 - x0 - cx - bx cy: 3 * (y1 - y0) by: 3 * (y2 - y1) - cy ay: y3 - y0 - cy - by t: s: 0.01 ;this value sets quality of the curve while [t <= 1][ tx: to integer! ( (ax * (t * t * t)) + (bx * (t * t)) + (cx * t) + .5 ) + x0 ty: to integer! ( (ay * (t * t * t)) + (by * (t * t)) + (cy * t) + .5 ) + y0 t: t + s insert tail result to pair! reduce [tx ty] ] return result ] click?: false mouse-pos: 0x0 fl: [ effect: [draw [pen 255.0.0 fill-pen 200.0.0 circle 4x4 4]] feel: make feel [ engage: func [f a e][ if find [down] a [ click?: true mouse-pos: e/offset ] if find [up] a [ click?: false ] if find [over away] a [ if click? [ f/offset: f/offset + e/offset - mouse-pos f/changes: [offset] bkg/effect: compose/deep [draw [(drawcurve)]] show [bkg f] ] ] ] ] ] view layout [ origin 0 bkg: box black 400x400 at 300x200 p0: box 10x10 with fl at 200x100 p1: box 10x10 with fl at 200x300 p2: box 10x10 with fl at 100x200 p3: box 10x10 with fl do [bkg/effect: compose/deep [draw [(drawcurve)]]] ]

 [2/12] from: greggirwin:mindspring at: 15-Jan-2003 17:49


Very nice Oldes!! -- Gregg

 [3/12] from: anton:lexicon at: 16-Jan-2003 17:49


Yes, good work! I hope you will put it on your rebsite. Anton.

 [4/12] from: rebolek:seznam:cz at: 16-Jan-2003 7:56


oh, impressive!! but how can I add points on curve? ;) bolek

 [5/12] from: cyphre:seznam:cz at: 16-Jan-2003 9:55


----- Original Message ----- From: "Boleslav Brezovsky" <[rebolek--seznam--cz]> To: <[rebol-list--rebol--com]> Sent: Thursday, January 16, 2003 7:56 AM Subject: [REBOL] Re: Beziere curve example
>oh, impressive!! >but how can I add points on curve? ;)
That's the reason why I haven't released my spline demo yet ;-) I'm glad Oldes at least mentioned me in the Rebol header :-P regards, Cyphre PS: Oldes, don't take it bad but next time please don't spread parts of my code from the Developer server without my knowledge...thats why I have stored some of my unfinished scripts and ideas on IOS ;-)

 [6/12] from: james:mustard at: 16-Jan-2003 22:49


A simple way to add points to a single bezier is to use an image colour sampling like the following: bkg: box black 400x400 feel [ engage: func [f a e][ if a = 'down [ if (pick to-image bkg e/offset/x + ((e/offset/y - 1) * f/size/x)) 255.255.255.0 [add-a-point] ] ] ] The downside to this method is that you are restricted to 16777216 colours... :) James.

 [7/12] from: rebol-list2:seznam:cz at: 17-Jan-2003 12:16


Hello Anton, Thursday, January 16, 2003, 7:49:27 AM, you wrote: A> Yes, good work! A> I hope you will put it on your rebsite. I should, and I should also replace current scripts with the new Rebol/View compatible ones as well:) Maybe that's the reason why Carl didn't released the new View yet:)) I will probably publicate my scripts on some html page as well (as soon as I'll finish somethink what I call RSS - Rebol Source Safe :)) =( Oliva David )=======================( [oliva--david--seznam--cz] )== =( Earth/Europe/Czech_Republic/Brno )============================= =( coords: [lat: 49.22 long: 16.67] )=============================

 [8/12] from: rebol-list2:seznam:cz at: 17-Jan-2003 11:39


Hello Cyphre, Thursday, January 16, 2003, 9:55:54 AM, you wrote: C> ----- Original Message ----- C> From: "Boleslav Brezovsky" <[rebolek--seznam--cz]> C> To: <[rebol-list--rebol--com]> C> Sent: Thursday, January 16, 2003 7:56 AM C> Subject: [REBOL] Re: Beziere curve example
>>oh, impressive!! >>but how can I add points on curve? ;)
C> That's the reason why I haven't released my spline demo yet ;-) C> I'm glad Oldes at least mentioned me in the Rebol header :-P C> regards, C> Cyphre C> PS: Oldes, don't take it bad but next time please don't spread parts of my C> code from the Developer server without my knowledge...thats why I have C> stored some of my unfinished scripts and ideas on IOS ;-) ehm... I think you do not mean it in serious way. If you look at your script and my, you may see that only one same thing is the 'fl block, because the draw function for beziere type of curve is different from your spline curve. I just wanted to test it, i have no serious reason to use it (just wanted to make something funny). Your script is in IOS unchanged since 23.October 2002. So don't tell me that you still wanted to make somethink with it. That will not speed any Rebol progress at all if you don't share (even not finished) code with other people than a few of us on IOS. I think that the Rebol community is so small so why to cut it even more? You should rather look at my code and your code and make your code better (for example using slow for loop in such a way as you use it is bad idea!) oldes. PS: i've attached modified version where is even less of your code. and I'm looking forward when you release you much more better version:) ...and.... I almost forgot why I have posted it here... I think that the way how draw effect now works is not sufficient... it would be much more better if there would be somethink like drawing port where the drawing commands (as are used in the draw effect) would be processed (drawn) directly into image (is it understandable?) Just consider you would like to draw image from hundrets of curves. You should first make a really large block of draw commands or make a lot of unnecessary to-image calls:( Could someone ask Carl about that issue? =( Oliva David )=======================( [oliva--david--seznam--cz] )== =( Earth/Europe/Czech_Republic/Brno )============================= =( coords: [lat: 49.22 long: 16.67] )============================= -- Attached file included as plaintext by Listar -- -- File: bezier-curve.r REBOL [ title: "Bezier Curve" author: "Oldes" note: {Inspired by Cyphre's Spline demo and by one Flash file} ] draw-beziere-curve: has [result pp x0 x1 x2 x3 y0 y1 y2 y3 cx bx ax cy by ay t tx ty s] [ result: make block! 120 pp: p0/size/x / 2 x0: p0/offset/x + pp y0: p0/offset/y + pp x1: p1/offset/x + pp y1: p1/offset/y + pp x2: p2/offset/x + pp y2: p2/offset/y + pp x3: p3/offset/x + pp y3: p3/offset/y + pp insert result compose [ pen 155.0.0 line (p0/offset + pp) (p1/offset + pp) line (p2/offset + pp) (p3/offset + pp) pen 255.255.255 line (p0/offset + pp) ] cx: 3 * (x1 - x0) bx: 3 * (x2 - x1) - cx ax: x3 - x0 - cx - bx cy: 3 * (y1 - y0) by: 3 * (y2 - y1) - cy ay: y3 - y0 - cy - by t: s: 0.01 ;this value sets quality of the curve while [t <= 1][ tx: to integer! ( (ax * (t * t * t)) + (bx * (t * t)) + (cx * t) + .5 ) + x0 ty: to integer! ( (ay * (t * t * t)) + (by * (t * t)) + (cy * t) + .5 ) + y0 t: t + s insert tail result to pair! reduce [tx ty] ] return result ] click?: false mouse-pos: 0x0 view layout [ origin 0 bkg: box black 400x400 with [effect: reduce ['draw make block! 120]] style point box 10x10 with [ effect: [draw [pen 0.255.0 fill-pen 0.200.0 circle 4x4 4]] changes: [offset] feel: make feel [ engage: func [f a e][ if a = 'down [click?: on mouse-pos: e/offset] if a = 'up [click?: off] if find [over away] a [ if click? [ f/offset: f/offset + e/offset - mouse-pos bkg/effect/2: draw-beziere-curve show [bkg f] ] ] ] ] ] at 300x200 p0: point at 200x100 p1: point at 200x300 p2: point at 100x200 p3: point do [bkg/effect/2: draw-beziere-curve] ] halt

 [9/12] from: andreas:bolka:gmx at: 18-Jan-2003 17:01


Friday, January 17, 2003, 11:16:31 AM, RebOldes wrote:
> (as soon as I'll finish somethink what I call RSS - Rebol Source > Safe :))
hu, that sounds too promising - i'm really looking forward to the safe :) -- Best regards, Andreas mailto:[andreas--bolka--gmx--net]

 [10/12] from: cyphre:seznam:cz at: 18-Jan-2003 20:20


Hi Oldes, Bolek and all here, Take my apologies if my words sounded to much offensive...sometimes I have strange cynical sense of humor most people don't understand. And it seems this becomes even worse when I'm trying to express such cynical comments in my crippled non-native english language. I'll try to restrict such statements as much as possible in the future posts... BTW you demo is very nice...I hope I'll find a time to merge our efforts in that area. regards, Cyphre

 [11/12] from: steve:shireman:semaxwireless at: 20-Jan-2003 7:27


I enjoyed it. Some of the best programmers in the world come from Czech_Republic. There must be good schools or the right technical attitude there. I met some software designers from MatLab (spelling?) some years ago at the embedded system west conference in San Jose, and they were brilliant and creative. Thanks for the script, Steve Shireman RebOldes wrote:

 [12/12] from: petr:krenzelok:trz:cz at: 20-Jan-2003 15:01


Steve Shireman wrote:
> I enjoyed it. Some of the best programmers in the world come from > Czech_Republic. There must be good schools or the right technical > attitude there.
And good marketing (just me, only talking, not coding, always knowing what should be done, without real knowledge how to actually do it :-)
> I met some software designers from MatLab (spelling?) some years ago > at the embedded system west conference in San Jose, and they were > brilliant and creative.
Yes, folks from Humusoft .... they are one of top supporters of Matlab. Maybe you also met folks from WebControl - our astronomy friends :-) Hmm, and hopefully soon enough some thing regarding rebol are going to be better organised here in Cz, so we can become a rebol form of Humusoft :-) -pekr-