Dial/Gauge/Clock

Share your advanced PureBasic knowledge/code with the community.
jasper
New User
New User
Posts: 7
Joined: Sat Jan 07, 2012 1:41 am

Dial/Gauge/Clock

Post by jasper »

I thought this was useful, there are a few imperfections and I have only been using PB for just over a week so constructive criticism is welcome.

I hope the images are accessible I have never used web storage before, note Screen3DRequester.pb is required.

http://www.4shared.com/photo/hyt7-W1_/Dial_SS.htm

Code: Select all

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY


If InitEngine3D()

Add3DArchive("Data", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  

  If OpenWindow(0, 0, 0, 325, 380, "A Simple Gauge", #PB_Window_Normal| #PB_Window_ScreenCentered)

    If OpenWindowedScreen(WindowID(0), 50, 50, 221, 221, 0, 0, 0)
      
    ImageGadget(2,  46, 46, 229, 229, 0, #PB_Image_Border)                      
 
    TrackBarGadget(3, 35, 300, 250, 30, 0, 255,#PB_TrackBar_Ticks )   
      
    ButtonGadget(4, 120, 350, 80, 20, "Close")  
     
    TextGadget(10,0,0,50,24,"")
    
    CreateMaterial(0, LoadTexture(0,"Dial.gif"))    ;The material for the billboard with the dial as the texture
    
    LoadTexture(1, "BlackNeedle.gif")               ;Create a texture from the needle
    
    DisableMaterialLighting(0, 1)
    
    AddMaterialLayer(0, TextureID(1),2)             ;Combine the textures as two layers on material #0
   
    CreateBillboardGroup(0, MaterialID(0), 34, 34)  ;Place the material on a billboard in the windowed screen
    
    AddBillboard(0, 0, 0, 0, -40)
    
    CreateCamera(0, 0, 0, 100,100)
   
   Repeat
    
  result=GetGadgetState(3)
  RotateMaterial(0,-result/57.5,2,1)                ;Rotate layer #1 of the material
  
  SetGadgetText(10,Str(result/2.55))                ;The dial is 255 degress scaled 0 to 100
  
  EventID = WaitWindowEvent()
  
  If EventID = #PB_Event_Gadget
    
     Select EventGadget()
       Case 4
         
         EventID = #PB_Event_CloseWindow
         
     EndSelect
   EndIf
   
      Screen3DEvents()  
      RenderWorld()
      Screen3DStats()
      FlipBuffers()
      
    Until EventID = #PB_Event_CloseWindow

    
  EndIf
    
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
EndIf  
End
EDIT: Well no inline images , I need to work on that. The graphics I used for the gauge and needle were 221 x 221 pixels

EDIT: The following posts with the help of Bisonte have fine tuned this and made some major improvements. Improvement 1./ was the use of png images and 2./ the following modification to code

Code: Select all

 AddMaterialLayer(0, TextureID(1),2)
Last edited by jasper on Sun Jan 08, 2012 11:21 pm, edited 1 time in total.
jasper
New User
New User
Posts: 7
Joined: Sat Jan 07, 2012 1:41 am

Re: Dial/Gauge/Clock

Post by jasper »

Hello again, I apologize for a certain lack of information in the previous post, I got so tangled up with trying to present images I ran out of time.

I am hoping for a little feedback here. My idea was to use existing procedures to rotate one image on top of another to create a dial or gauge where the programmer could use their own graphics images. I achieved this using textures on a billboard with about eight lines. When I get the chance I want to extend this to an instrument cluster containing several dials.

So far I am pleased with the results but have a few questions that might help me improve. I placed this in Tips and Tricks because I think it is useable as it stands, that is my first question am I correct in that assumption or am I doing something totally wrong.

The rest are just questions on the cosmetics of the thing.Colors have an impact on the final look, I guess it's how the layers are blended, this is a topic I don't fully understand. A white dial face with a black needle works well. Also it appears like the needle is the bottom layer when it passes through the dials text, at the moment I am countering that by using black text and a black needle. If there is nothing that can be done with the colors or layers it would still be acceptable for me with a little thought about design.

Lastly I didn't understand why I had to do math on the result from the trackbar, I thought it would return a one to one relationship, one tick = one degree.

Oh, a pointer on attaching images to a post would be appreciated. They are still available at the link in the first post
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: Dial/Gauge/Clock

Post by Bisonte »

There is no BlackNeddle.gif... only Needle.jpg... and gifs... are not supported by PB
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
jasper
New User
New User
Posts: 7
Joined: Sat Jan 07, 2012 1:41 am

Re: Dial/Gauge/Clock

Post by jasper »

Thank you Bisonte, I admit the gifs were a mistake, just like my wrangle with uploading images onto a server, the originals were jpgs, bmps pngs. I was scrolling through different formats to see what effect it had on the final image. The idea is to use any accepted format and create your own graphics, the screen shot was an example of what it could look like.

What I will do later is upload the graphics again in a different format, would you suggest bmp?
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: Dial/Gauge/Clock

Post by Bisonte »

PNG... Native Support by PB and Alpha Channels (also good packalgos)

but, we can't test your source, cause we need the correct gfx...

no running example ... no feedback ;)
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
jasper
New User
New User
Posts: 7
Joined: Sat Jan 07, 2012 1:41 am

Re: Dial/Gauge/Clock

Post by jasper »

Thank you again Bisonte, I actually had things working with the gifs but that does not mean it is right I know. :)

All will be uploaded and corrected a little later, I have to take my spouse to dinner first.

EDIT:Ok, she said she would wait until I had done before going to lunch. :lol: The png's are uploaded
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: Dial/Gauge/Clock

Post by Bisonte »

Ok ... i was curious, what this little code will do, and you not post a working example...
so I do it.
The SBI procedure only writes the included png data to the window temp dir, because I don't
know how to "catch" the images to make a texture... so LoadTexture have something to load ;)

If you exit the program on normal way, the graphics are deleteted from the tempdir...

Code: Select all

UsePNGImageDecoder()

Procedure SBI(FileName.s, Adress, Length) ; Save Binary Include
  
  Protected Result = #False, File
  
  If Adress And Length
    
    File = CreateFile(#PB_Any, FileName)
  
    If File
      WriteData(File, Adress, Length)
      CloseFile(File)
      Result = #True  
    EndIf
    
  EndIf
  
  ProcedureReturn Result
  
EndProcedure

XIncludeFile #PB_Compiler_Home + "\Examples\3D\Screen3DRequester.pb" ; Or change Path to your PB-Examples Directory

Define.f KeyX, KeyY, MouseX, MouseY
Define.s TempDir

TempDir = GetTemporaryDirectory()

If InitEngine3D()
  
  If FileSize(TempDir+"Dial.png")<=1 
    SBI(TempDir+"Dial.png", ?Dial, ?Dial_eof-?Dial)
  EndIf
  If FileSize(TempDir+"Needle.png")<=1 
    SBI(TempDir+"Needle.png", ?Needle, ?Needle_eof-?Needle)
  EndIf  
    
  Add3DArchive(TempDir, #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If OpenWindow(0, 0, 0, 325, 380, "A Simple Gauge", #PB_Window_Normal| #PB_Window_ScreenCentered)
    
    If OpenWindowedScreen(WindowID(0), 50, 50, 221, 221, 0, 0, 0)
      
      ImageGadget(2,  46, 46, 229, 229, 0, #PB_Image_Border)                     
      
      TrackBarGadget(3, 35, 300, 250, 30, 0, 255,#PB_TrackBar_Ticks )   
      
      ButtonGadget(4, 120, 350, 80, 20, "Close") 
      
      TextGadget(10,0,0,50,24,"")
      
      CreateMaterial(0, LoadTexture(0,"Dial.png"))    ;The material for the billboard with the dial as the texture
      
      LoadTexture(1, "Needle.png")               ;Create a texture from the needle
      
      DisableMaterialLighting(0, 1)
      
      AddMaterialLayer(0, TextureID(1),1)             ;Combine the textures as two layers on material #0
      
      CreateBillboardGroup(0, MaterialID(0), 34, 34)  ;Place the material on a billboard in the windowed screen
      
      AddBillboard(0, 0, 0, 0, -40)
      
      CreateCamera(0, 0, 0, 100,100)
      
      Repeat
        
        result=GetGadgetState(3)
        RotateMaterial(0,-result/57.5,2,1)                ;Rotate layer #1 of the material
        
        SetGadgetText(10,Str(result/2.55))                ;The dial is 255 degress scaled 0 to 100
        
        EventID = WaitWindowEvent()
        
        If EventID = #PB_Event_Gadget
          
          Select EventGadget()
            Case 4
              
              EventID = #PB_Event_CloseWindow
              
          EndSelect
        EndIf
        
        Screen3DEvents() 
        RenderWorld()
        Screen3DStats()
        FlipBuffers()
        
      Until EventID = #PB_Event_CloseWindow
      
      
    EndIf
    
  Else
    MessageRequester("Error", "The 3D Engine can't be initialized",0)
  EndIf
EndIf 

DeleteFile(TempDir+"Dial.png")
DeleteFile(TempDir+"Needle.png")

End 

DataSection
  Needle:
  Data.q $0A1A0A0D474E5089,$524448490D000000,$DD000000DD000000,$BFCD950000000408,$4D41670400000091
  Data.q $51FB7C8EB1000041,$5248632000000093,$800000257A00004D,$800000FFF9000083,$EA000030750000E8
  Data.q $170000973A000060,$000000D499A9976F,$AA000044474B6202,$700900000032238D,$0048000000735948
  Data.q $3E6BC94600480000,$5441444907060000,$65D5685FDCEDDA78,$45B99BA3F7F1C71C,$C8A8BD42DA983533
  Data.q $08B4242908A9A84A,$30BB1233316486CD,$26F1BB088488A842,$D2B0242422C22AF0,$22230FF8644A13FC
  Data.q $9B4C2EA350D21422,$6DD3991D9DC7F7FF,$3B39534D250A174F,$BBFB75E7DBF3EFCF,$E79DF9E79BCEFEF9
  Data.q $7A921A6988859D9C,$64E9CB274E55BB00,$B274E593A72C9D39,$593A72C9D3964E9C,$2C9D3964E9CB274E
  Data.q $964E9CB274E593A7,$CB274E593A72C9D3,$E593A72C9D3964E9,$72C9D3964E9CB274,$3964E9CB274E593A
  Data.q $9CB274E593A72C9D,$4E593A72C9D3964E,$A72C9D3964E9CB27,$D3964E9CB274E593,$E9CB274E593A72C9
  Data.q $74E593A72C9D3964,$3A72C9D3964E9CB2,$9D3964E9CB274E59,$4E9CB274E593A72C,$274E593A72C9D396
  Data.q $93A72C9D3964E9CB,$C9D3964E9CB274E5,$64E9CB274E593A72,$B274E593A72C9D39,$593A72C9D3964E9C
  Data.q $2C9D3964E9CB274E,$964E9CB274E593A7,$CB274E593A72C9D3,$E593A72C9D3964E9,$72C9D3964E9CB274
  Data.q $3964E9CB274E593A,$9CB274E593A72C9D,$4E593A72C9D3964E,$A72C9D3964E9CB27,$AEB081807A915593
  Data.q $41DC9F9D6717F98A,$EEBE9B2D3D9681DB,$04F5310840D13D4A,$5D4F7EF0D9E1B725,$9A672CE569DA4517
  Data.q $A554F539BFD8DE5B,$4DDE8AED730DBB97,$8A0E9DA4E8BAEA97,$457DBA6FB5D42914,$C3EEAB672F4AB9EA
  Data.q $95A0E91702EBE1A6,$524E69C739148A76,$2B4AE9EA7D710584,$5A1C1F54D456E957,$173B4938A7074BD7
  Data.q $799A00DA568BA1E8,$7AB94A584F521630,$9C5D0750BC68529B,$97A043D2282728E2,$EA6D6468EB17CBCE
  Data.q $861ADAE957294B09,$6E8DA31C938143D2,$5D38372E7FBE8122,$0B48A1E8189A9D66,$4C1C7AAE03E9BA05
  Data.q $49DD2AE5695F3D4C,$F2E12B8E9BA3E8FA,$1199E91F8EE9572D,$9CDCBBFB1722E5E9,$ECEEB9D5CAD2BE7A
  Data.q $97FF7749D1CE76CE,$387572B4AF9EA5B7,$E62E35DC661C3508,$B3461755A39070EE,$E15F2CBCBCD72391
  Data.q $4C9197B3D42E9472,$F6F2F78FFEFE7CBB,$A0ECC585D26E4A59,$5EB465814038478F,$13D49DF10595B175
  Data.q $2542EB3FEB3DC00E,$67E1682A08CD98AB,$4C0D234350858E5E,$6DBC9EC7D8FB34E2,$65A85D3D5BEE5795
  Data.q $3B78AA59C898A30B,$EB9F88F94F3D4EAE,$A2FE38C5D3360CC2,$24E53CF52878869B,$C66A95B3AF0BACFD
  Data.q $E1385707EA2EC6D2,$A0EE0CC358AA1755,$FC16FC398D2C4B83,$3B96F8130BA688FF,$A67F8A68C70B4D19
  Data.q $E6CC330DC905279E,$CCCA7C9D1461EE17,$9778661DF24E19C1,$9FC7E6053746DC65,$6A1986D88E934F52
  Data.q $2CF7C9D38634C8D8,$A50B5F86ED79E7CA,$D2549183B1261755,$ABC6BB8274C1B2C5,$E8C309F1342E93A1
  Data.q $7F4083B60CCF04E1,$358AB0CA84A6DE44,$40E1D8792F9BA30C,$2A24C6D96A1759E4,$4FF5C13C60F162E8
  Data.q $7D354ED9D30CC360,$4FE8107AC1DCCEFC,$A6A8EF94B0CC37E6,$D32DFEE1D4788F87,$08669E73E2A8661B
  Data.q $D64D3D48EE2E79E7,$78CDD8130CC37864,$269EA74F1399FB22,$661CB98661BB327B,$27F5C38A7195913C
  Data.q $8A049BC958661BA3,$32AB259EA43F89CC,$47E07A8BB0D42E98,$732FAEBA8FEE0CE6,$2C89EA51CC98661B
  Data.q $EAB6327AEE1D338F,$3C783A10C07CABC2,$5D2865D64B3D481E,$C6345D80F33D64A8,$61B332B4BF70FE5C
  Data.q $F8B5E448D3B65A86,$C2EB9C8C88DDC3A4,$FC44F0CE2EE2BE74,$C2EAB1322A2CF52D,$C39D626F86337612
  Data.q $6AC950BACFE4B8DD,$167A975C6160A89A,$3F73B63A85D3892D,$D4297EA78F1A9867,$00F10E2CC330DD24
  Data.q $D30979BB8738E21B,$85F1858AA0ECE585,$A8661B44A6822FD4,$6F5E2986718F3B62,$CCD2F70BAAC92AB7
  Data.q $12EB770EB1C6360C,$628B04661C4D0BA4,$330DF656D79BEA53,$F6731A99A713417C,$68C2E9ACAFCA30AF
  Data.q $4A5E3E795B0C657E,$A78661B8CAFAE37D,$570E79C62F2D4538,$A15E63E1755B650A,$CB2952AEABFE2995
  Data.q $C9D84B0B61950BAA,$50BAAC329D2B8758,$EA59F8A5E6EE41C5,$586A174F0197CD9B,$6ADF523FC50F2543
  Data.q $97B1261986F00CDE,$AFE01BD2B873EE56,$81B84BFC145BC35A,$E265E6EDC96F9191,$E9CB274E15BB725B
  Data.q $74E593A72C9D3964,$3A72C9D3964E9CB2,$9D3964E9CB274E59,$4E9CB274E593A72C,$274E593A72C9D396
  Data.q $93A72C9D3964E9CB,$C9D3964E9CB274E5,$64E9CB274E593A72,$B274E593A72C9D39,$593A72C9D3964E9C
  Data.q $2C9D3964E9CB274E,$964E9CB274E593A7,$CB274E593A72C9D3,$E593A72C9D3964E9,$72C9D3964E9CB274
  Data.q $3964E9CB274E593A,$9CB274E593A72C9D,$4E593A72C9D3964E,$A72C9D3964E9CB27,$12A953854E37F593
  Data.q $7425000000B6C151,$3A65746164745845,$3200657461657263,$302D31302D323130,$3A36323A38315438
  Data.q $30303A30302B3130,$250000007179D1C4,$6574616474584574,$00796669646F6D3A,$2D31302D32313032
  Data.q $36323A3831543830,$303A30302B31303A,$000000CDC18CB530,$474E507458457432,$6863004D5248633A
  Data.q $20736177206B6E75,$732820646E756F66,$6D6F726843206565,$2C79746963697461,$072965766F626120
  Data.q $742C000000DA48D1,$673A474E50745845,$6D6D616700414D41,$353435342E303D61,$6553282031303034
  Data.q $2C616D6D61472065,$D22965766F626120,$7414000000B90AB3,$493A474E50745845,$5F7469622E524448
  Data.q $2938006874706564,$7415000000507E85,$493A474E50745845,$6F6C6F632E524448,$3600657079745F72
  Data.q $1B0000002BA74A06,$3A474E5074584574,$746E692E52444849,$6D5F6563616C7265,$FB3000646F687465
  Data.q $741E0000008C073B,$493A474E50745845,$746469772E524448,$7468676965682C68,$3232202C31323200
  Data.q $0000008BE26E4E31,$666F737458457446,$6D49006572617774,$636967614D656761,$2D392E362E36206B
  Data.q $302D313130322035,$3631512037302D34,$2F2F3A7074746820,$67616D692E777777,$2E6B636967616D65
  Data.q $008D365F2B67726F,$5474584574180000,$6F443A3A626D7568,$3A3A746E656D7563,$A731007365676150
  Data.q $74180000002FBBFF,$626D756854745845,$3A6567616D493A3A,$007468676965683A,$00AD44BB77313232
  Data.q $5474584574170000,$6D493A3A626D7568,$6469573A3A656761,$17AB313232006874,$4574190000002017
  Data.q $3A626D7568547458,$707974656D694D3A,$2F6567616D690065,$004E56B23F676E70,$5474584574170000
  Data.q $544D3A3A626D7568,$3632333100656D69,$A521313631373430,$457413000000356B,$3A626D7568547458
  Data.q $2E3300657A69533A,$DABCDE42424B3437,$58457440000000DF,$3A3A626D75685474,$656C696600495255
  Data.q $2F7273752F2F2F3A,$5F676E6974736F68,$6D2F3973656C6966,$656C69662F6E6961,$3031303737363031
  Data.q $305B7461642E3730,$000000F602601B5D,$6042AE444E454900,$0000000000000082
  Needle_eof:
EndDataSection
DataSection
  Dial:
  Data.q $0A1A0A0D474E5089,$524448490D000000,$DD000000DD000000,$871A080000000308,$4D41670400000028
  Data.q $51FB7C8EB1000041,$5248632000000093,$800000257A00004D,$800000FFF9000083,$EA000030750000E8
  Data.q $170000973A000060,$020000D499A9976F,$D8D8DB45544C50C4,$4046909095D5D5D9,$ADD4D4D7AFAFB340
  Data.q $D6D6D9B4B4B7A9A9,$464D8D8D91D1D1D4,$6ED7D7DAB5B5B946,$BBBBBF5E5E646868,$6C71CDCDD04F4F55
  Data.q $62838388CACACD6C,$64646AAEAEB25C5C,$474EA5A5A9CACACE,$C43030378D8D9247,$77777DCCCCCFC0C0
  Data.q $565CBABABE66666C,$6DB3B3B7A6A6AA56,$4141487373796767,$82874A4A50ACACB0,$606A6A6FD5D5D882
  Data.q $CBCBCFB2B2B65A5A,$B0B44B4B52848489,$CB7A7A7F4E4E54B0,$606066727278C8C8,$BDC148484EC1C1C5
  Data.q $A69E9EA276767BBD,$4C4C52B4B4B8A2A2,$6D736262687F7F84,$58B8B8BCC4C4C76D,$ADADB12C2C335252
  Data.q $A1A559595F616166,$AF8080853A3A41A1,$3C3C43A4A4A9ABAB,$8B90D3D3D697979B,$D445454BCECED18B
  Data.q $A7A7AB78787DD0D0,$7D8244444A98989D,$4789898ECFCFD27D,$727277C5C5C84040,$D0D3BABABD5F5F65
  Data.q $AE4D4D53717176D0,$98989C3D3D44AAAA,$81865B5B618F8F94,$7A70707558585E81,$A3A3A7C7C7CA7575
  Data.q $797E9A9A9F3F3F45,$67C6C6CA45454C79,$4B4B519393976161,$333A2222299D9DA1,$5A7C7C81BEBEC133
  Data.q $B6B6BAC2C2C55454,$888DA0A0A4949499,$BB2F2F365D5D6388,$BFBFC3323239B7B7,$494F95959A57575D
  Data.q $C09C9CA065656A49,$7B7B808E8E93BCBC,$878C38383F99999E,$5936363DC3C3C687,$D2D2D52E2E355353
  Data.q $C5C96C6C7277777C,$49747479919195C5,$87878BBDBDC04444,$6B705F5F6436363B,$069494986F6F746B
  Data.q $29292E0E0E130000,$353BA8A8AC1B1B21,$74B1B1B551515635,$86868B35353C6E6E,$BFC279797D3E3E44
  Data.q $322A2A317E7E83BF,$C9C9CC5050572B2B,$5157434349A3A3A8,$5685858A9F9FA451,$4242499B9B9F5050
  Data.q $272E69696F313138,$9892929655555B27,$6363698C8C919393,$888C96969AB9B9BC,$A4DFB2B28A8A8F88
  Data.q $FA261BDACBCDE2A5,$8B89FD190EFF0C00,$7BF34C45E49896E7,$F53F37EE6660E97E,$3229EB726E66666B
  Data.q $3FF05952DDBEC0F8,$9E9EA33B3B423939,$29302D2D3425252C,$401C1C231E1E2629,$1B1B2213131B3A3A
  Data.q $FFFF24242B101018,$0000002218A389FF,$DDBFEB44474B6201,$487009000000B826,$0000480000007359
  Data.q $003E6BC946004800,$7854414449630F00,$16D7135B899DEDDA,$8A8B6108900907C0,$58222EC2E02A08A1
  Data.q $A9114145540A88D4,$20AA0DC54151650B,$E2D6A5C505C37DD6,$D16B46A493282CD2,$B1F56AD3ED2D703E
  Data.q $696FAFB68820A224,$EB21892CEEF15FDF,$FBEFEEFDA4C9924C,$BB99CE773B9B9B94,$0810204106E7739F
  Data.q $8408102040810204,$B641B473B886DC1D,$225C5E9E1E147165,$7C8227C3EDEA1BC4,$0087B305B67F3F5F
  Data.q $3230C15F40A7524F,$2361BB522088F86E,$61083F833D490A47,$15250A8E78DA565B,$F0BB56AC663D1B09
  Data.q $1DA93C6E39143208,$D2D2DB2E44C2642F,$131CCA4D1515EF84,$5129309A284F171B,$28440929A4E4E7AB
  Data.q $954B4B6C87EA6539,$593A77CD303250D4,$18BB424F770CC838,$02B369D7ED4CFB91,$6464E939ECFC5089
  Data.q $F048B7E5B61CE646,$B27CDE71F5B57347,$2F5F930416B23C9C,$D16726340A26CB4C,$8F24B0144E225CE2
  Data.q $B6CF9C5D2F177108,$F10C98FB4FF09606,$B15F2DDA91960B45,$82BBB647195C8C9C,$2ECFC0C78873BC4F
  Data.q $F8AB25C54521D324,$C94A6BD589606B6C,$050C8EBB5B2DC446,$5CBEB78C4A224F87,$9B619EA48D86C9AB
  Data.q $E6F9705B90887D4A,$F54CCDD52ED7E42D,$F143253F2A2A86D7,$DD6E05920D7253A5,$34EFB57FA9786556
  Data.q $19078766BDB31422,$C5A4EB6CC9B3E33B,$613D87BA55A8C66D,$FB0C4A0BA4088F13,$1493865DCEE7AE42
  Data.q $0777D38D495B91CF,$B6C81F9CCC082F68,$86D5EC94F68A3A56,$03D33102222DACD7,$D8611E585C2619F6
  Data.q $3DC60510E617F6B0,$9519FC2F76429690,$0E87838F49D6D8EB,$B588A439C3A28368,$C189F19F36199787
  Data.q $C36A8E47151E3106,$B6CE60B955938EC7,$C2775383D255B602,$728C35AE8FF126A8,$EA37A8F455EBA93B
  Data.q $EC5906D29ED63327,$66CE67F9036B4E5E,$2A39D279FF9F4851,$B1459D6BA17DFAF9,$6D0CCBFA2E5259E7
  Data.q $5BE58730CAF79570,$6FB6F1916D3AE5F6,$A6335FE69E69668B,$2BB60D485C360C81,$9B4973DC5F563D2F
  Data.q $CE556CFE31BCE7AD,$BF5341836B2E8BCB,$90809621805498B2,$AFC94858946B2C54,$1B1CA7A70DAADC4D
  Data.q $F51595DE44B081E2,$9485AD656AE13064,$540A84411C86284D,$DACFE3D416E540A9,$DD6C075F31E4ADA9
  Data.q $13B262B5D546B08B,$D84F99E616D723E7,$AA19104527656288,$4612399FF6311042,$1F3C8FAFDFAED55D
  Data.q $E16F5058625FEDAF,$37F34E6E8AB57397,$52BFB08914A94E9F,$9F332A0122EB0514,$899BC1B4D337C6F4
  Data.q $D1CE47C470DA7937,$54EAF0BAE5B3E2A8,$7097B315FE6B305D,$3E0C4D4AC0297AF0,$7A0DDBEFB7682CAA
  Data.q $8919F846C1391FE3,$0CAB8FE03388E901,$CCE252F347DF85D2,$C88454518802225E,$E42C0A8951F066D1
  Data.q $1CA8B8EF6E22619F,$6EEAE2B7208728A7,$0AE996C02840BAD1,$5A1C925621A613A0,$EACEE7C575A183D7
  Data.q $17BAD3CF4BD7F93B,$FEC109B44A84CEDE,$4EDE77FB0E93D591,$B6EFF8BD40729276,$6050264B0A0F49D2
  Data.q $210AA193EB40093A,$9DCA6FA09891AB9D,$CAF32A37F59DDD6A,$9ADBC4A74681EAF7,$349394A6552A8940
  Data.q $47DA3C635F7864AB,$646E607DD25CB496,$B1996A5FB59F7F88,$22ACF9699359320E,$7DA39346B2A3EA04
  Data.q $771E0FBA33BAE8EB,$5D2F18E15CA4330E,$AF8351D458EB791F,$62367D616F78E49B,$5343C7C0AA053942
  Data.q $ABCB74A79DA4FDA3,$3393A51DEF7703FC,$239AD15D2527F265,$9BAFE0F87B8FBE11,$311B30A2D5362551
  Data.q $99A16682A52A8046,$9FBFC1F96E8AFED1,$83E059B3219231B4,$0AA854B6CECD177B,$313918C46CC28A17
  Data.q $1E1EB3ED1B58950D,$15ACD5609B319AFB,$25AA80905C995757,$E80C62366946A505,$68CACA8590425553
  Data.q $0DD299D72DB7FDFF,$04A9A98E6DA43050,$9A52946400408DA6,$D1E5B795D222188D,$23E95C8D266926BE
  Data.q $8812815E32601D3C,$A2B0ED70488D9A6D,$821CAA3247DA32B7,$D02A9226C68E9A84,$0551888D9B6C49EF
  Data.q $EF3DA3EA4295E418,$8C4A94A08A54C3A4,$51B088D9B6CAF182,$3F68ECDE41F1CA8E,$51D1F87FA75D9888
  Data.q $094A8E9509F67DDA,$6CB705D9F2CA163A,$E087CFECD353DDCE,$26971519ABBEB3E3,$B7E7C0E07C6D8F63
  Data.q $ABF28FF19702E1FD,$B0E4702C9EA5B60E,$8B9FD997DFC4FD77,$D1C7315C2FD6E023,$56D843C3B884A20E
  Data.q $6F5C547EA90DC30C,$6B9D509A6C863E7F,$C165A77052762E7F,$561F8F6326267483,$1B4FCC4EA73D3332
  Data.q $6185BE9F981C2A93,$73776AEC89CEDD5F,$3FE6E2055EA45C4F,$AB9EFA11A7BB2BB1,$82EF55D9439587BC
  Data.q $C7B59C178BC27F7E,$F59F86D8EDAA7443,$52E20DCABB2FB96B,$83738CF4D1A8BDC8,$B30D7896646E73E1
  Data.q $3DE2503988C60723,$C337BDF5DE9D80EF,$C549C506F17B77DD,$4282D74436937132,$A1ECC23CEE15668F
  Data.q $B2787776DE1AF706,$184E579F82CE36DD,$A782C005AC062833,$3B45884D0A0B36C9,$BD321D1FAF71372A
  Data.q $C9B07093DC196EE0,$0F4282C5B6F6BE32,$0E72A2341028DA29,$198249F4186AF783,$85059369A560C4AF
  Data.q $9CE50086AC2A8D1E,$94B605327E9D2F70,$4525501F4282C5B3,$E4C8E58B7CCBDC0C,$547D0A0B16CAB798
  Data.q $A74592BDD2D89AF8,$BDDB49A8FC7B67E9,$FD5B1376E37E7314,$CE4AD8E54268B439,$D21546FA4E8ABDFC
  Data.q $26FE53D891F676CE,$8D8FBB04B79BC3F4,$997144E5085A1CFE,$0E1FE7ABCCE857BB,$BCF1E8B652F699FF
  Data.q $09B3F546559CBF4C,$2C9B454C4A8D5545,$98083E09BD013428,$4B95A7B3FA6E57BC,$B186D58ECB6D7D67
  Data.q $7435AFADFACEFDCF,$9FD9614EC18134BA,$B8980882A8C438E3,$787F96A3DFBC5157,$F0969CB9C1402AD9
  Data.q $BE719CBC6C1A3BD9,$9EB58ECDD73E1C48,$5B623C8EE3EDAEC7,$2DEEEF67DCDC730B,$962040399D90766E
  Data.q $F70EC5BB4F5025E1,$D89D77CCC0077B74,$E9F6EDF1C69D1D77,$D7A9EA1AC9773556,$352EDDD6F36899DC
  Data.q $CBFC6A17DC5A6340,$CBD43B6A97F8C36E,$728A2D3E7C533C0B,$FB2E3C951F1BABFA,$97EAED146DA6C1B0
  Data.q $DDD52F24CFF02BC8,$765FAD235EEA3D1D,$B66537CB2CD6CB5A,$5405F65155D60B95,$27FAFEE51C5E7E4D
  Data.q $D46503EEADD6EE9B,$483DBD208FDFD3D5,$78E907BA8F6F6F5F,$FA4106BF48F106A9,$EE8B06B54BCDE040
  Data.q $8D101A40066B57EE,$D2C2296CBBA975F4,$CFF12EF455652594,$D47AED26CD22325E,$BB263F40CD1A3D03
  Data.q $E7A6BF7E201BD5FA,$E2748D4BBBBFBA85,$755FA8D4E90FB335,$76514068D47541AB,$33E81EA039A562F7
  Data.q $201BE909940A552E,$A2033BEDB6A1B8DC,$0803B39501BCF6F6,$3D56818902FE0EDC,$6E8E81EA1D56812F
  Data.q $2EEA37B62B13A68D,$81F7441DA066B12C,$E7652D95FACA0127,$A092B89498486DD4,$1DA0740D2D617605
  Data.q $8252AC76EEBEAEEA,$01F55C5E8EEAFD0F,$B8A0A2A805F3BDA4,$50BE74F2EAFAF03B,$AA6D02EC95C1BEF7
  Data.q $E80DE1F03DD40FBF,$DAEA83B5F5745F27,$02BCF7501E740BD7,$D5D1D179AD5BB435,$8EBB283777449E05
  Data.q $F9F582273BB53657,$4ED3D7AB803F8778,$8391F575D1A09EF4,$2FBEA80DE41BC0C5,$0EDBDD42903E9A34
  Data.q $FFDD469E140BADCA,$A85BD5975DF16D82,$6378058F15D972A4,$23394953149F8B39,$992AA42CE1E8E683
  Data.q $EA97D2EDF4844A58,$697963657E5A9D97,$B13A1C8E5A3C8522,$A875C9F8CBB66275,$B7BEE977C50CB950
  Data.q $282DDF88EFD6074B,$4589D0CA7C22B879,$CC7BBFBFA933D6AD,$CC0BAC6E57A9B7A3,$4F1303DE60DD9FD0
  Data.q $8A136D83307069CE,$F012DD792F81B20E,$205E612090E9DC76,$6D311619062F71B5,$7D3EBD1F352BB1E5
  Data.q $3D1855028882F75B,$F5375B88D76B6739,$F1548653BE71D2ED,$A45CFCE88DE80BD2,$642DA9BBEFB07D76
  Data.q $CC8A0DC03DE63344,$7BF95142A0CC0F7B,$CC9F52DE97611FC3,$A7B74BB092AE75B3,$273B4084A6D9864E
  Data.q $20DE60142307F45A,$3F8387381B099099,$53942607BC93B12F,$E06C8666C14C52A0,$8251C9E4662A0512
  Data.q $E06C467770322DA8,$81EF24E389B2B952,$AF318812AA284409,$402E588970360302,$409A151C9E867224
  Data.q $F5B031CBB0B4AD97,$FE813EC57DD5A45C,$8BA4A48A9B46B979,$3C0E7D01EF14E257,$61AADCBABE3D1F59
  Data.q $C5D643079198D1F9,$4EC18DDA955CAC1B,$BAC3E25EE7D01EF1,$7ACDD2D61B94EA92,$A67BEF4ABBE3717A
  Data.q $219142867F3893BE,$245F596F6BB3838B,$FFDDAFADCE843434,$F651869B086A3B27,$810218517B59F097
  Data.q $61A5D86106805C40,$09CB3CD6A2D6E4BC,$DF2F78D8B457B1F3,$4FC2E53DBE9CCE1E,$84E5B1FDBE8F37E3
  Data.q $DA0B3C4467A2BD43,$4EA665B678B4CBFF,$A7C3BCF77ED507DB,$87F4B09CB2480ECE,$9B8EF5DC176F43A4
  Data.q $D1D6E75332DB2BF0,$727737DADFAE7765,$9723333E84E5AD68,$C58A7FBAC8AFAFDF,$A2080EC5C2E831C3
  Data.q $EECE65FD13C15534,$3767D2E20C204084,$D29F07AE40ADCDDA,$52415B37CFE6242C,$86504BFFD83C77A2
  Data.q $590C762B935E74B5,$B755111974B4B6C9,$A2C92B6AFCF94467,$6B7D46A696A3BCE2,$3B260B098A91CD10
  Data.q $32A64CB3610C200E,$4FE3B2C8A0E4C423,$D0F6F5B54EDD5926,$123E760D33FB8890,$B67E08401CF63ED6
  Data.q $C10A4D8ADB86528E,$F9260D567902F2E5,$50A814240751A120,$31384401CD601625,$1085E3B1276C6690
  Data.q $B908401CD64CB6E0,$C321084CA2845F69,$F7703080396C239D,$93F81080C768188C,$995140218401CD63
  Data.q $E60E085E3AFEF312,$6548E100735846AF,$EC9F10B074A1A032,$3AEDA8E6B6797240,$1100735802F7899B
  Data.q $A0F8848318981448,$3674D9EDF3EC6CF0,$CAFA4D643424E30E,$72204467986A789D,$70CA3410E623EBCE
  Data.q $6F8C9F222160F2C7,$5672E6BB5C29AD4B,$90C322E442952B7D,$A7BAFF790F63F793,$C186CE21693E3B70
  Data.q $151550200E7B1E1A,$C58442C1D47DE22A,$B6D282F379767B9C,$D93446CF5BA67B6D,$37B77585B7DAC2F7
  Data.q $3DFE143E971072B5,$171FD0F17B243CFC,$8AE347CFF6994F59,$229B6C39D710827D,$B88B9ACDB80E54F9
  Data.q $2915C408102A61D4,$132134708ADFA970,$AE146D56F9EFF7E9,$E68ECA4F25F2A3C2,$7BB9AFB6718B30D3
  Data.q $D3E6F271A9B16D8D,$4C50F99FD313F0B4,$59D2E9627969F79F,$E4B0FC9543841F2C,$33239F29CA9B07EC
  Data.q $342DB3DF4989D16A,$F19B282A3297B81D,$F8D5DA7FB0A75DD6,$97CA5D7F216099D3,$5B60AB7192B9D8FB
  Data.q $B22C2C977A14F307,$8DFF0F1C831C4FDD,$E964BDBAD3CC1D6D,$F9899B6C1333E7BB,$E14EC3B96EF87A7C
  Data.q $236BC8D15AB70064,$905AB62AC1B75EB6,$8D602B6C9E0DAFF9,$F4158BB6E2412CDC,$E6CD5DFF1AAFE22E
  Data.q $A5F6A3491576733C,$86BDDA313739F620,$F6645F7DB5BF35E6,$4381F8E4CA8A294B,$F42C720BDD2841AE
  Data.q $6C790E2F84EC22B5,$85846C5E250E5FCD,$0A6BCEA17D8C1193,$BEC6769CC25F0D84,$0297FC6685362750
  Data.q $A17D8C0184E384A4,$5B5C984773C29BA6,$9D26418E104418EF,$FAA14D9350BE8625,$4F7FF2DB3CECF29B
  Data.q $4F3148C41B7FD4F0,$E9A85F032E7EA30C,$7D94D26571EE70A6,$55F75BFC6C27DD76,$13946E2A39427106
  Data.q $5CD42F81833396E7,$C76A1969AE2DA853,$527131FFEE21A7E9,$30AC0FC43113F62D,$A6985350742FA183
  Data.q $9EDF632787D60AF7,$78D9633B3536F9B0,$3214DFAA17D0DCF7,$E971EF8F57BC575F,$14A1D06919B7EDA0
  Data.q $F542FB19BA09D7FF,$FA21992DE796C29A,$DDEC3651B61D63BB,$F542F84C182C6761,$5594CAA1D041429A
  Data.q $9770F7F3C94F7F8E,$2CD5C06C6F69F978,$B663C7FD1EAA1F47,$B16F735E7F4922F5,$BFB31FF9AFCC7343
  Data.q $6EDB7E03E48742E7,$79FFCCFA6B6E3A86,$D25E76B73D0B92BB,$D11FF1EF528EC9F4,$B977B47A40642B6C
  Data.q $9EBBBFE51EF12663,$8C90E75E144AA201,$A752070FDE73BF0E,$040810203CFECCA1,$0204081020408102
  Data.q $8102040810204081,$4081020408102040,$2040810204081020,$ABDF3FF9E5C40810,$00004376E88CF9FD
  Data.q $6164745845742500,$74616572633A6574,$302D323130320065,$3A38315438302D31,$30302B31323A3532
  Data.q $000FC5C36D30303A,$6474584574250000,$69646F6D3A657461,$2D32313032007966,$38315438302D3130
  Data.q $302B31323A35323A,$B37D9E1C30303A30,$7458457432000000,$4D5248633A474E50,$77206B6E75686300
  Data.q $646E756F66207361,$6843206565732820,$69636974616D6F72,$766F6261202C7974,$0000DA48D1072965
  Data.q $4E50745845742C00,$6700414D41673A47,$342E303D616D6D61,$2031303034353435,$6D61472065655328
  Data.q $766F6261202C616D,$0000B90AB3D22965,$4E50745845741400,$622E524448493A47,$68747065645F7469
  Data.q $0000507E85293800,$4E50745845741500,$632E524448493A47,$7079745F726F6C6F,$002BA74A06360065
  Data.q $50745845741B0000,$2E524448493A474E,$63616C7265746E69,$646F6874656D5F65,$00008C073BFB3000
  Data.q $4E50745845741E00,$772E524448493A47,$6965682C68746469,$2C31323200746867,$8BE26E4E31323220
  Data.q $7458457446000000,$6572617774666F73,$614D6567616D4900,$362E36206B636967,$31303220352D392E
  Data.q $2037302D34302D31,$7074746820363151,$692E7777772F2F3A,$6967616D6567616D,$5F2B67726F2E6B63
  Data.q $4574180000008D36,$3A626D7568547458,$6E656D75636F443A,$73656761503A3A74,$00002FBBFFA73100
  Data.q $6854745845741800,$616D493A3A626D75,$676965683A3A6567,$BB77313232007468,$457417000000AD44
  Data.q $3A626D7568547458,$3A3A6567616D493A,$3232006874646957,$000000201717AB31,$7568547458457419
  Data.q $656D694D3A3A626D,$616D690065707974,$B23F676E702F6567,$4574170000004E56,$3A626D7568547458
  Data.q $3100656D69544D3A,$3231373430363233,$00000031AEC94531,$7568547458457413,$657A69533A3A626D
  Data.q $42424B322E323100,$4000000039A3AC75,$6D75685474584574,$66004952553A3A62,$752F2F2F3A656C69
  Data.q $6974736F682F7273,$73656C69665F676E,$662F6E69616D2F39,$3637363031656C69,$61642E3736393939
  Data.q $E752936E5D305B74,$444E454900000000,$00000000826042AE
  Dial_eof:
EndDataSection
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
jasper
New User
New User
Posts: 7
Joined: Sat Jan 07, 2012 1:41 am

Re: Dial/Gauge/Clock

Post by jasper »

Bisonte, thats amazing :shock: .

I have some news regarding the png's. They make a big difference with some of the "imperfections" I mentioned earlier. The top layer now looks like the top layer as it should and my range of colors can be expanded. I made a black dial with an orange needle and it looked pretty good. Part of this I think is down to the blending mode. I changed the mode to "2" in this line

Code: Select all

 AddMaterialLayer(0, TextureID(1),2) 
That is something I am still working on improving.

Something else I need to look at was the last needle I drew was eccentric at the pivot point, kinda like the wheel on a circus clowns car. I'm not sure whether that happened during conversion from one format to the other or not.

Thanks for sticking with me on this, do you have any opinion on the results?
jasper
New User
New User
Posts: 7
Joined: Sat Jan 07, 2012 1:41 am

Re: Dial/Gauge/Clock

Post by jasper »

Hi, several of the original issues are now resolved and I have also made some progress toward adding features. When I originally posted this thread I included clock in the title and thought that I might be a little optimistic in saying that. In fact an extra needle/hand can be added quite easily, assuming we create texture #11 and material #1 we can layer that on top of our original material #0 and control its rotation independently of material #0 .

Code: Select all

      CreateMaterial(1, LoadTexture(11, "Needle2.png") )
      AddMaterialLayer(0, TextureID(11),2)
The layers look as they should and the images are sharp, I have uploaded a screen shot of a black dial with a red needle as an example at this link http://www.4shared.com/photo/7usNSoFB/Gauge_SS2.html

The eccentricity seems to prevail so to overcome this I have included a stationary "bezel" at the pivot point in the above example which looks at its best two pixels below center. The bezel is added as another material

Code: Select all

      CreateMaterial(2, LoadTexture(12, "Bezel.png") )
      AddMaterialLayer(0, TextureID(12),2)
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: Dial/Gauge/Clock

Post by VB6_to_PBx »

is there anyway to create "Dial/Gauge/Clock"
without needing to use Microsoft DirectX ??
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
Post Reply