ProgressCircle (for Linux/Windows & Mac.. I guess))

Share your advanced PureBasic knowledge/code with the community.
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

walker wrote:@Demivec: didn't understand what you want to achieve with the line state%segments ,,,,
Frankly, I agree. I don't know what I wanted to achieve.:wink: I could explain what I did achieve but I think it may be wiser to let it die on the vine.


On to other things.

1. I think it would be better to avoid redrawing all of the states each time you are only advancing by one. Here is my change: set only a single state, unless the value of state is negative. If state<0 then set the range of states from 1 to +state.

2. Changed state drawing calculations. Made calculations more precise and did away with nudging. The number of Segments is now only limited by resolution instead of wether it was divisible by 4 (or any other #). The smallest working (Size,Segments) combo is 12 with 8 Segments!:shock: If you want to read the text the smallest Size would be 26, if you've got good eyes.:wink:

Here's the code with changes included:

Code: Select all

;- ProgressCircle
;  2008 by walker
; modifications by ebs
; modifications by Demivec
; modifications by walker
;--------------------------------------------
;-free for everyone and any purposes
;-enhancements made by others
;-must be published and posted in the same PB-Forum ;-)
;-cross plattform ability must be achieved
;--------------------------------------------
EnableExplicit

Procedure ProgressCircle(gadgetNumber.l,x.l,y.l,Size.l,segments.l,fg.l,bg.l)
  Protected radius.l,n.l,X2.l,Y2.l,img.l, beta_in_rad.d
  
  img = CreateImage(#PB_Any,Size,Size)
  StartDrawing(ImageOutput(img))
  Box(0,0,Size,Size,bg)
  radius = Size/2
  Circle(radius,radius,radius,fg)
  Circle(radius,radius,2*radius/3,bg)

  ; draw radial lines
  For n = 0 To segments-1
    beta_in_rad = (2*#PI*n)/segments - #PI/2 ; [Demivec] updated formula makes nudging unnecessary in SetProgressCircleState
    X2.l = radius *(1 + Cos(beta_in_rad))
    Y2.l = radius *(1 + Sin(beta_in_rad))
    LineXY(radius,radius,X2,Y2,bg)
  Next
  StopDrawing()
  ImageGadget(gadgetNumber,x,y,Size,Size,ImageID(img))
  SetGadgetData(gadgetNumber, img) ;store #image with gadget
EndProcedure

Procedure SetProgressCircleState(progressbar.l,segments.l, state.l, Text.s , COLOR.l, backgroundcolor.l, textcolor.l=0)
  Static progCirc_font.l
  Protected IW2.l,TW2.l,TH2.l,x.l,y.l
  Protected img.l = GetGadgetData(progressbar) ;retrieve stored #image
  Protected beta_in_rad.d
  Protected m.l,rangeStart.l ; [Demivec]
  
  IW2.l = ImageWidth(img)/2
  If progCirc_font = 0 ;avoid loading font if it is already loaded   
    progCirc_font = LoadFont(#PB_Any,"sans",IW2/3-1,#PB_Font_Bold)
  EndIf                                                                                                     
  
  StartDrawing(ImageOutput(img))   
  If Text
    ; use circle color for text
    DrawingFont(FontID(progCirc_font));
    TH2 = TextHeight(Text)/2
    TW2 = TextWidth(Text)/2   
    Circle(IW2,IW2,2*IW2/3,backgroundcolor) ;
    DrawText(IW2-TW2,IW2-TH2,Text,textcolor,backgroundcolor)
  EndIf   
  
  ;check if setting a range or only a single state [Demivec]
  ; a range will be set (of from 1 to state) if state is negative,
  ; only the single state will be set if state>0
  If state<0
    rangeStart = 1
    state * -1
  Else
    rangeStart = state
  EndIf 
  
  ; adjust angle so first segment is at top of circle
  state -1
  For m= rangeStart - 1 To state ; To clear the circle (set color to initial color and text to 1 space, and state=-segments)  [Demivec] changed explanation
    beta_in_rad.d = #PI*((2*m+1)/segments - 1/2)  ; [Demivec] updated formula makes nudging unnecessary
    ; calculate point on radius
    x = IW2 + (IW2 - 2)*Cos(beta_in_rad) ; [Demivec] adjusted to find a point at a set distance from largest radius
    y = IW2 + (IW2 - 2)*Sin(beta_in_rad) ;           to avoid segment lines 
    FillArea(x,y,backgroundcolor,COLOR)
  Next
  
  StopDrawing()
  SetGadgetState(progressbar,ImageID(img))
  While WindowEvent():Wend; update the gadget
  ProcedureReturn 1
EndProcedure

;---- DEMO -----<
Define.l bg,fg,stp,Size,r,g,b,count,m
Define.l Event

bg=$D2D8C3; backgroundcolor
fg=$AAB68F; initial color of the circle
stp=33 ;Any value allowed, working values are usually less than Size (i.e. stp<Size), [Demivec]
;for max segments for lower sizes these work (stp,size) (32,30) (16,20) (12,16) (8,12), (100,120) (1 to 44,50)
Size=50 ;12 is minimum;  maximum... your screen ;-)

OpenWindow(0,0,0,310,310,"ProgressCircle DEMO",#PB_Window_SystemMenu | #PB_Window_SizeGadget)
CreateGadgetList(WindowID(0))
ProgressCircle(0,70,70,Size,stp,fg,bg)

r=10
g=150
b=10
count=0
Repeat
  For m= 1 To stp
    SetProgressCircleState(0,stp,m,Str(1+100/stp*m)+ "%",RGB(r, g, b),bg, RGB(236, 200-(m*5), 19))  ; [Demivec]  adjusted % calculation
    Delay(300)
    Event = WindowEvent()
    While Event ;improved event catcher for demo
      If Event = #PB_Event_CloseWindow
        Break 2
      EndIf
      Event=WindowEvent()
    Wend
  Next
  count+1
  r+20
  g+20
  b+10
  If r >240 Or g>240 Or  b>240
    r=Random(255)
    g=Random(255)
    b=Random(255)
  EndIf
Until Event =#PB_Event_CloseWindow Or count=3
SetProgressCircleState(0,stp,-stp," ",fg,bg); clear the ProgressCircle.... [Demivec] using new parameter method 
Delay(3000)
End
I think another desirable feature is the possibility of displaying a continous circle of segments (without lines).
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

... I think we now have a nearly perfect new control for PB 8) 8)
(what could be achieved if only a few people work together... :D )

a continous progresscircle (without segments) is a little bit more complicated as there is no function to draw a part of a circle ... but maybe this isn't needed..... :idea: I have an idea.... I'll try it out and will then post the result
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Post by michel51 »

walker wrote:... I think we now have a nearly perfect new control for PB 8) 8)
(what could be achieved if only a few people work together... :D )

