vs GUI Updates - the latest from b+
#37
OK I have reworked the slider code. Since it comes in a picture box there is already a label we can use to keep it self contained all-in-one slider box.

and I reworked it again 2022-08-12, sorry just trying to get it right! The 3.4100000001 values in slider labels were making me crazy when they were supposed to be 3.41! So I added Steve's N2S$ for converting sci notation to normal layman and added my Round2$ function for rounding the display number to dp or 10^dp place in the decimal number eg, -2 = hundreths

Here is screen shot of the remake 2022-08-12:
   
I used 2 decimals with first slider, w, 3 for next, D, and 4 decimals for last two variables L, B.

And look how simple the code is! (2022-08-12 code just added 4 lines to code posted yesterday)

Code: (Select All)
Option _Explicit ' b+ 2022-08-11 & 12
'$include:'vs GUI.BI'

'   Set Globals from BI
Xmax = 1210: Ymax = 620: GuiTitle$ = "remake GUI b+ Mod of vince Designer Egg"
OpenWindow Xmax, Ymax, GuiTitle$, "arial.ttf" ' << arial works well for pixel sizes 6 to 128 .FontH
_ScreenMove 30, 40 ' <<< centers for a 1380 x 700 Screen area, you may prefer another center
' GUI Controls
'                     Dim and set Globals for GUI app
Dim Shared As Long picEgg, picw, picD, picL, picB
picEgg = NewControl(5, 10, 10, 800, 600, 20, 40, 393, "Designer Egg")
picw = NewControl(5, 820, 64, 380, 65, 18, 999, 555, "")
picD = NewControl(5, 820, 203, 380, 65, 18, 999, 555, "")
picL = NewControl(5, 820, 342, 380, 65, 18, 999, 555, "")
picB = NewControl(5, 820, 481, 380, 65, 18, 999, 555, "")
' End GUI Controls

Dim Shared S, B, L, w, D ' globals for Egg drawing
S = 80: L = 5.4: B = 4.1: w = .4: D = 3.2 '< These are Vince starting parameter values for good egg

Dim Shared Sliders(3) As Slider
Sliders(0).Label = "w = "
Sliders(0).Low = 0
Sliders(0).High = 1
Sliders(0).Value = .4
Sliders(0).DecPt = -2

Sliders(1).Label = "D = "
Sliders(1).Low = 2.8
Sliders(1).High = 3.6
Sliders(1).Value = 3.2
Sliders(1).DecPt = -3

Sliders(2).Label = "L = "
Sliders(2).Low = 4.4
Sliders(2).High = 6.4
Sliders(2).Value = 5.4
Sliders(2).DecPt = -4

Sliders(3).Label = "B = "
Sliders(3).Low = 3.6
Sliders(3).High = 4.6
Sliders(3).Value = 4.1
Sliders(3).DecPt = -4

drwEgg ' up date picEgg
drwHSlider picw, 0, -1
drwHSlider picD, 1, -1
drwHSlider picL, 2, -1
drwHSlider picB, 3, -1
MainRouter ' after all controls setup

Sub BtnClickEvent (i As Long)
    i = i
End Sub

Sub LstSelectEvent (control As Long)
    control = control
End Sub

Sub PicClickEvent (i As Long, Pmx As Long, Pmy As Long)
    Pmy = Pmy
    Select Case i
        Case picw
            drwHSlider picw, 0, Pmx
            w = Sliders(0).Value
            drwEgg
        Case picD
            drwHSlider picD, 1, Pmx
            D = Sliders(1).Value
            drwEgg
        Case picL
            drwHSlider picL, 2, Pmx
            L = Sliders(2).Value
            drwEgg
        Case picB
            drwHSlider picB, 3, Pmx
            B = Sliders(3).Value
            drwEgg
    End Select
End Sub

Sub PicFrameUpdate (i As Long)
    i = i
End Sub

