GDI+ Swiss Railway Clock v1.30 build 2024-01-25 [Windows only!]

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

GDI+ Swiss Railway Clock v1.30 build 2024-01-25 [Windows only!]

Post by UEZ »

Here an Implementation of the famous Swiss Railway Clock incl. bouncing minute needle. "It requires only about 58.5 seconds to circle the face, then the hand pauses briefly at the top of the clock. It starts a new rotation as soon as it receives the next minute impulse from the master clock." -> https://en.wikipedia.org/wiki/Swiss_railway_clock

WINDOWS ONLY!!!

Image

Image

Code: Select all

The source code has become too long to publish here. See below for download options.
Example ini file for the purple clock:

Code: Select all

[Settings]
SwissRailwayClock=0
x=1762
y=874
WinSize=160
Autostart=-1
ShowDate=-1
AlwaysOnTop=1
ShowSeconds=0
Transparency=255
BgTransparency=255
ClickThru=-1
ScreenL=0
ScreenT=0
ScreenR=1920
ScreenB=1080
ScreenW=1920
ScreenH=1080
Snap=1
SnapGap=20
SecondHandTyp=3
ClockSecondHandStepping=-1
ShowLogo=1
ShowShadowBorder=1
ShowBrushedBorder=1
ShowClockDial=0
ShowShadowSecondHand=0
ShowShadowMinuteHand=0
ShowShadowHourHand=0
ShadowColor=0x20A0A0A0
ClockDialColorBig=0xFF000000
ClockDialColorSmall=0xFF000000
ClockBgColorStart=0x009932CC
ClockBgColorEnd=0x00F2A2E8
ClockMinuteHandColor=0xFF36013F
ClockHourHandColor=0xFF36013F
ClockSecondHandColor=0xFFC01010
ClockCenterRingColor=0xAFDCD0FF
ClockCenterBottomColor=0xFF101010
ClockBrandingColor=0xF0000000
Needed resource files incl. compiled exe can be found here: GDI+ Swiss Railway Clock v1.30 build 2024-01-25.zip or on my OneDrive

Or here: GDI+ Swiss Railway Clock 1.29 Build 2024-01-17

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2018-02-24: changed to base91 string for the embedded FB logo (must be saved in ANSI format!)
2018-02-25: crunched FB logo to 2 lines in base91 format and added x64 compile functionality (thx srvaldez)
2018-03-01: changed GUI to widget style
2018-03-03: added blurred clock shadow and added gradient frame color
2018-03-04: windows size and position will be saved to an ini file
2018-03-06: added tray icon "Exit" and "Reset" function
2018-03-07: added "Autostart" functionality using the registry
2018-03-09: added sub GUI to change GUI size and GUI transparency, added menu entry to alter "always on top" behavior
2018-04-03: added sub GUI to change GUI background transparency, added menu entry to click thru the UI, auto positioning UI when it is out of visible screen
2019-06-14: added DPI awareness code for Vista+ os
2019-07-04: some small code / gfx modifications
2023-06-19: add GUI snap to screen borders (multi monitor supported)
2024-01-17: option added on request to not display clock second hand, added option to display date in the clock, added a small About intro
2024-01-25: add more clock customize options (check trayicon). Some settings are only changeable in the ini file especially the color values
Last edited by UEZ on Jan 25, 2024 20:34, edited 37 times in total.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by dodicat »

Nice clock uez.
I cannot remember these clocks in railway stations over here.
Perhaps a continental device.

I remember some ships clocks being run by a master. (You are continually changing the clocks for changing longitudes).
Here is a much simpler clock, using a string and the DRAW parser.
The first time the second hand crosses 12 it synchronises correctly.
The program starts at a one second resolution form TIME, which means of course it could be out by one second at startup, but TIMER and
TIME merge within a minute.

Code: Select all


Function GetClock() As String
     Dim As String fbHORSE = _
