Jump to content

How to get an onPaint mouse cursor for weird noobs


TheCongregation

Recommended Posts

Copy and paste this and put it AFTER your onLoop:

 

Spoiler

@Override

public void onPaint(Graphics2D g) {

 

// Get the mouse position on the screen

Point mouseScreenPosition = getMouse().getPosition();

 

// Draw the cursor body

drawCustomCursor(g, mouseScreenPosition);}

Then copy and paste this and also put it AFTER your onLoop

 

Spoiler

public void drawCustomCursor(Graphics2D g, Point mouseScreenPosition) {

int cursorSize = 20; // Adjust cursor size as needed

 

// Define the points for the custom cursor shape (star with spikes)

int[] xPoints = {

mouseScreenPosition.x - cursorSize / 2,

mouseScreenPosition.x,

mouseScreenPosition.x + cursorSize / 2,

mouseScreenPosition.x + cursorSize / 4,

mouseScreenPosition.x,

mouseScreenPosition.x - cursorSize / 4

};

int[] yPoints = {

mouseScreenPosition.y - cursorSize / 4,

mouseScreenPosition.y - cursorSize / 2,

mouseScreenPosition.y - cursorSize / 4,

mouseScreenPosition.y + cursorSize / 4,

mouseScreenPosition.y + cursorSize / 2,

mouseScreenPosition.y + cursorSize / 4

};

 

// Set gold color for the border

g.setColor(new Color(255, 215, 0)); // Gold color (255, 215, 0)

 

// Draw the cursor shape with a thicker gold border

g.setStroke(new BasicStroke(2)); // Increase the stroke width for the border

g.drawPolygon(xPoints, yPoints, xPoints.length); // Draw the border

 

// Set custom cursor color (bright red with 25% opacity)

g.setColor(new Color(255, 0, 0, 64)); // Red (255, 0, 0) with alpha (64)

 

// Draw the cursor shape with less opacity

g.fillPolygon(xPoints, yPoints, xPoints.length); // Fill the shape

 

// Draw a smaller shape in the center (triangle with silver color)

int smallShapeSize = 8; // Size of the smaller shape

int[] smallXPoints = {

mouseScreenPosition.x - smallShapeSize / 2,

mouseScreenPosition.x + smallShapeSize / 2,

mouseScreenPosition.x

};

int[] smallYPoints = {

mouseScreenPosition.y + smallShapeSize / 2,

mouseScreenPosition.y + smallShapeSize / 2,

mouseScreenPosition.y - smallShapeSize / 2

};

g.setColor(new Color(224, 224, 224, 192)); // Silver color (192, 192, 192) with alpha (128)

g.fillPolygon(smallXPoints, smallYPoints, 3); // Fill the triangle

}

Badabing Badaboom you gots yourself a mouse cursor, ask chat gpt if you wanna change the shape and colour of it etc or just mess with the colours and cursor sizes that are already present in the above method

  • Boge 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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