- float boxSize = 100;
- float boxX, boxY;
- void setup(){
- size(640,480);
- boxX = width/2;
- boxY = height/2;
- rectMode(RADIUS);
- }
- void draw(){
- background(255);
- //make sure all shapes are "transparent"
- noFill();
-
- //draw mouse circle
- ellipseMode(CENTER);
- ellipse(mouseX, mouseY, 30,30);
-
- //test if mouse is in box's area
- //ideas and code taken from:
- //http://www.processing.org/learning/basics/mousefunctions.html
- if(mouseX>boxX-boxSize && mouseX<boxX+boxSize &&
- mouseY>boxY-boxSize && mouseY<boxY+boxSize){
- fill(200, 200);
- //println("in area");
- }else{
- ;
- }
-
- //create box "safe" area in center and dividing lines
- //USE QUADS, I.E. PRISMS
- rect(boxX, boxY, boxSize, boxSize);
- //line(0, 0, width, height); //top left to bottom right
- //line(0, height, width, 0); //bottom left to top right
-
- noFill();
- //top
-
- quad(0.0,0.0, float(width),0.0, width/2+boxSize, height/2-boxSize, width/2-boxSize, height/2-boxSize);
- //bottom
- quad(float(width),float(height), 0.0,float(height), width/2-boxSize, height/2+boxSize, width/2+boxSize, height/2+boxSize);
- //left
- quad(0.0,0.0, 0.0,float(height), width/2-boxSize, height/2+boxSize, width/2-boxSize, height/2-boxSize);
- //right
- quad(float(width),0.0, float(width),float(height), width/2+boxSize, height/2+boxSize, width/2+boxSize, height/2-boxSize);
- }
This is the current code, it's still a work in progress.
It depicts a square surrounded by the 4 prisms.
I understand what yove told me, but I would like to keep the prisms with noFill() until the mouse is over that prism.