"S1C0BM345,150M+5,-27M+3,-25M+4,-21M+6,-10M+15,-10"_
&"M+5,-4M+11,-4M+8,0M+2,4M+48,1M+15,7"_
&"M+15,7M+12,10M+12,13M+19,27M+7,15M+6,13"_
&"M+7,7M+23,5M+39,-9M+37,-10M+20,-1M+24,3"_
&"M+30,5M+18,-10M+34,-23M+15,-3M+18,6M+15,11"_
&"M+12,15M+2,28M+5,39M+-5,18M+-17,38M+-7,14"_
&"M+-20,34M+-12,21M+-4,9M+-2,3M+-1,37M+4,9"_
&"M+-4,1M+-9,-7M+-7,-17M+-3,-30M+6,-38M+23,-59"_
&"M+4,-29M+-3,-21M+-13,-17M+-10,-6M+-13,-4M+-17,0"_
&"M+-6,3M+5,18M+11,28M+0,27M+-3,15M+-7,13"_
&"M+-10,16M+-12,11M+-9,11M+-9,10M+6,19M+8,13"_
&"M+5,6M+6,12M+-4,11M+-12,17M+-14,13M+-10,13"_
&"M+-8,13M+-7,10M+-4,11M+-12,6M+-8,3M+-5,11"_
&"M+0,6M+-28,-9M+3,-12M+8,-8M+13,-7M+8,-5"_
&"M+12,-10M+9,-16M+10,-15M+12,-15M+0,-10M+-3,-13"_
&"M+-2,-8M+-5,1M+-3,12M+-8,9M+-12,13M+-10,13"_
&"M+-7,16M+-8,15M+-5,8M+-8,11M+-9,9M+-13,12"_
&"M+-3,9M+273,4M+0,13M+-382,-1M+-1,-12M+71,-3"_
&"M+20,-21M+27,-20M+28,-41M+6,-14M+5,-20M+-19,-35"_
&"M+-7,-10M+-8,-7M+-9,-4M+-16,7M+-12,3M+-29,0"_
&"M+-22,1M+-14,21M+-13,27M+-13,19M+-12,30M+-7,22"_
&"M+-4,19M+-7,22M+31,3M+-1,15M+-171,-1M+-2,-13"_
&"M+95,-2M+13,-8M+15,-9M+8,-13M+8,-21M+5,-32"_
&"M+5,-22M+9,-21M+8,-22M+8,-19M+-3,-4M+-17,5"_
&"M+-9,3M+-69,0M+-4,7M+-4,12M+5,17M+9,10"_
&"M+13,14M+11,10M+10,3M+12,4M+4,11M+-2,12"_
&"M+-8,7M+-8,-4M+-20,-14M+-15,-13M+-36,-56M+-2,-19"_
&"M+7,-14M+15,-8M+48,-20M+-7,-26M+5,-11M+1,-11"_
&"M+7,-7M+6,-11M+8,-18M+3,-18M+-1,-14M+-4,-10"_
&"M+-6,-11M+-8,1M+-14,12M+-7,10M+-3,15M+-6,8"_
&"M+-12,-2M+-16,-6M+-4,-17M+1,-16"_
&"BM+191,77P4294967295,0"
    Dim As String S1,tmp
    dim as long Xpos=400,Ypos=300,rad=395
    #macro thickline(x,y,x2,y2,thickness,col,g,flag2)
    Scope
        Dim As Long xc,yc
        Var _x=Int(x),_y=Int(y),_x2=Int(x2),_y2=Int(y2)
        Dim As Single h=Sqr((_x2-_x)*(_x2-_x)+(_y2-y)*(_y2-y))  'hypotenuse
        Dim As Single s=(y-_y2)/h                               'sine
        Dim As Single c=(_x2-_x)/h                              'cosine
        If flag2=1 Then
            g+="S6BM" &(_x) &"," &(_y)'hands
            xc=(_x+_x2)\2:yc=(_y+_y2)\2
        Else
            g+="S6BM" &(xpos) &"," &(ypos)'digits
            g+="BM+" &(_x-xpos) &"," &(_y-ypos)
            xc=((_x+_x\2)-xpos\2+c*thickness):yc=((_y+_y\2)-ypos\2-s*thickness)
        End If
        g+="C" &col
        g+="M+" &(s*thickness\2) &"," &(c*thickness\2)
        g+="M+" &(_x2-_x) &"," &(_y2-_y)
        g+="M+" &(-s*thickness\1) &"," &(-c*thickness\1)
        g+="M+" &(_x-_x2) &"," &(_y-_y2)
        g+="M+" &(s*thickness\1) &"," &(c*thickness\1)
        g+="BM" &(xc) &"," &(yc) &"P" &(col+2) &"," &col
    End Scope
    #endmacro
    
    #define rd .0174532925199433
    #define map(a,b,x,c,d) ((d)-(c))*((x)-(a))/((b)-(a))+(c)
    
    #macro mod12(n,m)
    m= n Mod 12
    If m=0 Then m=12 
    #endmacro
    
    #macro lineto(xx1,yy1,xx2,yy2,d,col,flag2,fract)
    thickline(xx1,yy1,(xx1+(xx2-xx1)*d),(yy1+(yy2-yy1)*d),(rad/fract),col,tmp,flag2)
    s1+=tmp
    #endmacro
    
    #macro drawline(x,y,ang,length,col,x2,y2,flag,flag2)
    ang2=ang:ang2=ang2*.0174532925199433
    x2=(x)+length*Cos(ang2)
    y2=(y)-length*Sin(ang2)
    If flag>1 Then :thickline(x,y,x2,y2,(rad/flag),col,tmp,flag2):s1+=tmp:End If
    #endmacro
    
    #macro one(x,y,fract,a)
    drawline((x+210*Cos((90-a)*rd)),(y-210*Sin((90-a)*rd)),90-(a),fract,grey,tmp1,tmp2,100,1)
    #endmacro
    
    #macro V(x,y,fract,a)
    drawline((x+210*Cos((90-a)*rd)),(y-210*Sin((90-a)*rd)),90-(a-12),fract,grey,tmp1,tmp2,100,1)
    drawline((x+210*Cos((90-a)*rd)),(y-210*Sin((90-a)*rd)),90-(a+12),fract,grey,tmp1,tmp2,100,1)
    #endmacro
    
    #macro X(x,y,fract,a)
    drawline((x+210*Cos((90-(a+2))*rd)),(y-210*Sin((90-(a+2))*rd)),90-(a-18),fract,grey+1,tmp1,tmp2,100,1)
    drawline((x+210*Cos((90-(a-2))*rd)),(y-210*Sin((90-(a-2))*rd)),90-(a+18),fract,grey,tmp1,tmp2,100,1)
    #endmacro
    
    Dim As Ulong grey =Rgb(220,220,221)
    Static As Long newsm,firstrun,firstmin
    Static As Single firstfrac
    Dim As Long m2
    Dim As Single b1,b2,tmp1,tmp2,ang2
    Static As Single delta,secs
    'numbers
    one(400,300,30,30)     '1
    
    one(400,300,30,58.75)  '2
    one(400,300,30,61.25)
    
    one(400,300,30,87.5)   '3
    one(400,300,30,90)
    one(400,300,30,92.5)
    
    one(400,300,30,117.5)  '4
    V(400,300,30,122.5)
    
    V(400,300,30,150)      '5
    
    V(400,300,30,177.5)    '6
    one(400,300,30,182.5)
    
    V(400,300,30,207.5)    '7
    one(400,300,30,212.5)
    one(400,300,30,215)
    
    V(400,300,30,236)      '8
    one(400,300,30,241)
    one(400,300,30,243.5)
    one(400,300,30,246)
    
    one(400,300,30,266.5)
    X(400,300,32,271)      '9
    
    X(400,300,32,300)      '10
    
    X(400,300,32,329)      '11
    one(400,300,30,333.5)
    
    X(400,300,32,357)      '12
    one(400,300,30,1.5)
    one(400,300,30,4.5)
    
    If firstrun=0 Then
        newsm=Valint(Mid(Time,4,2))
        firstrun=1
        delta=Timer
        firstfrac=Valint(Right(Time,2))
    End If
    Dim As String t=Time
    Dim As Single hm=Valint(Left(t,2)),mm=Valint(Mid(t,4,2))
    If newsm<>mm Then 
        firstmin=1
        delta=Timer
    End If
    newsm=mm
    
    If firstmin=0 Then secs=(Timer-delta)+firstfrac Else secs=(Timer-delta)
    
    mod12(hm,m2)
    Dim As Single h=map(0,12,m2,360,0)
    Dim As Single m=map(0,60,mm,360,0)
    Dim As Single s=map(0,60,(secs),360,0)
    Dim As Long R=rad/2
    For z As Long=0 To 359 Step 6
        drawline((Xpos),(Ypos),z,R,15,b1,b2,1,0)
        If z=90 Then: lineto(b1,b2,(Xpos),(Ypos),.1,Rgb(200,0,0),0,50):End If 
        If z Mod 30=0 Then 
            If z<>90 Then:   lineto(b1,b2,(Xpos),(Ypos),.1,Rgb(200,0,0),0,50) :End If
        Else
            lineto(b1,b2,Xpos,Ypos,.05,Rgb(0,0,200),0,50)
        End If
    Next z
    drawline(Xpos,Ypos,(h+90)-5*(360-m)/60,.6*R,Rgb(10,100,200),tmp1,tmp2,50,1)'hour 
    drawline(Xpos,Ypos,(m+90)-(360-s)/60,.85*R,Rgb(10,100,201),tmp1,tmp2,50,1)  'minute 
    drawline(Xpos,Ypos,(s+90),.92*R,Rgb(150,0,0),tmp1,tmp2,100,1)              'second 
    Function=fbHORSE+ s1
End Function

'===========================  START =====================>>