Sub drwEgg ' makes an image the size of the picBox and give it the picEgg N1 handle
    Dim xx, x, a, y, aa, sh, sw
    Dim As Long sd
    sh = Con(picEgg).H: sw = Con(picEgg).W
    sd = _Dest
    _Dest Con(picEgg).N1
    Line (0, 0)-(Con(picEgg).W, Con(picEgg).H), &HFF000000, BF ' cls

    For xx = -0.5 * L * S To 0.5 * L * S
        x = xx / S
        a = (L * L - 4 * x * x) / (L * L + 8 * w * x + 4 * w * w)
        y = 0.5 * B * Sqr(a)
        'you can stop here for p(x) = x

        a = Sqr(5.5 * L * L + 11 * L * w + 4 * w * w)
        a = a * (Sqr(3) * B * L - 2 * D * Sqr(L * L + 2 * w * L + 4 * w * w))
        a = a / (Sqr(3) * B * L * (Sqr(5.5 * L * L + 11 * L * w + 4 * w * w) - 2 *_
         Sqr(L * L + 2 * w * L + 4 * w * w)))

        aa = L * (L * L + 8 * w * x + 4 * w * w)
        aa = aa / (2 * (L - 2 * w) * x * x + (L * L + 8 * L * w - 4 * w * w) * x +_
         2 * L * w * w + L * L * w + L * L * L)
        aa = 1 - aa

        y = y * (1 - a * aa)

        Line (sw / 2 + xx, sh / 2 - S * y)-(sw / 2 + xx, sh / 2 + S * y), &HFFFFFFFF
    Next
    'ok now that N1 has been updated
    _Dest sd
    drwPic picEgg, 0
End Sub

'$include:'vs GUI.BM'
 
Perfect little demo for horz. sliders

Zip has the revised BI/BM code to do the new sliders.

EDIT 2022-08-12 everything completely changed out for label fix in Sliders, you can now spec the decimal precision to display.


Attached Files
.zip   2022-08-12 GUI b+ mod vince Designer Egg.zip (Size: 561.01 KB / Downloads: 37)
b = b + ...
Reply


Messages In This Thread
vs GUI Updates - the latest from b+ - by bplus - 07-27-2022, 02:42 PM
RE: vs GUI 2022-07-27 Update - by bplus - 07-27-2022, 03:11 PM
RE: vs GUI 2022-07-27 Update - by bplus - 07-27-2022, 03:28 PM
RE: vs GUI 2022-07-27 Update - by SierraKen - 07-27-2022, 03:48 PM
RE: vs GUI 2022-07-27 Update - by bplus - 07-27-2022, 04:04 PM
RE: vs GUI 2022-07-27 Update - by bplus - 07-27-2022, 08:08 PM
RE: vs GUI 2022-07-27 Update - by bplus - 07-27-2022, 08:26 PM
RE: vs GUI 2022-07-27 Update - by vince - 08-08-2022, 12:05 AM
RE: vs GUI 2022-07-27 Update - by bplus - 07-27-2022, 08:49 PM
RE: vs GUI 2022-07-27 Update - by bplus - 07-29-2022, 02:37 AM
RE: vs GUI 2022-07-27 Update - by bplus - 08-02-2022, 11:51 PM
RE: vs GUI 2022-07-27 Update - by bplus - 08-03-2022, 06:06 PM
RE: vs GUI 2022-07-27 Update - by bplus - 08-04-2022, 02:01 AM
RE: vs GUI 2022-07-27 Update - by bplus - 08-04-2022, 11:46 PM
RE: vs GUI Update - by bplus - 08-05-2022, 01:25 AM
RE: vs GUI Updates - the latest from b+ - by bplus - 08-12-2022, 03:31 AM
RE: vs GUI Updates - the latest from b+ - by Pete - 12-02-2022, 03:27 AM
RE: vs GUI Updates - the latest from b+ - by dbox - 12-06-2022, 05:57 PM
RE: vs GUI Updates - the latest from b+ - by Pete - 12-22-2022, 09:19 AM
RE: vs GUI Updates - the latest from b+ - by Pete - 12-22-2022, 04:56 PM



Users browsing this thread: 38 Guest(s)