a continous progresscircle (without segments) is a little bit more complicated as there is no function to draw a part of a circle ... but maybe this isn't needed..... :idea: I have an idea.... I'll try it out and will then post the result
That would be nice on Mac too, but...

...I get an error in line 51

Code: Select all

DrawingFont(FontID(progCirc_font));
The message: "#font object not initialized".

I don't found where the font is loaded, so the FontID(..) occures an error I think.

//Edit// Ok, I tried a lot, and with this line

Code: Select all

DrawingFont(#PB_Default) 
it works. Not very constant - often 1 segment, sometimes 2 or 3 segments together - but it works.
May be, it can run a little bit faster and homogeneous, but I don't know how to do on Mac at this time. I will try...
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

I finally realized where I saw this graphic... The wife and I were watching T3 Rise of the Machines... It is in the TX HUD...

Does this mean the TX runs on PB???
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

michel51 wrote:That would be nice on Mac too, but...

....snipped

The message: "#font object not initialized".
it works. Not very constant - often 1 segment, sometimes 2 or 3 segments together - but it works.
May be, it can run a little bit faster and homogeneous, but I don't know how to do on Mac at this time. I will try...
Try the updated version below.
walker wrote:... I think we now have a nearly perfect new control for PB 8) 8)
(what could be achieved if only a few people work together... :D )

a continous progresscircle (without segments) is a little bit more complicated as there is no function to draw a part of a circle ... but maybe this isn't needed..... :idea: I have an idea.... I'll try it out and will then post the result
I worked on a more nearly perfect version.

