2
$\begingroup$

I'm trying to make this manipulation. Initially, I use Text to add Happy Wedding. However, the function doesn't allow me to format the font, color, etc. So I changed it and used PlotLabel. The problem is that the label position is moving with time. How can I fix its position on the top?

Manipulate[
 If[n =!= nold, vHues = Table[rhue[0.2, -0.15], {n}]; 
  mPositions = RandomReal[NormalDistribution[0, 1], {n, 2}]; 
  vSizes = RandomReal[{0, 1}, {n}]; nold = n]; 
   Graphics[{Thickness[t], 
   Table[{vHues[[i]], hea[mPositions[[i]]*s, vSizes[[i]]^e]}, {i, n}]},
  PlotLabel -> 
   Style["Happy Wedding", 40, Hue[0.5/6], FontFamily -> "Mistral", 
    Background -> White],
   ImageSize -> {350, 350}], {{s, 1, "separation"}, 0.1, 2, 
  ControlType -> Animator}, {{e, 0.5, "size variation"}, 0.05, 2, 
  ControlType -> Animator}, 
  {{n, 10, "number"}, 1, 20, 1, 
  ControlType -> Animator}, {{t, 0.001, "thickness"}, 0.00001, 0.03, 
  ControlType -> Animator}, TrackedSymbols -> True, 
 ControllerLinking -> True, 
  Initialization :> {nold = 10,
   hea[{x_, y_}, 
     s_] := {BezierCurve[{{0, 0}, {1, 1 + RandomReal[]*0.3}, {0.5, 
         1.3 + RandomReal[]*0.3}, {0, 1}}], 
      BezierCurve[{{0, 0}, {-1, 1}, {-0.5 - (Plus[RandomReal[]])*0.3, 
         1.3}, {0, 1}}]} /. 
          {(x1_)?NumericQ, (y1_)?NumericQ} -> {x, y} + s*{x1, y1}}]
$\endgroup$
11
  • $\begingroup$ "I use Text to add Happy Wedding. However, the function doesn't allow me to format the font, …" You can always use Style. $\endgroup$
    – xzczd
    Nov 7, 2019 at 6:36
  • $\begingroup$ I tried but it doesn't work. Maybe I missed something? $\endgroup$
    – emnha
    Nov 7, 2019 at 6:37
  • $\begingroup$ I mean you can adjust font, etc. of Text with Style, check document of Style for more information, an example can also be found in the Properties & Relations section of document of Text. $\endgroup$
    – xzczd
    Nov 7, 2019 at 6:46
  • $\begingroup$ @xzczd okay I see but I just tried and the problem is that the text is moving. $\endgroup$
    – emnha
    Nov 7, 2019 at 6:53
  • 2
    $\begingroup$ add the option PlotRange -> {{-5, 5}, {-5, 5}}? $\endgroup$
    – kglr
    Nov 7, 2019 at 6:53

1 Answer 1

3
$\begingroup$

Replace Graphics[...] with

Labeled[Graphics[{Thickness[t], 
    Table[{vHues[[i]], hea[mPositions[[i]]*s, vSizes[[i]]^e]}, {i, n}]}, 
   ImageSize -> {350, 350}], 
 Style["Happy Wedding", 40, Hue[0.5/6], FontFamily -> "Mistral", Background -> White], 
 Top]
$\endgroup$

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.