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.

Moveable paint help

Featured Replies

public void mousePressed(MouseEvent e) {
		Point clicked;
		clicked = e.getPoint();

		Rectangle paintArea = new Rectangle((int)startX, (int)startY, mainPaint.getWidth(null), mainPaint.getHeight(null)); //xPos,yPos,width,height

		if(paintArea.contains(clicked)){
			startX = clicked.getX();
			startY = clicked.getY();
		}
	}

This doesn't seem to work. startX and startY are double values. Why doesn't it work?

public void mousePressed(MouseEvent e) {
		Point clicked;
		clicked = e.getPoint();

		Rectangle paintArea = new Rectangle((int)startX, (int)startY, mainPaint.getWidth(null), mainPaint.getHeight(null)); //xPos,yPos,width,height

		if(paintArea.contains(clicked)){
			startX = clicked.getX();
			startY = clicked.getY();
		}
	}

This doesn't seem to work. startX and startY are double values. Why doesn't it work?

 

What is this supposed to do sorry :/

EDIT:

EDIT EDIT: fixed some things 

You mean something like this?:

 boolean dragging = false;
    Rectangle paintArea;

    @Override
    public void onPaint(Graphics2D g) {
        
        int x = 0; //set to where you want it to start off
        int y = 0; //set to where you want it to start off
        if(dragging){
            x = mouse.getPosition().x;
            y = mouse.getPosition().y;
        }
        paintArea = new Rectangle(x, y, mainPaint.getWidth(null), mainPaint.getHeight(null)); 
    }

    @Override
    public void mousePressed(MouseEvent e) {
if(painArea != null){
    if(paintArea.contains(e.getPoint()){
     dragging = true;
     }
     }
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    if(painArea != null && dragging){
      dragging = true;
     ​}
    }

Edited by Isolate

  • Author

 

What is this supposed to do sorry :/

EDIT:

EDIT EDIT: fixed some things 

You mean something like this?:

 boolean dragging = false;
    Rectangle paintArea;

    @Override
    public void onPaint(Graphics2D g) {
        
        int x = 0; //set to where you want it to start off
        int y = 0; //set to where you want it to start off
        if(dragging){
            x = mouse.getPosition().x;
            y = mouse.getPosition().y;
        }
        paintArea = new Rectangle(x, y, mainPaint.getWidth(null), mainPaint.getHeight(null)); 
    }

    @Override
    public void mousePressed(MouseEvent e) {
if(painArea != null){
    if(paintArea.contains(e.getPoint()){
     dragging = true;
     }
     }
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    if(painArea != null && dragging){
      dragging = true;
     ​}
    }

I'm trying to get the paint to move. That too does not work.

I'm trying to get the paint to move. That too does not work.

click and drag? or just click and assumed magic?

Is this test also including my double edit or only the first edit

hmmmm hb:

    boolean dragging = false;
    Rectangle paintArea = null;

    @Override
    public void onPaint(Graphics2D g) {
        if(paintArea == null){
                paintArea = new Rectangle(x, y, mainPaint.getWidth(null), mainPaint.getHeight(null)); 
      }else{
        
        if(dragging){
           paintArea.x = mouse.getPosition().x;
            paintArea.y = mouse.getPosition().y;
        }
}
    }

    @Override
    public void mousePressed(MouseEvent e) {
if(painArea != null){
    if(paintArea.contains(e.getPoint()){
     dragging = true;
     }
     }
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    if(dragging){
      dragging = false;
     ​}
    }

Code is starting to look overcomplicated though

Edited by Isolate

  • Author

click and drag? or just click and assumed magic?

Is this test also including my double edit or only the first edit

hmmmm hb:

    boolean dragging = false;
    Rectangle paintArea = null;

    @Override
    public void onPaint(Graphics2D g) {
        if(paintArea == null){
                paintArea = new Rectangle(x, y, mainPaint.getWidth(null), mainPaint.getHeight(null)); 
      }else{
        
        if(dragging){
           paintArea.x = mouse.getPosition().x;
            paintArea.y = mouse.getPosition().y;
        }
}
    }

    @Override
    public void mousePressed(MouseEvent e) {
if(painArea != null){
    if(paintArea.contains(e.getPoint()){
     dragging = true;
     }
     }
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    if(dragging){
      dragging = false;
     ​}
    }

Code is starting to look overcomplicated though

Still no, I guess I'll just request a tutorial on getting paint to move on mouseDrag

Is "mainPaint" even a object?

 

In order to pull of something like this you will need to make a rectangle, then wherever you click on the rectangle get that (x,y) value and wherever your mouse ends up calculate the new (x,y) value. Then you also have to calculate the corresponding (x,y) values for the strings you are painting (relative positioning seems best for this). I dunno what those two methods above were about :/

  • Author

Is "mainPaint" even a object?

 

In order to pull of something like this you will need to make a rectangle, then wherever you click on the rectangle get that (x,y) value and wherever your mouse ends up calculate the new (x,y) value. Then you also have to calculate the corresponding (x,y) values for the strings you are painting (relative positioning seems best for this). I dunno what those two methods above were about :/

Mainpaint is just the Image of the paint. I tried doing something like this, got the the paint to move to where i clicked the mouse, but I couldn't click and drag it, Also, I was only able to click inside the paint, which only made the paint move to the bottom right hand corner of the screen. Tried getting it to be able to follow mouse, but I can't. Any ideas?

public void mousePressed(MouseEvent e) {
		Point clicked;
		clicked = e.getPoint();

		Rectangle paintArea = new Rectangle((int)startX, (int)startY, mainPaint.getWidth(null), mainPaint.getHeight(null)); //xPos,yPos,width,height

		if(paintArea.contains(clicked)){
			startX = clicked.getX();
			startY = clicked.getY();
		}
	}

This doesn't seem to work. startX and startY are double values. Why doesn't it work?

 

 

 

Ill hint what you need to do, you will have to put in the effort of coding it.

 

-When the mouse is clicked, check if the mouse is in the paint area.

-If the mouse is in the paint area, update the x, y values of the paint to the mouse x, y coordinates (in the onPaint method, use variables  for this). This will move the paint around to the mouse position while the mouse is being held down.

-when the mouse is released, stop moving the paint.

 

 

You should think of a logical way to do it before just trying to code it.

Ill hint what you need to do, you will have to put in the effort of coding it.

 

-When the mouse is clicked, check if the mouse is in the paint area.

-If the mouse is in the paint area, update the x, y values of the paint to the mouse x, y coordinates (in the onPaint method, use variables  for this). This will move the paint around to the mouse position while the mouse is being held down.

-when the mouse is released, stop moving the paint.

 

 

You should think of a logical way to do it before just trying to code it.

I swear thats what i gave a snippet of (although it was 1am and i might have missed something)

I swear thats what i gave a snippet of (although it was 1am and i might have missed something)

 

 

What you posted wont even paint anything. It looks like you had the right idea, but the syntax wasnt there.

Guest
This topic is now closed to further replies.

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.