[REBOL] Re: Beziere curve example
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