Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Progress Bar

Featured Replies

This will paint a progress bar going left-right or right-left. It has one class and two callable methods: drawProgressBar() || drawReversedProgressBar()

 

Example Usage In onPaint() with the Graphics2D named g:

Spoiler

Defining The Colors To Use:

Spoiler


ProgressBar.drawProgressBar(15, 260, 160, 8, 8, 8, getConfigs().get(243), maxValue, Color.black, Color.cyan, g);

ProgressBar.drawReversedProgressBar(15, 230, 160, 8, 8, 8, currentTime, maxTime, Color.black, Color.cyan, g);

Not Defining Colors:
Spoiler


ProgressBar.drawProgressBar(15, 260, 160, 8, 8, 8, getConfigs().get(243), maxValue, g);

ProgressBar.drawReversedProgressBar(15, 230, 160, 8, 8, 8, currentTime, maxTime, g);

Code:

Spoiler

import java.awt.*;

public abstract class ProgressBar {

    public static void drawProgressBar(int xPos, int yPos, int width, int height, int arcWidth, int arcHeight, float currentValue, float maxValue, Color borderColor, Color fillColor, Graphics2D g) {
        filledProgressBar(currentValue, maxValue, width, xPos, yPos, height, arcWidth, arcHeight, fillColor, g);
        progressBar(xPos, yPos, width, height, arcWidth, arcHeight, borderColor, g);
    }

    public static void drawProgressBar(int xPos, int yPos, int width, int height, int arcWidth, int arcHeight, float currentValue, float maxValue, Graphics2D g) {
        filledProgressBar(currentValue, maxValue, width, xPos, yPos, height, arcWidth, arcHeight, Color.cyan, g);
        progressBar(xPos, yPos, width, height, arcWidth, arcHeight, Color.black, g);
    }

    public static void drawReversedProgressBar(int xPos, int yPos, int width, int height, int arcWidth, int arcHeight, float currentValue, float maxValue, Color borderColor, Color fillColor, Graphics2D g) {
        reversedFilledProgressBar(currentValue, maxValue, width, xPos, yPos, height, arcWidth, arcHeight, fillColor, g);
        progressBar(xPos, yPos, width, height, arcWidth, arcHeight, borderColor, g);
    }

    public static void drawReversedProgressBar(int xPos, int yPos, int width, int height, int arcWidth, int arcHeight, float currentValue, float maxValue, Graphics2D g) {
        reversedFilledProgressBar(currentValue, maxValue, width, xPos, yPos, height, arcWidth, arcHeight, Color.cyan, g);
        progressBar(xPos, yPos, width, height, arcWidth, arcHeight, Color.black, g);
    }


    private static void progressBar(int xPos, int yPos, int width, int height, int arcWidth, int arcHeight, Color colorOfBorder, Graphics2D g) {
        g.setColor(colorOfBorder);
        g.drawRoundRect(xPos, yPos, width, height, arcWidth, arcHeight);
    }

    private static void filledProgressBar(float currentValue, float maxValue, int width, int xPos, int yPos, int height, int arcWidth, int arcHeight, Color colorOfFill, Graphics2D g) {
        currentValue = (currentValue >= maxValue) ? maxValue : currentValue;
        g.setColor(colorOfFill);
        g.fillRoundRect(xPos, yPos, calculateFillAmount(currentValue, maxValue, width), height, arcWidth, arcHeight);
    }

    private static void reversedFilledProgressBar(float currentValue, float maxValue, int width, int xPos, int yPos, int height, int arcWidth, int arcHeight, Color colorOfFill, Graphics2D g) {
        currentValue = (currentValue >= maxValue) ? maxValue : currentValue;
        g.setColor(colorOfFill);
        g.fillRoundRect(xPos, yPos, width - calculateFillAmount(currentValue, maxValue, width), height, arcWidth, arcHeight);
    }

    private static int calculateFillAmount(float currentValue, float maxValue, int width) {
        float percentValueOfFillAmount = currentValue / maxValue;
        return (int) (percentValueOfFillAmount * width);
    }

}

 

Edited by BravoTaco

  • Author
4 hours ago, Kramnik said:

Very awesome snippet. Will test sometime :D 

Thanks! 🙂 Let me know how it goes.

Sweet! I’ll test this today. 

  • Author
4 hours ago, Heist said:

Sweet! I’ll test this today. 

Let me know if anything needs added or fixed

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.