Screen 19,32
color ,rgb(200,200,200)
windowtitle "Roman Clock"
Do
    Var clockstring= GetClock
    Screenlock
    Cls
    Draw Clockstring
    Screenunlock
    Sleep 1,1
Loop Until Inkey=Chr(27)
Sleep

 
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by lizard »

dodicat wrote: Here is a much simpler clock, using a string and the DRAW parser.
Great example for DRAW. How do you produced the "fbHORSE" String?
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by dodicat »

hi lizard.
I did the horse a couple of years back from a small editor I made up.
Took about ten minutes to work my way round the outline.
I copied from a bigger scale scale, S4 is the draw start scale, so the drawing can be scaled down to S1.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by lizard »

Is this editor available somewhere? Looks like what i am working at. The "draw" is fascinating and very quick. But seems only very few are able to use it.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by jj2007 »

Excellent! SmoothingModeAntiAlias makes a big difference.

@dodicat: Your clock is very nice, too, but uses one core of my CPU almost at 100%. I tried to play with the Sleep 1, 1 but no success.
BasicCoder2
Posts: 3909
Joined: Jan 01, 2009 7:03
Location: Australia

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by BasicCoder2 »

lizard wrote:Is this editor available somewhere? Looks like what i am working at. The "draw" is fascinating and very quick. But seems only very few are able to use it.
This was an editor to create relative DRAW strings.
You could load a bitmap image such as one of the fb logo and trace the silhouette and save it as DRAW strings.
It also allowed the generation of animations using the generated DRAW strings.
viewtopic.php?f=8&t=24124&hilit=horse
Tracing a silhouette can also be made automatic.
viewtopic.php?f=7&t=23719&hilit=fbHorse+DRAW
viewtopic.php?f=8&t=23705&hilit=fbHorse+DRAW
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by lizard »

Thanks! Now i have to work through all this stuff.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by dodicat »

jj207
I can draw the actual clock dial to an image.
And only draw the moving hands in the loop.

Code: Select all


Function GetClock(im as any ptr=0) As String
     Dim As String fbHORSE = _
