Problems with plotting multiple objects over each other

5 views (last 30 days)
I'm using the rectangle function to fill in a circle located at the center point (x,y) of a grid square and width and weigth (1,1) with curvature (1,1)...in other words a circle that touches the bounds of a grid square. This happens whenever I left click on the plot. I want to be able to right click in a grid square a have the filled in circle erase. For some reason Matlab won't overlay rectangles with the same center point. I was hoping to use the rectangle function again but with a black color (since my background is black). Once I get this part working, I want to extend it to replace any circle I click on with another circle of a different color I've picked already. Is there work around that I could use?
  2 Comments
Harold
Harold on 22 Mar 2013
What I mean is I want to be able to delete the filled circle when I right click on it or if I left click on it with a different color selected. For example, in the picture here http://i50.tinypic.com/23if88j.jpg I first selected the blue color and left clicked on the grid squares. I then change to the red color and click on the grid squares. That blue circle should of been replaced with a red circle when I left clicked on it. I have the same problem when I try to right click on the circle. When I right click within the bounds of a grid square, the circle should be replaced with a circle colored in black (essentially erasing that circle from the board).

Sign in to comment.

Answers (2)

Wouter
Wouter on 21 Mar 2013
You could try to edit the renderer of the figure window:
set(gcf,'renderer','opengl') % changes the renderer of the current fig to opengl
set(gcf,'renderer','painters') %changes the renderer to painters
set(gcf,'renderer','zbuffer') %changes the renderer to buffer
A different renderer might be able to get rid of your visualisation problems.
  1 Comment
Harold
Harold on 22 Mar 2013
Wouter,
Unfortunately editing the renderer did not work.

Sign in to comment.


Image Analyst
Image Analyst on 22 Mar 2013
When you call rectangle, store the handle of it in a 6 by 6 array at the location of the circle in the grid. Then when you have to change the color, delete the handle before drawing the new one.
% Draw.
handleArray(row, column) = rectangle(.....
When it comes time to draw a new circle of a different color:
% Erase that handle to clear the circle.
delete(handleArray(row, column));
% Draw new circle at that location.
handleArray(row, column) = rectangle(.....
  2 Comments
Harold
Harold on 24 Mar 2013
No other suggestions? If you would like here is the fully developed code as of thus far. Flow_FreeGUI is the main program that you should run.

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!