Back to black?

edited November 2015 in Questions about Code

Okay, so I am completely new to Processing and I am trying to get the basics. I am trying to build an arduino printer that uses data sent by Processing over serial to draw a bitmap on a wall, but that is way too ambitious for where I am right now.

I figured I wanted to have a bitmap with an alpha of 50 per cent that brightens up when you go over it with your mouse. So I took the pointillism sketch and manipulated it a bit. But somehow I cannot get a color value using get() and all pixels turn out black. What am I missing here?

(I was using a picture of "Girl with a pearl earring" by Johannes Vermeer for this)

        PImage img;

        void setup()

        {

          img = loadImage("parel.jpg");

          size(182,262);

          tint (255,127);

          image (img,0,0);

        }


        void draw()

        { 

          color pix = img.get(mouseX, mouseY);

          fill(pix);

          point(mouseX, mouseY);

        }

Answers

  • Try adding img.loadPixels() to the sketch (I think it'll work if you put it in setup()). Also I believe point() doesn't use fill() but stroke().

  • Yes! It was stroke()! Thanks a million!

Sign In or Register to comment.