2
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Can you please tell where I am going wrong in my code? why it is executing again and again? $\endgroup$ – Surbhi Grover Nov 2 '18 at 19:40
  • $\begingroup$ @SurbhiGrover, your code works fine in version 9 (windows 10) and version 11.3 (wolfram cloud). $\endgroup$ – kglr Nov 2 '18 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.