"S1C0BM345,150M+5,-27M+3,-25M+4,-21M+6,-10M+15,-10"_
&"M+5,-4M+11,-4M+8,0M+2,4M+48,1M+15,7"_
&"M+15,7M+12,10M+12,13M+19,27M+7,15M+6,13"_
&"M+7,7M+23,5M+39,-9M+37,-10M+20,-1M+24,3"_
&"M+30,5M+18,-10M+34,-23M+15,-3M+18,6M+15,11"_
&"M+12,15M+2,28M+5,39M+-5,18M+-17,38M+-7,14"_
&"M+-20,34M+-12,21M+-4,9M+-2,3M+-1,37M+4,9"_
&"M+-4,1M+-9,-7M+-7,-17M+-3,-30M+6,-38M+23,-59"_
&"M+4,-29M+-3,-21M+-13,-17M+-10,-6M+-13,-4M+-17,0"_
&"M+-6,3M+5,18M+11,28M+0,27M+-3,15M+-7,13"_
&"M+-10,16M+-12,11M+-9,11M+-9,10M+6,19M+8,13"_
&"M+5,6M+6,12M+-4,11M+-12,17M+-14,13M+-10,13"_
&"M+-8,13M+-7,10M+-4,11M+-12,6M+-8,3M+-5,11"_
&"M+0,6M+-28,-9M+3,-12M+8,-8M+13,-7M+8,-5"_
&"M+12,-10M+9,-16M+10,-15M+12,-15M+0,-10M+-3,-13"_
&"M+-2,-8M+-5,1M+-3,12M+-8,9M+-12,13M+-10,13"_
&"M+-7,16M+-8,15M+-5,8M+-8,11M+-9,9M+-13,12"_
&"M+-3,9M+273,4M+0,13M+-382,-1M+-1,-12M+71,-3"_
&"M+20,-21M+27,-20M+28,-41M+6,-14M+5,-20M+-19,-35"_
&"M+-7,-10M+-8,-7M+-9,-4M+-16,7M+-12,3M+-29,0"_
&"M+-22,1M+-14,21M+-13,27M+-13,19M+-12,30M+-7,22"_
&"M+-4,19M+-7,22M+31,3M+-1,15M+-171,-1M+-2,-13"_
&"M+95,-2M+13,-8M+15,-9M+8,-13M+8,-21M+5,-32"_
&"M+5,-22M+9,-21M+8,-22M+8,-19M+-3,-4M+-17,5"_
&"M+-9,3M+-69,0M+-4,7M+-4,12M+5,17M+9,10"_
&"M+13,14M+11,10M+10,3M+12,4M+4,11M+-2,12"_
&"M+-8,7M+-8,-4M+-20,-14M+-15,-13M+-36,-56M+-2,-19"_
&"M+7,-14M+15,-8M+48,-20M+-7,-26M+5,-11M+1,-11"_
&"M+7,-7M+6,-11M+8,-18M+3,-18M+-1,-14M+-4,-10"_
&"M+-6,-11M+-8,1M+-14,12M+-7,10M+-3,15M+-6,8"_
&"M+-12,-2M+-16,-6M+-4,-17M+1,-16"_
&"BM+191,77P4294967295,0"
    Dim As String S1,tmp
    dim as long Xpos=400,Ypos=300,rad=395
    #macro thickline(x,y,x2,y2,thickness,col,g,flag2)
    Scope
        Dim As Long xc,yc
        Var _x=Int(x),_y=Int(y),_x2=Int(x2),_y2=Int(y2)
        Dim As Single h=Sqr((_x2-_x)*(_x2-_x)+(_y2-y)*(_y2-y))  'hypotenuse
        Dim As Single s=(y-_y2)/h                               'sine
        Dim As Single c=(_x2-_x)/h                              'cosine
        If flag2=1 Then
            g+="S6BM" & (_x) & "," & (_y)'hands
            xc=(_x+_x2)\2:yc=(_y+_y2)\2
        Else
            g+="S6BM" & (xpos) & "," & (ypos)'digits
            g+="BM+" & (_x-xpos) & "," & (_y-ypos)
            xc=((_x+_x\2)-xpos\2+c*thickness):yc=((_y+_y\2)-ypos\2-s*thickness)
        End If
        g+="C" & col
        g+="M+" & (s*thickness\2) & "," & (c*thickness\2)
        g+="M+" & (_x2-_x) & "," & (_y2-_y)
        g+="M+" & (-s*thickness\1) & "," & (-c*thickness\1)
        g+="M+" & (_x-_x2) & "," & (_y-_y2)
        g+="M+" & (s*thickness\1) & "," & (c*thickness\1)
        g+="BM" & (xc) & "," & (yc) & "P" & (col+2) & "," & col
    End Scope
    #endmacro
    
    #define rd .0174532925199433
    #define map(a,b,x,c,d) ((d)-(c))*((x)-(a))/((b)-(a))+(c)
    
    #macro mod12(n,m)
    m= n Mod 12
    If m=0 Then m=12 
    #endmacro
    
    #macro lineto(xx1,yy1,xx2,yy2,d,col,flag2,fract)
    thickline(xx1,yy1,(xx1+(xx2-xx1)*d),(yy1+(yy2-yy1)*d),(rad/fract),col,tmp,flag2)
    s1+=tmp
    #endmacro
    
    #macro drawline(x,y,ang,length,col,x2,y2,flag,flag2)
    ang2=ang:ang2=ang2*.0174532925199433
    x2=(x)+length*Cos(ang2)
    y2=(y)-length*Sin(ang2)
    If flag>1 Then :thickline(x,y,x2,y2,(rad/flag),col,tmp,flag2):s1+=tmp:End If
    #endmacro
 
    #macro one(x,y,fract,a)
    drawline((x+210*Cos((90-a)*rd)),(y-210*Sin((90-a)*rd)),90-(a),fract,grey,tmp1,tmp2,100,1)
    #endmacro
    
    #macro V(x,y,fract,a)
    drawline((x+210*Cos((90-a)*rd)),(y-210*Sin((90-a)*rd)),90-(a-12),fract,grey,tmp1,tmp2,100,1)
    drawline((x+210*Cos((90-a)*rd)),(y-210*Sin((90-a)*rd)),90-(a+12),fract,grey,tmp1,tmp2,100,1)
    #endmacro
    
    #macro X(x,y,fract,a)
    drawline((x+210*Cos((90-(a+2))*rd)),(y-210*Sin((90-(a+2))*rd)),90-(a-18),fract,grey+1,tmp1,tmp2,100,1)
    drawline((x+210*Cos((90-(a-2))*rd)),(y-210*Sin((90-(a-2))*rd)),90-(a+18),fract,grey,tmp1,tmp2,100,1)
    #endmacro
    
    Dim As Ulong grey =Rgb(220,220,221)
    Static As Long newsm,firstrun,firstmin
    Static As Single firstfrac
    Dim As Long m2
    Dim As Single b1,b2,tmp1,tmp2,ang2
    Static As Single delta,secs
       if im<>0 then
    'numbers
    one(400,300,30,30)     '1
    
    one(400,300,30,58.75)  '2
    one(400,300,30,61.25)
    
    one(400,300,30,87.5)   '3
    one(400,300,30,90)
    one(400,300,30,92.5)
    
    one(400,300,30,117.5)  '4
    V(400,300,30,122.5)
    
    V(400,300,30,150)      '5
    
    V(400,300,30,177.5)    '6
    one(400,300,30,182.5)
    
    V(400,300,30,207.5)    '7
    one(400,300,30,212.5)
    one(400,300,30,215)
    
    V(400,300,30,236)      '8
    one(400,300,30,241)
    one(400,300,30,243.5)
    one(400,300,30,246)
    
    one(400,300,30,266.5)
    X(400,300,32,271)      '9
    
    X(400,300,32,300)      '10
    
    X(400,300,32,329)      '11
    one(400,300,30,333.5)
    
    X(400,300,32,357)      '12
    one(400,300,30,1.5)
    one(400,300,30,4.5)
    end if
    If firstrun=0  Then
        newsm=Valint(Mid(Time,4,2))
        firstrun=1
        delta=Timer
        firstfrac=Valint(Right(Time,2))
    End If
   
    Dim As String t=Time
    Dim As Single hm=Valint(Left(t,2)),mm=Valint(Mid(t,4,2))
    If newsm<>mm Then 
        firstmin=1
        delta=Timer
    End If
    newsm=mm
    
    If firstmin=0 Then secs=(Timer-delta)+firstfrac Else secs=(Timer-delta)
    
    mod12(hm,m2)
    Dim As Single h=map(0,12,m2,360,0)
    Dim As Single m=map(0,60,mm,360,0)
    Dim As Single s=map(0,60,(secs),360,0)
    Dim As Long R=rad/2
    if im<>0 then
    For z As Long=0 To 359 Step 6
        drawline((Xpos),(Ypos),z,R,15,b1,b2,1,0)
        If z=90 Then: lineto(b1,b2,(Xpos),(Ypos),.1,Rgb(200,0,0),0,50):End If 
        If z Mod 30=0 Then 
            If z<>90 Then:   lineto(b1,b2,(Xpos),(Ypos),.1,Rgb(200,0,0),0,50) :End If
        Else
            lineto(b1,b2,Xpos,Ypos,.05,Rgb(0,0,200),0,50)
        End If
    Next z
    else
    drawline(Xpos,Ypos,(h+90)-5*(360-m)/60,.6*R,Rgb(10,100,200),tmp1,tmp2,50,1)'hour 
    drawline(Xpos,Ypos,(m+90)-(360-s)/60,.85*R,Rgb(10,100,201),tmp1,tmp2,50,1)  'minute 
    drawline(Xpos,Ypos,(s+90),.92*R,Rgb(150,0,0),tmp1,tmp2,100,1)              'second 
    end if
    if im<>0 then draw im, fbHORSE+ s1
    Function= s1
End Function

'===========================  START =====================>>

Screen 19,32
dim as any ptr image=imagecreate(800,600,rgb(200,200,200))
GetClock(image) 'init image with dial
windowtitle "Roman Clock"

Do
    Var clockstring= GetClock
    Screenlock
    Cls
    put(0,0),image,pset
    Draw Clockstring
    Screenunlock
    Sleep 1,1
Loop Until Inkey=Chr(27)
Sleep
imagedestroy image

  

  
It a little more cpu friendly.
lizard
Here is my own little editor

Code: Select all

'Mouse driven point to point editor.
'Press esc to end with choice of saving.
'right click screen to undo an instruction
dim as string bitmap= "horse.bmp"'if bitmap is valid it will load
dim as integer bitmapFlag
dim as string d
Dim Shared As Integer xres,yres
#define shaped 16 
#define alphablend 64 
#define OnTop 32
#define GetWindowHandle 2
Screeninfo xres,yres
'xres=800
'yres=600
Screenres int(.9*xres),int(.9*yres),32,,SHAPED Or ALPHABLEND Or ONTOP

Type v2
    As Integer x,y
    col As Ulong
    as ushort Bits
End Type
Function Size(bmp As String) As V2 'get bitmap width/height/ colour resolution 
    dim as V2 b
    Open bmp For Binary access read As #1
    Get #1, 19, b.X
    Get #1, 23, b.Y
    get #1, 29, b.Bits
    Close #1
    Return b
End Function
declare function FileLen alias "fb_FileLen" ( byval filename as zstring ptr ) as longint
declare function FileExists alias "fb_FileExists" ( byval filename as zstring ptr ) as integer
dim as any ptr bitmapim
if FileExists(bitmap) then
    bitmapflag=1
    var sz=size(bitmap)
     bitmapim=imagecreate(sz.x,sz.y)
    bload bitmap,bitmapim
    end if

