From: Jonas Hochfelder on
Hello newsgroup!
I have spent the whole day trying to recreate an image that I've seen.
This image uses beziers to create a "swirl".
For those who are willing to help, here is the image I'm talking about:
http://www.kristanixsoftware.com/buttonshop/example-buttons.php
It's the image at the bottom of the page over the button with the star
on it. It's left to the green button with the "angeled" caption.
This button has a bezier that divides the button into 2 halfes. My
attemps at recreating this button are the following:
I am not sure how I can awake your interest in helping me, but it would
be very nice if you did so.
My problem is that I don't know how Beziers really work, and there's
something wrong in my code.
Maybe it's only something for mathematicians, I don't know...
Thank you, Jonas!

Public Function RoundRectSwirlFromFullRect(ByRef r As RECTF, ByVal r1 As
Single, ByVal r2 As Single, ByVal r3 As Single, ByVal r4 As Single) As
clsWApath

Dim X As Single
Dim Y As Single
Dim w As Single
Dim h As Single

X = r.Left
Y = r.Top
w = r.Right - r.Left
h = r.Bottom - r.Top

Dim rr As clsWApath
Set rr = New clsWApath

With rr
' \
Call rr.Append_Bezier(X + w - r2, Y + r2, X + w, Y, X + w, Y +
r2, X + w, Y + r2)
' |
Call rr.Append_Line(X + w, Y + r2, X + w, Y + h - r3)
' /
Call rr.Append_Bezier(X + w, Y + h - r3, X + w, Y + h, X + w -
r3, Y + h, X + w - r3, Y + h)
'__
Call rr.Append_Line(X + w - r3, Y + h, X + r4, Y + h)
'\_
Call rr.Append_Bezier(X + r4, Y + h, X, Y + h, X, Y + h - r4,
X, Y + h - r4)

Call rr.Append_Bezier(X, Y + h - r4, X + (w \ 2), Y + h, X + (w
\ 2), Y + r2, X + w, Y + r2)

Call rr.ClosePath
End With

Set RoundRectSwirlFromFullRect = rr

End Function
From: Larry Serflaten on

"Jonas Hochfelder" <hochfelderj2000(a)gmx.de> wrote

> I have spent the whole day trying to recreate an image that I've seen.
> This image uses beziers to create a "swirl".

It looks to me like a simple application of Cos.

Ex: On new form:

Private Sub Form_Paint()
Dim a, b
Cls
Me.Scale (0, -101)-(1000, 101)
b = 0!
For a = 0 To 1000
PSet (a, 100 * Cos(b))
b = b + 0.0031
Next
End Sub

Private Sub Form_Resize()
Refresh
End Sub



LFS


From: dot nyet on
On Thu, 3 Jul 2008 22:50:46 -0500, "Larry Serflaten"
<serflaten(a)usinternet.com> wrote:
in <eUIqIjY3IHA.1808(a)TK2MSFTNGP04.phx.gbl>

>
>"Jonas Hochfelder" <hochfelderj2000(a)gmx.de> wrote
>
>> I have spent the whole day trying to recreate an image that I've seen.
>> This image uses beziers to create a "swirl".
>
>It looks to me like a simple application of Cos.
>
>Ex: On new form:
>
>Private Sub Form_Paint()
>Dim a, b
> Cls
> Me.Scale (0, -101)-(1000, 101)
> b = 0!
> For a = 0 To 1000
> PSet (a, 100 * Cos(b))
> b = b + 0.0031
> Next
>End Sub
>
>Private Sub Form_Resize()
> Refresh
>End Sub
>
>
>
>LFS
>

Larry, you consistently provide the most concise simple learning
examples in this group and you've been doing that for a long time. I
sincerely applaud you. What a great breakdown of the problem and a nice
little demonstration example to boot.

Frank
From: Jonas Hochfelder on
Yes, theoretically this seems to be right, thank you.
But the problem is that it's not only this "wave", but also it's filled.
Hard to explain without a paper to draw onto...
I mean I really must use this Append_Bezier stuff.
Could somebody take a look again? I don't know how to handle these
control points...

This is the function for appending the bezier:

Public Function Append_Bezier(ByVal X1 As Single, ByVal Y1 As Single, _
ByVal CtrlPtX1 As Single, ByVal CtrlPtY1 As Single, _
ByVal CtrlPtX2 As Single, ByVal CtrlPtY2 As Single, _
ByVal X2 As Single, ByVal Y2 As Single)
From: senn on

"Jonas Hochfelder" <hochfelderj2000(a)gmx.de> skrev i en meddelelse
news:uNpPrlc3IHA.4988(a)TK2MSFTNGP04.phx.gbl...
> Yes, theoretically this seems to be right, thank you.

Would rather say -practically !.

> But the problem is that it's not only this "wave", but also it's filled.
> Hard to explain without a paper to draw onto...
> I mean I really must use this Append_Bezier stuff.
> Could somebody take a look again? I don't know how to handle these control
> points...
>

It won't help you drawing a Bezier. As you can't fill
but a closed curve. You can however draw a closed
Bezier curve in GDI+ and afterwards create it and fill
it. Dont know, if alike can be done with APIs alone
- without GDI+.

Why not construct a bitmap of that kind in PhotoDraw.
And load that in to a Buttons picture property.

/senn