fix problems with setting cursor to an image; image pixely, contains colors that it shouldn't

Heey guys,

My program shows the picture I set the cursor to be, but the picture is pixely, contains colors that aren't in the original picture and gets distorted at times. Since, apparantly the mouse isn't visible when you take a screenshot I don't know how to show you. I thought I would just show you most of the code, since I'm a beginner and might leave stuff out that actually causes the problem.

//Intialize picture aimingpoint
PImage aimingpoint;

//define class object
hare one;

//define boolean for pulling gun
boolean pull;

int width = 600;
int height = 600;

float middleX = width/2;
float middleY = height/2;

//Define values for position and size hunters
float xPosHunter1 = 0;
float yPosHunter1 = 0;
float xPosHunter2 = -200;
float yPosHunter2 = 0;
int radHunter = 10;

int deadlyDistance = 150;

//Define animalspeed
int animalSize = 10;
float hareSpeed = 1;

void setup() {
  size(width, height);
  //Define hare one
  one = new hare(100, 1);
  aimingpoint = loadImage("aimingpoint.png");

void draw() {
  //calculate angle between the line that goes fromthe origin to the mouse and postive x-axis
  //I posted a question about this on


  //Move origing to the middle of the canvas.
  translate(0.5 * width, 0.5 * height);

  //Flip the canvas in the x-axis so that the axis system is like a 'normal' one.
  scale(1, -1);

  //draw mouse as aimingpoint
  cursor(aimingpoint, 16, 16);
  //  ellipseMode(CENTER);
  //  ellipse(mouseX, mouseY, 5, 5);
  //  noFill();
  //  ellipse(mouseX, mouseY, 30, 30);

     if ((keyPressed == true && key == 'p' || key == 'P') && mousePressed == true && distanceOriginMouse() <= deadlyDistance){
     background(0, 255, 0);
    else if ((keyPressed == true && key == 'p' || key == 'P') && mousePressed == true && distanceOriginMouse() > 0.5 * deadlyDistance){

  //draw gun when p is pressed
  if (keyPressed == true && key == 'p' || key == 'P') {
    line(0, 0, 40, 0);

  //draw deadly
  ellipse(0,0,deadlyDistance, deadlyDistance); 

  //Draw Hare1;


  ellipse(xPosHunter1, yPosHunter1, radHunter, radHunter);
  ellipse(xPosHunter2, yPosHunter2, radHunter, radHunter);
  //if (mousePressed == true && mouseButton == LEFT && mouseX >=) {

The picture is 16 x 16 pixels, so that probably causes the pixelyness, but if I take a larger picture, processing won't show the entire picture anymore.

Hope you guys can help out!



  • Answer ✓

    you need to post the image you are using, or link to it.

  • I am no longer in need of the answer to this question.

    Thanks for the effort however!

    Best wishes

Sign In or Register to comment.