Dim Shared As Integer monitorX,monitorY
Dim Shared As Integer WinposX,WinposY
Screeninfo monitorX,monitorY 
'set up for opaque screen
Extern "windows" Lib "user32"
Declare Function GetDC Alias "GetDC" (Byval As Any Ptr) As Any Ptr
End Extern
Extern "windows" Lib "gdi32"
Declare Function _point Alias "GetPixel"(Byval As Any Ptr,Byval As Integer,Byval As Integer) As Ulong
End Extern
Declare Function SLWA Alias "SetLayeredWindowAttributes" (Byval As Any Ptr, Byval As Uinteger, Byval As Ubyte, Byval As Integer) As Integer
Declare Function NoConsole Alias "FreeConsole"  As Integer
Declare Function _getmouse Alias "GetCursorPos" (Byval As Any Pointer) As Integer
declare function showconsole alias "AllocConsole"() as integer


Sub BlendWindow( Byval Alpha_Value As Ubyte )
    Dim Win As Any Ptr
    var Ip = Cptr(Integer Ptr,@Win )
    Screencontrol GETWINDOWHANDLE, *Ip
    SLWA Win,Rgba(255,0,255,0),Alpha_Value,2 Or 1
End Sub
'---------------------------------------
Type Point
    As Single x,y,r
    As Integer counter
    As Ulong col
End Type
Type screenpoint
    As long x,y
End Type
Sub getmoose(Byref mx As Integer,Byref my As Integer,byref mb as integer=0,byref mw as integer=0)
    getmouse mx,my,mw,mb
    #define _map(a,b,_x_,c,d) ((d)-(c))*((_x_)-(a))/((b)-(a))+(c)
    ScreenControl 0, WinposX,WinposY 
    Dim As screenpoint mouse=Type<screenpoint>(mx,my)
    _getmouse(@mouse)
    mx=_map(0,MonitorX,mouse.x-WinposX,0,MonitorX)
    my=_map(0,monitorY,mouse.y-WinposY,0,MonitorY)
End Sub
#define map(a,b,x,c,d) ((d)-(c))*((x)-(a))/((b)-(a))+(c)
#define inpoint(c,mx,my) (mx)>(c.x-c.r) And (mx)<(c.x+c.r) And (my)>(c.y-c.r) And (my)<(c.y+c.r)
#define Red(col)   cptr(ubyte ptr,@col)[2]
#define Green(col) cptr(ubyte ptr,@col)[1]
#define Blue(col)  cptr(ubyte ptr,@col)[0]
dim shared as integer sx=50,sy=50 'screen start position


Sub moveall
    Dim As Integer mx,my,mb,x,y,dx,dy
    Static As Integer lastmx,lastmy
    Getmouse mx,my,,mb
    Screencontrol 0, x, y
    Static As Integer pressed,moved
    If mb=1 Then pressed=-1 else pressed=0
    If lastmx<>mx Or lastmy<>my Then moved=-1 Else moved=0
    If moved Then dx=lastmx-mx:dy=lastmy-my
    If pressed And moved Then
        Screencontrol 100, x-dx, y - dy 
        sx=x-dx:sy=y-dy
        pressed=0
        Exit Sub
    End If
    lastmx=mx:lastmy=my
End Sub


sub traceover(a() as point, col as ulong,l as integer,im as any ptr=0)
    for n as integer=l to ubound(a)-1
        line im,(a(n).x,a(n).y)-(a(n+1).x,a(n+1).y),col
        next n
    end sub
    
Dim As Point c(1 To 5)         'the four boxes on top
Redim As Point Ccolours(0)     'the coloured boxes below
Redim As Point s(0)           'the array running parallel(Legacy from an older program, but still handy)
Dim As Point slide(1 To 3)    'the colour slider circles

Dim As Any Pointer im=imagecreate(.9*xres,.9*yres,Rgb(0,0,0))
Screeninfo xres,yres
Dim As Any Ptr MyScreen = GetDC(0)
'slider ball circles
slide(1).y=.92*yres:slide(1).r=5:slide(1).col=Rgb(200,0,0)
slide(2).y=.94*yres:slide(2).r=5:slide(2).col=Rgb(0,200,0)
slide(3).y=.96*yres:slide(3).r=5:slide(3).col=Rgb(0,0,200)

'the three larger circles
c(1).x=.3*xres:c(1).y=20:c(1).r=10
c(2).x=.5*xres:c(2).y=20:c(2).r=10
c(3).x=.9*xres:c(3).y=20:c(3).r=10
c(4).x=.7*xres:c(4).y=20:c(4).r=10
c(5).x=.1*xres:c(5).y=25:c(5).r=10
'=========  DRAW STUFF TO AN IMAGE ================
'The colour boxes 
dim as string border=Str(Rgb(0,200,0))',lastborder,starter
Line im,(0,0)-(xres,50),Rgb(100,100,255),bf
Dim As Integer ypos=.9*yres
Dim As Integer _st=.4*xres/25
Dim As Ulong col,tally,total,delta1
Line im,(0,.9*yres)-(xres,yres),Rgb(100,100,255),bf
Line im,(.6*xres,.92*yres)-(.75*xres,.92*yres),Rgb(200,0,0)
Line im,(.6*xres,.94*yres)-(.75*xres,.94*yres),Rgb(0,200,0)
Line im,(.6*xres,.96*yres)-(.75*xres,.96*yres),Rgb(0,0,200)
For y As Integer=_st To 4*_st Step _st
    tally+=1
    For x As Integer=.1*xres To .5*xres Step _st
        total+=1
        delta1=map((.1*xres),(.5*xres),x,0,254)
        Select Case tally
        Case 1: col=Rgb(255,delta1,0)
        Case 2:col=Rgb(0,255,delta1)
        Case 3:col=Rgb(delta1,0,255)
        Case 4:col=Rgb(255-delta1,255-delta1,255-delta1)
        End Select
        Redim Preserve Ccolours(1 To total)
        Ccolours(total)=Type<Point>(x,ypos+y-_st,_st,0,col)
        Line im,(x-_st/2,ypos-_st/2+y)- (x+_st/2,ypos+_st/2+y),col,bf 
        Line im,(x-_st/2,ypos-_st/2+y)- (x+_st/2,ypos+_st/2+y),rgb(0,0,0),b
    Next x
Next y

'================= GRID AND CIRCLES =======================
For x As Integer=0 To xres Step 50
    Line im,(x,50)-(x,yres),Rgba(255,255,255,200)'50 before
Next x
For y As Integer=50 To yres Step 50
    Line im,(0,y)-(xres,y),Rgba(255,255,255,200)
Next y
For z As Integer=1 To 4
    line im,(c(z).x-c(z).r,c(z).y-c(z).r)-(c(z).x+c(z).r,c(z).y+c(z).r),Rgb(255,255,255),b
    'Circle im,(c(z).x,c(z).y),c(z).r+1,Rgb(255,255,255)
