# Using CloudDeploy to build a website for diagrams for Physics/Math teachers

I create a lot of diagrams in Mathematica like the one below for my physics and math study guides.

What I'd like to do is create a website where teachers could rapidly customize images like this and download them to use in their own study guides.

Can anyone with experience using CloudDeploy in Mathematica talk about the benefits and pitfalls of using the Wolfram Cloud to help create a website? Is it worth it? Are there better options?

Edit: Sample code was requested (out of curiosity?).

StandardFont = "Comic Sans MS"

Wheel[] := {Disk[{0, 0}, 5/8], Gray, Disk[{0, 0}, 5*8.5/100]}

Wheel[x_] := Translate[Wheel[], {x, 0}]

TrainShape[] := Rectangle[{0, 0}, {5, 5/2}]

TrainCar[] := {{Opacity[0.5], Blue, EdgeForm[Thick], TrainShape[]}, Wheel[51/8], Wheel[5 7/8]}

TrainCar[x_] := Translate[TrainCar[], {x, 0}]

ToMass[m_] := ToString[m] <> " kg"

Default[MassLabel, 3] := 40;
MassLabel[m_, x_, f_.] :=
Style[Text[ToMass[m], {x + 2.5, 1.5}], f, Bold, FontFamily -> StandardFont]

WeightShape[] := Rectangle[{0, 0}, {5/2, 5}]

Weight[] := {Opacity[0.5], Blue, EdgeForm[Thick], WeightShape[]}

Weight[x_] := Translate[Weight[], x]

Pulley[] := {{Gray, Disk[]}, Disk[{0, 0}, 1/8]}

Pulley[x_] := Translate[Pulley[], x]

Diagram[m1_, m2_] :=
Graphics[{TrainCar[0], MassLabel[m1, 0], Weight[{15, -10}],
Pulley[{15.25, 1/4}], Line[{{5, 5/4}, {15.25, 5/4}}],
Thick,
Circle[{15.25, 1/4}, 1, {0, \[Pi]/2}],
Line[{{16.25, 1/4}, {16.25, -5}}],
Translate[MassLabel[m2, 13.75], {0, -8.75}]}, ImageSize -> 700]

Diagram[4, 5]


Gives the following diagram.

Here is the link to the CloudDeploy of a FormFunction that generates a diagram, where you can change the mass values, and this is the code I used to generate it:

fofu = FormFunction[
{{"mass1", "First mass"} -> <|"Interpreter" -> "Number",
"Input" -> 6|>,
{"mass2", "Second mass"} -> <|"Interpreter" -> "Number",
"Input" -> 7|>
},
Function[
StandardFont = "Comic Sans MS";
TrainShape[] := Rectangle[{0, 0}, {5, 5/2}];
TrainCar[] := {{Opacity[0.5], Blue, EdgeForm[Thick],
TrainShape[]}};
TrainCar[x_] := Translate[TrainCar[], {x, 0}];
ToMass[m_] := ToString[m] <> " kg";
Default[MassLabel, 3] := 40;
MassLabel[m_, x_, f_.] :=
Style[Text[ToMass[m], {x + 2.5, 1.5}], f, Bold,
FontFamily -> StandardFont];
WeightShape[] := Rectangle[{0, 0}, {5/2, 5}];
Weight[] := {Opacity[0.5], Blue, EdgeForm[Thick], WeightShape[]};
Weight[x_] := Translate[Weight[], x];
Pulley[] := {{Gray, Disk[]}, Disk[{0, 0}, 1/8]};
Pulley[x_] := Translate[Pulley[], x];
Diagram[m1_, m2_] :=
Graphics[{TrainCar[0], MassLabel[m1, 0], Weight[{15, -10}],
Pulley[{15.25, 1/4}], Line[{{5, 5/4}, {15.25, 5/4}}], Thick,
Circle[{15.25, 1/4}, 1, {0, \[Pi]/2}],
Line[{{16.25, 1/4}, {16.25, -5}}],
Translate[MassLabel[m2, 13.75], {0, -8.75}]},
ImageSize -> 700]; Diagram[#mass1, #mass2]
], "GIF",
AppearanceRules -> <|
"Description" ->
"https://mathematica.stackexchange.com/questions/140876"|>
];
CloudDeploy[fofu, Permissions -> "Public"]


Hope that helps!

Jose