Modifications:
  • 1. Organized most parameters into a structure. This allows more than one progressCircle to be displayed. (I will try to create a demo for that)

    2. Unified the setup and the update procedure, now just one ProgressCircle() that does everything.

    3. Implemented a command format for ProgressCircle(). This makes it possible for the function to peform the following: setup default values for structure, initialize a progress circle, update a progress circle, free progress circle items (gadget,image,font) when no longer needed.

    4. Implemented a changeable font (size determined by circle size, and in Bold). It can be changed for each update of progress circle by specifying the new fonts name before the update.

    5. Made it possible to use a custom image#,gadget#, or fontID or have them generated when the progress circle is initialized/updated.

    6. Used the parameter of "radius" to specify how large progress circle would be instead of "Size." This makes the resultant size equivalent to 2 * radius, so it's always even.

    7. Added lots of documentation. Also increased program by 59 lines of code (excluding comments and blank lines). Removed old unnecessary comments.

    8. Made it possible to implement further idea changes via the command structure.

    9. Minor changes to variable names.
Did a speed test of complete demo run, with Delay()'s commented out and exiting when count=1000 for both this updated version and the previous one posted by me. The speed for this one was at least as fast as the previous code's time. About 2400 milliseconds for 33000 updates including the time for the rest of the demo code. That's 13.75 updates per millisecond, worst time still produce more than 12 updates per millisecond.

Code: Select all

;- ProgressCircle
;  2008 by walker
; modifications by ebs
; modifications by Demivec
; modifications by walker
;--------------------------------------------
;-free for everyone and any purposes
;-enhancements made by others
;-must be published and posted in the same PB-Forum ;-)
;-cross plattform ability must be achieved
;--------------------------------------------
EnableExplicit

; [Demivec] organized most parameters into a structure.
;  Allows more than one progressCircle to be displayed.
Structure ProgressCircle 
  ;for init: need to set radius,segmentCount,segmentColor,backgroundColor,gx,gy,gadgetNum,imageNum
  ;  all values used for init, excluding segmentColor are considered constants after init is performed
  ;between updates: can change segmentColor,textcolor, either fontID or newFont/fontNum
  
  radius.l          ;radius of circle (=1/2 Size) ;12 is minimum;  maximum... your screen ;-)
  segmentCount.l    ;#of segments in circle ;any value allowed, working values are usually less than Size (i.e. segments<Size)
                    ;for max segments at various sizes these work (seg,Size) (8,12) (12,16) (16,20) (32,30) (1 to 44,50) (100,120) 
  segmentColor.l    ;color of circle ,during init the entire circle is drawn in this color
  backgroundColor.l ;background color of circle
  textColor.l       ;color of text in circle
  
  gx.l              ;coordinates to create ImageGadget at (used only during init)
  gy.l  
  
  ;If any of the next two values are set to #PB_any, an init call will set them with their new value,
  ;if they are not equal to #PB_Any their value will be used for the desired item.
  gadgetNum.l       ;if =#PB_Any during init, will be equal to gadget# on exit
  imageNum.l        ;if =#PB_Any during init, will be equal to image# on exit
  
  ;A user should either set fontID to a pre-initialized fontID or they should set newFont to the name of font.
  ;If newFont is used it will have the side-effect of freeing the previous fontID, so for a given
  ;ProgressCircle only one method should be used during it's existance.
  fontID.l          ;font handle for displayed text, if not zero it is treated as valid (or pre-initialized)
  newFont.s         ;name of font to use load during next update, fontID will equal the font handle and this
                    ;will equal "" after LoadFont is attempted
  fontNum.l         ;if =#PB_Any during init, will be equal to font# on exit or zero, this value can be read
                    ;to determine if a new font was succesfully loaded (it will be non-zero if successful)
  
  ;style.l           ;not currently used, it indicates if using a continuous or a segmented circle
EndStructure


; [Demivec] utilized a structure to hold ProgressCircle data, unified seperate procedures and created
;  a command format to specify actions (rather OOP like), allowed font to be specified and changed,
;  made it possible to use either #pb_any or custom values for gadget#,image#,fontID.