Next z
if bitmapflag=1 then line im,(c(5).x-c(5).r,c(5).y-c(5).r)-(c(5).x+c(5).r,c(5).y+c(5).r),Rgb(255,255,255),b
Line im,(0,.9*yres)-(xres,.9*yres),Rgb(0,200,0)
Draw String im,(c(1).x-150,c(1).y),"NEW POINTS -->"
Draw String im,(c(2).x-80,c(2).y),"FILL -->"
Draw String im,(5,5), "SCREEN RESOLOTIONS = " &xres-1 &"," &yres-1
Draw String im,(.9*xres-50,35),"SCREEN TOGGLE"
Draw String im,(.7*xres-70,35),"SEE THROUGH TOGGLE"
if bitmapflag=1 then
Draw String im,(.1*xres-70,40),"BITMAP TOGGLE"
end if

'================  IMAGE NOW DRAWN =========================

Noconsole        'hide the dos box
'===============================================
'some variables
Dim As Integer mx,my,mb,flag1,flag2,flag3,flag4,flag5,flag6,flag7,toggle=1,counter,paintflag,contrast=1
dim as integer flag8,bitmaptoggle=1
Dim As Integer dx,dy
Dim As String key
Dim As String fill=Str(Rgb(255,255,255))
dim as string delta,first
d="""C"+border+"B" +d

Dim As String f=d
Dim As Integer count,cm,z
Dim As Integer rd,gr,bl,lower=1
Dim As Ulong boxcol=valulng(fill),circ1col,circ2col
dim as integer bitmapx=0,bitmapy=50,bflagx,bflagy
counter=0
'========================  SHOW THE SCREEN =================
#macro showscreen()
Screenlock
Cls
Put(0,0),im,alpha
if bitmaptoggle=1 then
if bitmapflag then put(bitmapx,bitmapy),bitmapim,pset
end if
'highlight the newpoints box
line(c(1).x+c(1).r-1,c(1).y+c(1).r-1)-(c(1).x-c(1).r+1,c(1).y-c(1).r+1),circ1col,bf

'draw the colour slider circles
For z As Integer=1 To 3
    Circle(slide(z).x,slide(z).y),slide(z).r,slide(z).col,,,,f
Next z
'highlight the fill circle
Circle(c(2).x,c(2).y),c(2).r-1,circ2col,,,,f
circle(c(3).x,c(3).y),c(3).r-1,circ2col
'the coloured square
Line(.8*xres,.9*yres)-(.85*xres,.95*yres),boxcol,bf
'top and base of drawing area
Line (0,.9*yres)-(xres,.9*yres),valuint(border)
line (0,50)-(xres,50),valuint(border)
Draw String(xres/3,60),"mouse " & mx &"   " & my 
Draw String(xres/2,60),"Previous mouse " &s(Ubound(s)).x & "  " &s(Ubound(s)).y
'the rbg values of the fill colour shown
Draw String(.8*xres,.975*yres),"RGB(" &RED(boxcol) &"," &GREEN(boxcol) &"," & BLUE(boxcol) &")",Rgb(255,255,255)

Draw d  'MAIN STRING

traceover(s(),boxcol,lower)
'small spot at mouse
pset (s(Ubound(s)).x,s(Ubound(s)).y)
 if contrast=1 then line(0,50)-(xres,.9*yres),rgba(0,0,0,150),bf

Screenunlock
Sleep 1,1
#endmacro
'=============================================================

Do
   
    getmoose(mx,my,mb)
    key=Inkey
    cm=0
    'Set the slider bobs to match the fill colour (boxcol)
    slide(1).x=map(0,255,RED(boxcol),(.6*xres),(.75*xres))
    slide(2).x=map(0,255,GREEN(boxcol),(.6*xres),(.75*xres))
    slide(3).x=map(0,255,BLUE(boxcol),(.6*xres),(.75*xres))
    
    'colours highlight at mouse inside(Two boxes at the top, not the toggle)
    circ1col=Rgb(100,100,255)
    circ2col=Rgb(100,100,255)
    'arrow keys to shift the screen
    if bflagx=0 and bflagy=0 then
    If key=Chr(255)+"K" Then sx-=5:bflagx=1
    If key=Chr(255)+"M" Then sx+=5:bflagx=1
    If key=Chr(255)+"P" Then sy+=5:bflagy=1
    If key=Chr(255)+"H" Then sy-=5:bflagy=1
    end if
    if len(key)=0 then bflagx=0:bflagy=0
    if bitmapflag=0 then
    screencontrol 100,sx,sy
    'bflag=0
    else 
   if bflagx then bitmapx+=sgn(sx-50)*5:sx=50
   if bflagy then bitmapy+=sgn(sy-50)*5:sy=50
    end if
    'CHECK THE MOUSE IN:
    If mb=1 And flag6=0 Then   'the colours in the boxes at the bottom
        flag6=1
        For z =1 To Ubound(Ccolours)
            If inpoint(Ccolours(z),mx,my+5)=0 Then boxcol=Ccolours(z).col':border=str(boxcol)
        Next z
    End If
    flag6=mb
    
    For cm=Lbound(c) To Ubound(c) 'Check for mouse in a box (upper screen)
        If inpoint(c(cm),mx,my) Then Exit For
        If my>.9*yres Then cm=-1: Exit For
    Next cm
    
    If cm=5 and bitmapflag=1 Then 'BITMAP TOGGLE 
        If mb=1 And flag8=0 Then 
            flag8=1
            bitmaptoggle=-bitmaptoggle
        End If
    End If
    flag8=mb
    
    
    If cm=4 Then 'CONTRAST TOGGLE 
        If mb=1 And flag7=0 Then 
            flag7=1
            contrast=-contrast
        End If
    End If
    flag7=mb
    
    If cm=3 Then 'SCREEN TOGGLE 
        If mb=1 And flag5=0 Then 
            flag5=1
            toggle=-toggle
            If toggle=-1 Then blendwindow(100) Else blendwindow(255)
        End If
    End If
    flag5=mb
    
    If cm=2 And Ubound(s)>=3 Then 'FILLER 
        If PaintFlag Then circ2col=boxcol
        If mb=1 And flag4=0 Then
            flag4=1
            fill= Str(boxcol)
           'var t=ltrim(starter ,"""C")
           If PaintFlag  Then d+="P"+fill+","+border't'str(boxcol)'border
        End If
    End If
    flag4=mb
    
    If cm=1 Then         'NEW START 
        circ1col=Rgb(0,200,0)
        If mb=1 And flag3=0  Then
            flag3=1
             lower=ubound(s)+1
            d+=""""+"_"+Chr(10)+"&"+""""
            d+="B"
        End If
    End If
    flag3=mb
    If my<50 And cm=Ubound(c)+1 then moveall:cm=0 'if mouse in top frame
    'CREATE THE STRING FOR DRAW.
    'AND CREATE AN ARRAY IN PARALLEL
    If mb=1 And flag1=0 And cm=Ubound(c)+1 Then
        flag1=1:counter+=1
        Redim Preserve s(1 To Ubound(s)+1)
        s(Ubound(s))=Type<Point>(mx,my,0,counter)
        Dim As Integer dx,dy
        If counter=1 Then dx=mx:dy=my Else  dx=mx-s(Ubound(s)-1).x:dy=my-s(Ubound(s)-1).y
        If counter=1 Then d+="M"+Str(dx)+","+Str(dy) Else d+="M+"+Str(dx)+","+Str(dy)
        count+=1
        If count>5 Then d+=""""+"_"+Chr(10)+"&"+"""":count=0
    End If
    flag1=mb
    
    'go back on right mouse click(delete mistakes)
    If mb=2 And flag2=0 Then
        flag2=1
        If counter>1 Then Redim Preserve s(1 To Ubound(s)-1):counter-=1
        If counter=1 Then Redim s(0):counter=0
        delta=Mid(d,instrrev(d,"M"))
        d=Rtrim(d,delta)
    End If
    flag2=mb
    
    showscreen()
    
    'the colour sliders
    For z As Integer=1 To 3 'in the colour sliders
        If inpoint(slide(z),mx,my) Then
            While mb = 1 
                Getmouse mx,my,,mb
                showscreen()
                If mx<>slide(z).x Or my<>slide(z).y  Then
                    rd=RED(boxcol):gr=GREEN(boxcol):bl=BLUE(boxcol)
                    slide(z).x=mx
                    If slide(z).x<.6*xres Then slide(z).x=.6*xres
                    If slide(z).x>.75*xres Then slide(z).x=.75*xres
                    Select Case As Const z
                    Case 1: rd=map((.6*xres),(.75*xres),slide(1).x,0,255)
                    Case 2: gr=map((.6*xres),(.75*xres),slide(2).x,0,255)
                    Case 3: bl=map((.6*xres),(.75*xres),slide(3).x,0,255)
                    End Select
                    If rd<0 Then rd=0:If rd>255 Then rd=255
                    If gr<0 Then gr=0:If gr>255 Then gr=255
                    If bl<0 Then bl=0:If bl>255 Then bl=255
                    boxcol=Rgb(rd,gr,bl)
                End If
            Wend
        End If
    Next z
  If Len(d)-Instrrev(d,"B")<18 Then PaintFlag=1 Else PaintFlag=0 
