Mini Gauges

Share your advanced PureBasic knowledge/code with the community.
l1marik
User
User
Posts: 49
Joined: Tue Jun 30, 2020 6:22 am

Mini Gauges

Post by l1marik »

Mini Gauges
Task was clear, to make minimalist gauges of icon size :D

Image

Source: http://www.ctvrtky.info/wp-content/uplo ... Gauges.tar
ebs
Enthusiast
Enthusiast
Posts: 530
Joined: Fri Apr 25, 2003 11:08 pm

Re: Mini Gauges

Post by ebs »

l1marik,

I love your series of gauges - please keep them coming! One question:

Why is the statement

Code: Select all

gray = Point(x, y)
in the drawing loop in the procedure ImageToColor()? I commented it out and it has no effect.

Regards,
Eric
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Mini Gauges

Post by infratec »

You should definately use EnableExplicit.

To avoid an error you should use some checks:

Code: Select all

If IsGadget(parent_canvas)
    
    If GadgetWidth(parent_canvas) > 0
      
      If StartVectorDrawing(CanvasVectorOutput(parent_canvas))
Else if you reduce the window to the titlebar it results in an error.

And why not 'own' gadgets instead of drawing?
Than you can avoid the resizing commands. This can be done automatically. (If you want it)
l1marik
User
User
Posts: 49
Joined: Tue Jun 30, 2020 6:22 am

Re: Mini Gauges

Post by l1marik »

ebs wrote:l1marik,

I love your series of gauges - please keep them coming! One question:

Why is the statement

Code: Select all

gray = Point(x, y)
in the drawing loop in the procedure ImageToColor()? I commented it out and it has no effect.

Regards,
Eric
Dear Eric, it is some rest in the code, thank you for notice.

Lukas
l1marik
User
User
Posts: 49
Joined: Tue Jun 30, 2020 6:22 am

Re: Mini Gauges

Post by l1marik »

infratec wrote:You should definately use EnableExplicit.

To avoid an error you should use some checks:

Code: Select all

If IsGadget(parent_canvas)
    
    If GadgetWidth(parent_canvas) > 0
      
      If StartVectorDrawing(CanvasVectorOutput(parent_canvas))
Else if you reduce the window to the titlebar it results in an error.

And why not 'own' gadgets instead of drawing?
Than you can avoid the resizing commands. This can be done automatically. (If you want it)
Dear infratec, answer is simple, for demo I wrote code as minimally needed, without any extra checking. For final application it is different story.

Lukas
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Mini Gauges

Post by Saki »

Hi,
Codes for the forum should always be as perfect as possible.
Beginners look at the codes or take them over completely.

Bad programming style is thus inherited.

Therefore, always document the codes well.

EnableExplicit is a "Must have" for every code that is made available to others.

Only beginners or unteachable people do without it.
There are then quickly no more answers or ratings from other users.
The interest in such codes diminishes very quickly.

The problem with the low priority of the window timers can unfortunately
not be solved by using BindEvent() it just shift the problem a little.

If you want to use window timers, it is best to set only one.
This one can then be divided into several.

Using threads forces the user to create a thread safe executable, so I avoid this completely.
If you want to do this, you are probably more experienced and can add it yourself.

But for the cyclic execution of a multi timer it is not necessary, at least not for my code.


Best Regards Saki
地球上の平和
Post Reply