3

I need to create a Manipulate that shows a circle or disk with a control to select whether it is Circle or Disk and sliders to set the {x,y} coordinates, radius and color (Hue).

My code is

type={"Disk","Circle"};

Manipulate[ip = Position[type,choose];
  If[ip == {{2}}, Show[Graphics[{Hue[a], Circle[{x, y}, r]}], 
    Axes->True, PlotRange -> {{-5,5}, {-5,5}}],
  If[ip == {{1}}, Show[Graphics[{Hue[a], Disk[{x, y}, r]}], 
    Axes -> True, PlotRange -> {{-5, 5}, {-5, 5}}], Print["No Plot"]]], 
 {choose, type, ControlType -> PopupMenu}, 
 {a, -1, 1}, {x, -4, 5}, {y, -4, 5}, {r, 1, 5}]

However, on selecting circle it keeps on loading again and again. I am not able to find the error. What is wrong with this code.

kglr
  • 394,356
  • 18
  • 477
  • 896

1 Answers1

4

A streamlined version of your code:

Manipulate[Graphics[{Hue[a], choose[{x, y}, r]}, Axes -> True, 
    PlotRange -> {{-5, 5}, {-5, 5}}], 
 {choose, {Disk, Circle}, ControlType -> PopupMenu},
 {a, -1, 1}, {x, -4, 5}, {y, -4, 5}, {r, 1, 5}]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896