Loop Until key =Chr(27)
d+=""""
screeninfo xres,yres
dim as any ptr lastscreen=imagecreate(xres,yres,0)
get(0,0)-(xres-1,yres-1),lastscreen
dim as string q
screenres xres,yres,32
put(0,0),lastscreen,pset
draw string(100,100),"Do you wish to save -- y/n",rgb(255,255,255)
var ff=freefile
do
 q=input(1)
loop until lcase(q)="n" or lcase(q)="y"
if lcase(q)="n" then goto fin

locate 6,6
if Open ("DRAWINGpoints.bas" For Output As #ff)=0 then print "saved":beep else print "Fail"
Print #ff,"Dim as string zz = _"
Print #ff,d

Print #ff,"'Number off points ";Ubound(s)

Print #ff,"Screenres ";xres;",";yres;",";32
Print #ff, "Draw zz"
Print #ff,"Sleep"
Close #ff

shell "notepad DRAWINGpoints.bas"
Sleep
fin:
imagedestroy im
imagedestroy lastscreen
if bitmapim<>0 then imagedestroy bitmapim
 
  
Last edited by dodicat on Jan 19, 2024 13:21, edited 1 time in total.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by lizard »

dodicat wrote:lizard
Here is my own little editor
Thanks a lot. I see it is for windows, i will have to use my dual-boot and fire up win10 for this. Will continue here to not disturb the clock thread:

viewtopic.php?f=7&t=26285&p=243878#p243878
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by UEZ »

@dodicat: thanks for your contribution - always something to learn. :-)

Regarding vector graphics: what you can do is to convert the image to SVG format and parse it within your code. A good challenge would be to code a converter from an image to e.g. SVG format.

Here an online converter: http://www.vectorization.org/?userfile_ ... Format=svg

This is the output (SVG file). Save it as e.g. FBLogo.svg

Code: Select all

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
 "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
 width="243.803778pt" height="184.052586pt" viewBox="0 0 243.803778 184.052586"
 preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.12, written by Peter Selinger 2001-2015
</metadata>
<g transform="translate(-37.053152,214.390314) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M1037 2118 c-51 -26 -57 -33 -57 -61 -1 -18 -9 -70 -19 -117 -13 -62
-15 -91 -8 -108 12 -26 45 -37 82 -28 20 5 25 13 25 40 0 26 8 39 39 64 43 34
45 33 75 -26 22 -43 15 -73 -36 -157 -40 -68 -44 -93 -23 -147 4 -11 2 -19 -6
-22 -8 -2 -48 -14 -89 -27 -88 -26 -88 -26 -100 -68 -8 -29 -6 -36 25 -68 18
-20 44 -55 57 -79 14 -27 34 -48 52 -56 17 -7 45 -26 64 -42 33 -29 35 -29 48
-11 15 20 10 55 -10 67 -6 4 -21 8 -34 8 -12 0 -25 6 -28 14 -3 8 -18 19 -34
25 -16 5 -41 28 -56 51 -26 39 -27 44 -13 68 14 26 18 27 134 32 72 3 129 11
143 18 13 8 26 12 28 9 5 -5 -30 -98 -56 -148 -10 -20 -26 -67 -34 -105 -25
-108 -43 -141 -94 -169 -41 -23 -54 -25 -178 -25 -112 0 -134 -2 -134 -15 0
-13 96 -15 800 -15 704 0 800 2 800 15 0 13 -51 15 -395 15 -413 0 -435 2
-367 41 16 9 43 41 60 72 17 31 59 85 92 120 34 37 60 74 60 86 0 12 6 21 15
21 18 0 48 -56 38 -73 -27 -44 -132 -163 -156 -176 -49 -27 -79 -53 -70 -61 4
-5 26 -10 48 -12 35 -3 40 0 43 20 2 15 15 28 34 37 17 7 38 26 47 43 9 17 47
62 84 101 75 79 75 76 16 152 -16 20 -29 43 -29 50 0 8 32 43 71 79 67 61 72
68 76 115 4 37 -2 68 -21 120 -14 38 -24 71 -22 72 8 9 88 4 114 -6 35 -15 50
-43 58 -115 6 -49 3 -62 -37 -147 -55 -119 -64 -202 -29 -274 12 -25 25 -45
29 -45 4 0 5 30 3 68 -4 66 -3 68 45 142 27 41 71 115 97 164 l48 90 -13 94
c-8 58 -20 103 -30 117 -10 12 -43 30 -75 40 l-56 18 -57 -40 c-82 -58 -118
-68 -182 -49 -70 21 -104 20 -175 -4 -69 -24 -158 -35 -205 -26 -40 8 -91 46
-71 53 16 6 -78 115 -132 155 -47 34 -87 45 -186 50 -68 4 -81 2 -133 -24z
m646 -645 c9 -9 17 -20 17 -25 0 -5 14 -27 31 -48 26 -32 30 -43 24 -72 -11
-48 -109 -173 -161 -203 -24 -14 -51 -37 -60 -50 -16 -25 -17 -25 -182 -25
-156 0 -164 1 -150 18 9 9 18 38 20 63 3 25 19 74 37 108 17 34 31 67 31 75 0
7 25 45 56 84 l55 72 72 1 c40 0 88 7 107 14 39 16 77 11 103 -12z"/>
<path d="M393 853 c-4 -10 -11 -22 -17 -26 -8 -6 -7 -10 2 -14 7 -3 12 -24 12
-54 0 -27 5 -49 10 -49 6 0 10 23 10 50 0 38 4 50 15 50 8 0 15 5 15 10 0 6
-7 10 -15 10 -20 0 -19 10 3 26 16 12 15 13 -6 14 -13 0 -25 -8 -29 -17z"/>
<path d="M490 770 c0 -47 3 -60 15 -60 11 0 15 11 15 40 0 27 5 43 15 46 8 4
15 12 15 20 0 17 -12 18 -28 2 -9 -9 -12 -9 -12 0 0 7 -4 12 -10 12 -6 0 -10
-27 -10 -60z"/>
<path d="M610 814 c-17 -20 -17 -68 0 -88 16 -20 64 -21 80 -1 17 21 7 29 -18
14 -23 -14 -52 -6 -52 16 0 11 11 15 40 15 41 0 47 8 30 41 -13 23 -62 26 -80
3z m60 -19 c0 -9 -9 -15 -25 -15 -24 0 -32 10 -18 23 12 13 43 7 43 -8z"/>
<path d="M766 808 c-9 -12 -16 -29 -16 -38 0 -25 30 -60 51 -60 28 0 61 19 54
30 -4 6 -13 5 -24 -2 -22 -14 -51 -4 -51 17 0 11 11 15 40 15 41 0 47 8 30 41
-15 27 -64 25 -84 -3z m64 -13 c0 -9 -9 -15 -25 -15 -24 0 -32 10 -18 23 12
13 43 7 43 -8z"/>
<path d="M1680 622 c-39 -19 -80 -74 -80 -106 0 -34 28 -64 70 -77 50 -15 56
-44 8 -36 -18 3 -42 8 -53 12 -17 5 -25 -2 -43 -33 -12 -22 -22 -42 -22 -46 0
-3 25 -13 56 -22 116 -34 224 26 224 124 0 38 -24 62 -76 77 -19 5 -35 15 -35
20 1 14 46 18 69 6 16 -8 22 -4 40 28 12 21 22 41 22 44 0 10 -64 27 -104 27
-23 0 -57 -8 -76 -18z"/>
<path d="M2660 624 c-151 -65 -162 -276 -17 -315 22 -6 57 -7 79 -4 43 8 50
19 62 93 l6 43 -22 -15 c-27 -19 -79 -21 -96 -4 -16 16 -15 59 3 85 20 29 60
37 95 19 l29 -14 7 55 c5 42 3 57 -7 64 -22 14 -100 10 -139 -7z"/>
<path d="M490 623 c0 -5 -9 -66 -20 -138 -30 -197 -40 -177 89 -173 124 3 158
19 175 77 11 38 -5 81 -31 81 -14 0 -13 5 10 25 20 20 27 35 27 65 0 59 -23
70 -147 70 -57 0 -103 -3 -103 -7z m135 -88 c0 -11 -8 -21 -17 -23 -14 -3 -18
3 -18 23 0 20 4 26 18 23 9 -2 17 -12 17 -23z m0 -105 c9 -15 -14 -40 -36 -40
-14 0 -19 7 -19 25 0 20 5 25 24 25 14 0 28 -5 31 -10z"/>
<path d="M1047 475 c-42 -85 -77 -157 -77 -160 0 -3 26 -5 58 -5 l57 1 -40 34
-40 35 148 0 c81 0 147 -2 147 -5 0 -2 -20 -16 -45 -31 -25 -14 -45 -28 -45
-30 0 -2 27 -4 59 -4 l59 0 -18 83 c-10 45 -26 117 -35 160 l-17 77 -67 0 -66
0 -78 -155z m120 -43 c-28 -5 -29 0 -10 53 l18 48 5 -49 c4 -42 2 -49 -13 -52z"/>
<path d="M2150 623 c0 -5 -9 -66 -20 -138 -28 -188 -31 -175 38 -175 l58 0 18
133 c10 72 20 144 23 160 l6 27 -62 0 c-33 0 -61 -3 -61 -7z"/>
</g>
</svg>
Online documentation: http://svgpocketguide.com/book/#section-2

Does a SVG parser for FB already exists?
BasicCoder2
Posts: 3909
Joined: Jan 01, 2009 7:03
Location: Australia

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by BasicCoder2 »

UEZ wrote:Does a SVG parser for FB already exists?
A challenge for someone? Maybe something that makes use of bezier curves to reduce the numbers required for curved shapes. I played around with scalable rotatable vector graphics paint programs it isn't that hard.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-21 [Windows and 32-bit only!]

Post by jj2007 »

dodicat wrote:jj2007
I can draw the actual clock dial to an image.
And only draw the moving hands in the loop.
CPU is calm now, 0% usage - excellent!
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-25 [Windows and 32-bit only!]

Post by srvaldez »

hello UEZ
with the following changes it compiles with both 32 and 64-bit

comment out fMin in line 85
Dim Shared As Single fSec, /'fMin,'/ fHr, fAmplitude = 3
add fMin_ in line 129
m1 = fDiameter * 0.015, fMin_
replace fMin with fMin_ in lines 148, 150, 152, 162, 165, 172, 173
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: GDI+ Swiss Railway Clock v1.0 build 2018-02-25 [Windows and 32-bit only!]

Post by UEZ »

srvaldez wrote:hello UEZ
with the following changes it compiles with both 32 and 64-bit

comment out fMin in line 85
Dim Shared As Single fSec, /'fMin,'/ fHr, fAmplitude = 3
add fMin_ in line 129
m1 = fDiameter * 0.015, fMin_
replace fMin with fMin_ in lines 148, 150, 152, 162, 165, 172, 173
Thanks srvaldez!

To be honest I was to lazy to do these small modifications because x64 mode with all these API calls makes no real differences in speed.

Anyhow, source code updated -> see post #1.

@dodicat:
I added one line to make the center of your clock more "beautiful".
...
Do
Var clockstring= GetClock
Screenlock
Cls
put(0,0),image,pset
Draw Clockstring
Circle (400, 300), 12, &h101010, , , , F
Screenunlock
Sleep 10,1
Loop Until Inkey=Chr(27)
...
Post Reply