Procedure ProgressCircle(*pCircle.ProgressCircle, cmd.l, state.l = 1, Text.s = "")
  Protected x.l,y.l,m.l,TW2.l,TH2.l,rangeStart.l
  Protected angle_rad.d
  
  ;Call procedure ProgressCircle with the forms below to accomplish each given task:
  ;  ProgressCircle(@Data.ProgressCircle,10)                Setup Data of ProgressCircle with default values
  ;  ProgressCircle(@Data.ProgressCircle,0)                 Init ProgressCircle
  ;  ProgressCircle(@Data.ProgressCircle,1,state# [,Text])  Draw a specific state# [, display Text]
  ;  ProgressCircle(@Data.ProgressCircle,1,-state# [,Text]) Draw a range of states from 1 to +state# [, display Text]
  ;  ProgressCircle(@Data.ProgressCircle,-1)                Free circle elements (image,font,gadget), convenient to
  ;                                                         use if all three items were created by ProgressCircle. 
   Select cmd ;commands in order of likely use
   ;the command #'s are more or less arbitrary, may be better to replace with constants in future
   ;of the form #PC_SetDefaults_cmd or maybe these forms #PCCmd_Init,#PCCmd_Update,#PCCmd_FreeElements
    Case 1  ;{draw state#
      
      ;check if current font should be replaced with a new font
      If *pCircle\newFont <> ""
        If *pCircle\fontNum <> #PB_Any
          FreeFont(*pCircle\fontNum) ;free font if a previous font was loaded
        EndIf
        *pCircle\fontNum = LoadFont(*pCircle\fontNum,*pCircle\newFont,*pCircle\radius / 3 - 1,#PB_Font_Bold)
        *pCircle\newFont = "" ;reset so repeated attempts will not be made
        If IsFont(*pCircle\fontNum) ;if successfully loaded set the fontID
          *pCircle\fontID = FontID(*pCircle\fontNum)
        EndIf 
      EndIf
      

      StartDrawing(ImageOutput(*pCircle\imageNum))   
      ;handle text first
      If Text <> "" 
        If *pCircle\fontID <> 0  ;check if fontID is initialized
          DrawingFont(*pCircle\fontID) ;use only successfully loaded font
          TH2 = TextHeight(Text) / 2
          TW2 = TextWidth(Text) / 2   
          Circle(*pCircle\radius,*pCircle\radius,2 * *pCircle\radius / 3,*pCircle\backgroundColor) ;clear text area
          DrawText(*pCircle\radius - TW2,*pCircle\radius - TH2,Text,*pCircle\textColor,*pCircle\backgroundColor)
        EndIf
      EndIf   
      
      ;check if setting a range or only a single state 
      ; a range will be set (of from 1 to state) if state is negative,
      ; only the single state will be set if state>0
      If state<0
        rangeStart = 1
        state * -1
      Else
        rangeStart = state
      EndIf
      
      ;first segment is at top of circle
      state - 1
      For m= rangeStart - 1 To state ; To clear the circle (set color to initial color and text to 1 space, and state=-segments)  [Demivec] changed explanation
        angle_rad.d = #PI * ((2 * m + 1) / *pCircle\segmentCount - 1/2) 
        ; calculate point on radius
        x = *pCircle\radius + (*pCircle\radius - 2) * Cos(angle_rad) ; adjusted to find a point at a set distance from largest radius to avoid segment lines
        y = *pCircle\radius + (*pCircle\radius - 2) * Sin(angle_rad)           
        FillArea(x,y,*pCircle\backgroundColor,*pCircle\segmentColor)
      Next
      StopDrawing()
      
      SetGadgetState(*pCircle\gadgetNum,ImageID(*pCircle\imageNum)) ;}
    Case 0  ;{initialize progress circle image and gadget
      ;  
      If *pCircle\imageNum = #PB_Any 
        *pCircle\imageNum = CreateImage(#PB_Any,*pCircle\radius * 2,*pCircle\radius * 2) ;assign a generated image#
      Else
        ;use image# supplied (frees previous image if necessary)
        CreateImage(*pCircle\imageNum,*pCircle\radius * 2,*pCircle\radius * 2)
      EndIf 
        
        StartDrawing(ImageOutput(*pCircle\imageNum))
        Box(0,0,*pCircle\radius * 2,*pCircle\radius * 2,*pCircle\backgroundColor)
        Circle(*pCircle\radius,*pCircle\radius,*pCircle\radius,*pCircle\segmentColor)
        Circle(*pCircle\radius,*pCircle\radius,2 * *pCircle\radius / 3,*pCircle\backgroundColor)
        
        ; draw radial lines
        For m = 0 To *pCircle\segmentCount - 1
          angle_rad = (2 * #PI * m) / *pCircle\segmentCount - #PI/2 ;
          x.l = *pCircle\radius * (1 + Cos(angle_rad))
          y.l = *pCircle\radius * (1 + Sin(angle_rad))
          LineXY(*pCircle\radius,*pCircle\radius,x,y,*pCircle\backgroundColor)
        Next
        StopDrawing()
        
        If *pCircle\gadgetNum = #PB_Any 
          *pCircle\gadgetNum = ImageGadget(#PB_Any,x,y,*pCircle\radius * 2,*pCircle\radius * 2,ImageID(*pCircle\imageNum))
        Else
          ImageGadget(*pCircle\gadgetNum,*pCircle\gx,*pCircle\gy,*pCircle\radius * 2,*pCircle\radius * 2,ImageID(*pCircle\imageNum))
        EndIf ;}
    Case -1 ;{free progress circle elements (image, font, gadget)
      If IsGadget(*pCircle\gadgetNum)
        FreeGadget(*pCircle\gadgetNum)
        *pCircle\gadgetNum = 0
      EndIf
      If IsFont(*pCircle\fontNum)
        FreeFont(*pCircle\fontNum)
        *pCircle\fontNum = 0
      EndIf
      If IsImage(*pCircle\imageNum)
        FreeImage(*pCircle\imageNum)
        *pCircle\imageNum = 0
      EndIf ;}
    Case 10 ;{setup default progress circle data, suitable for an init cmd
      ;gx,gy,textColor values are left unchanged
      *pCircle\radius = 25
      *pCircle\segmentCount = 25
      *pCircle\segmentColor = $AAB68F 
      *pCircle\backgroundColor = $D2D8C3
      *pCircle\gadgetNum = #PB_Any
      *pCircle\imageNum = #PB_Any
      *pCircle\fontNum = #PB_Any
      *pCircle\fontID = 0 
      
      CompilerIf #PB_Compiler_OS = #PB_OS_Windows
      *pCircle\newFont = "Arial"
      CompilerEndIf
      
      CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
      *pCircle\newFont = "Arial"  ;I think this is normally installed and available
      CompilerEndIf
        
      CompilerIf #PB_Compiler_OS = #PB_OS_Linux
      *pCircle\newFont = "FreeSans" ;this is only a guess, suggestions welcome
      CompilerEndIf ;}
       
  EndSelect
  
  While WindowEvent():Wend; update the gadget
  ProcedureReturn 1

EndProcedure

;---- DEMO -----<
Define.l r,g,b,count,m
Define.l Event

OpenWindow(0,0,0,310,310,"ProgressCircle DEMO",#PB_Window_SystemMenu | #PB_Window_SizeGadget)
CreateGadgetList(WindowID(0))

Define.ProgressCircle circle_1,circle_2

;setup progressCircle data
ProgressCircle(@circle_1,10) ;set ProgressCircle defaults
circle_1\gadgetNum = 0 ;#PB_Any
circle_1\gx = 70
circle_1\gy = 70

ProgressCircle(@circle_1,0) ;initialize progressCircle

r = 10
g = 150
b = 10
count = 0
Repeat
  circle_1\segmentColor = RGB(r, g, b)
  For m = 1 To circle_1\segmentCount
    circle_1\textColor = RGB(236, 200 - (m * 5), 19)
    ProgressCircle(@circle_1,1,m,Str(1 + 100 / circle_1\segmentCount * m) + "%") ;update ProgressCircle
    Delay(100)
    Event = WindowEvent()
    While Event ;improved event catcher for demo
      If Event = #PB_Event_CloseWindow
        Break 2
      EndIf
      Event=WindowEvent()
    Wend
  Next
  count+1
  r+20
  g+20
  b+10
  If r >240 Or g>240 Or  b>240
    r=Random(255)
    g=Random(255)
    b=Random(255)
  EndIf
Until Event =#PB_Event_CloseWindow Or count=3
circle_1\segmentColor = $AAB68F
ProgressCircle(@circle_1,1,-circle_1\segmentCount) ; clear the ProgressCircle.... [Demivec] using new parameter method
Delay(300)
;ProgressCircle(@circle_1,-1) ;free Progress Circle elements, image,gadget,font [Demivec]
End
@Edit: moved the change in segmentColor outside of demo's inner loop, added additional comments
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Post by michel51 »

Demivec wrote: Try the updated version below.
Works fine here and very quick :D
Great job :!:

If I see right, the first and last 4 (5) segments come together. This is the only "error" I've registered. (Oh god, my english :lol: )

May be, you can find out what happens. Or it's possible that's an effect only on Mac.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

michel51 wrote:
Demivec wrote: Try the updated version below.
Works fine here and very quick :D
Great job :!:

If I see right, the first and last 4 (5) segments come together. This is the only "error" I've registered. (Oh god, my english :lol: )

May be, you can find out what happens. Or it's possible that's an effect only on Mac.
How about supplying a small, non-jpg image showing what you're seeing? It would help a great deal.
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Post by michel51 »

Demivec wrote: How about supplying a small, non-jpg image showing what you're seeing? It would help a great deal.
It's not easy to declare and handle.
Please download this archive, extract and you will find 6 pictures.

http://rapidshare.com/files/101346742/Archiv.zip

The first 5 pictures show the standing segments but changing numbers. The 6. picture the next segment is drawn with a new number.

The same effect at the end of the circle. No pictures here, because it's difficult to create.

Hope it's ok to let you know in this way.
If not, send me a pn, then I will send back the archive.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

Hi michel51,

could you please set a breakpoint on line 111 (use the last posted source ... and use without changes...!)

Code: Select all

FillArea(x,y,*pCircle\backgroundColor,*pCircle\segmentColor)
and then make a screenshot (after first halt) from the variable-viewer like the following? (don't forget to open the circle_1 structure with a doubleclick)

Image
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Post by michel51 »

walker wrote:Hi michel51,

could you please set a breakpoint on line 111 (use the last posted source ... and use without changes...!)
Hi walker,

sorry, but I don't know an other way at this time...
The 2. picture beginns with circle_2.ProgressCircle [url]http://rapidshare.com/files/10 ... 2.zip.html
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

...well it seems that al values are the same... EXCEPT... angle_rad it is defined as double... and on your machine it's only a float? doesn't double exist on Mac? otherwise here's a bug in the MACOs Version.... and should be reported... (the type is changed by PB from double to float though double was declared)

Another differences are TH2 and TW2 .... TH2 must be 5 if the size of the loaded font = 25/3+1 (which equals to 9) your screenshot says TH2= 8... that's why the text is a little above the centre... (maybe a failure of internal math of PB?)

(TW2 differs 1 point.... but that depends on the font....)

but that all doesn't mind for calculating the coordinates..... I guess there are bugs in the internal math of PB for MacOs... or the FillArea() command has an issue....

could you please upload another pair of screenshots but this time after the 3rd or 4th stop (as you like)?
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

michel51 wrote:
walker wrote:Hi michel51,

could you please set a breakpoint on line 111 (use the last posted source ... and use without changes...!)
Hi walker,

sorry, but I don't know an other way at this time...
The 2. picture beginns with circle_2.ProgressCircle [url]http://rapidshare.com/files/10 ... 2.zip.html
I asked for the pictures for some good reasons. One is this, the circle you showed isn't round. This means that the circle function didn't translate to an identical circle for the MAC OS.

In the pictures it appears as if the circle is larger than it should be. This can be seen by comparing the top of the circle to the bottom and the left of the circle to it's right side. They're not mirror images of each other.

I have noticed some discrepancies of this nature under Windows also. It is caused by PB's circle function being translated into an Ellipse function in the Windows API. I think this might be the case for you also (MAC QuickGraph library I think it's called). I've worked out some adjustments for this under Windows (they are not complete and I haven't posted them yet). I think one solution would be to add code that would draw the circles without using PB's function. I'm trying to determine if this is feasible or not.
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Post by michel51 »

walker wrote:could you please upload another pair of screenshots but this time after the 3rd or 4th stop (as you like)?
Here you are.

http://rapidshare.com/files/101528371/Archiv_3.zip.html

After 4 steps...
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

Post by superadnim »

Why not just use images (thus letting an artist do their work to match it to the current program's theme, style, etc) instead of hard-coding it all?

Using a little image-strip will be faster, of course you'll waste N times of memory but given how ugly this is compared to a rendered product, I'd still take my chances.

PS: It goes up to 101%?

:lol: should I bash the keyboard and give up?
:?
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

superadnim wrote:Why not just use images (thus letting an artist do their work to match it to the current program's theme, style, etc) instead of hard-coding it all?

Using a little image-strip will be faster, of course you'll waste N times of memory but given how ugly this is compared to a rendered product, I'd still take my chances.

PS: It goes up to 101%?
@superadnim: I think if you post your code everone will see if what you suggest is worth it. It is a work iin progress. It apparently hasn't reach the point of doing the things you suggest, though it has the structure in place to make it possible. walker invited everyone to improve it, why don't you jump-start the ideas you suggest?

What's an example of a "rendered product?"


PS. The "demo" goes up to 101%. I think since the features are evolving and improving it makes sense that the demo is the least important part and the last to be updated.
Post Reply