3
$\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$
1

1 Answer 1

4
$\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$
2
  • $\begingroup$ Can you please tell where I am going wrong in my code? why it is executing again and again? $\endgroup$ Commented Nov 2, 2018 at 19:40
  • 1
    $\begingroup$ @SurbhiGrover, your code works fine in version 9 (windows 10) and version 11.3 (wolfram cloud). $\endgroup$
    – kglr
    Commented Nov 2, 2018 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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