Jump to content

Need help with some calculations.


keymetaphore

Recommended Posts

Posted

Hey.

I might be asking a real stupid question, but I've just ran out of ideas.

I am creating a progress bar, based on DX (the one on wiki wont work because its divided in parts).

I have created the first rectangle, but I have trouble calculating the width of the second one.

-- ex. code
-- first rectangle, base
baseWidth = 200
dxDrawRectangle(10, 10, baseWidth, 10) -- might be lack of args, but you get the point

-- second rect indicating progress
progress = 4
dxDrawRectangle(10, 10, baseWidth/4, 10) -- this is not a correct calculation, just an example

I

AKA Syncer

  • Moderators
Posted
baseWidth * (progress / 100)

 

4 progress / 100 = 0.04

0.04 * 200 = 8 px

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...