Warning: session_start(): open(/var/lib/php/sessions/sess_698nb94rm7amp1rb5fv52o2jpk, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
module ShowRandomColor > DynModule {
RGB color;
S myGuess, yourName;
transient JPanel colorPanel;
transient JTextField tfYourName;
visualize {
if (color == null) setField(color := makeRandomColor());
JComponent theForm = withRightMargin(makeForm2(
"I call this color:", dm_fieldLabel('myGuess),
"How do you call this color?", centerAndEastWithMargin(
onEnter(tfYourName = selectAllOnFocus(dm_fieldTextField('yourName)), rThread saveName),
jbutton("Save", rThread saveName))));
ret withRightAlignedButtons(
centerAndSouthWithMargin(
northAndCenterWithMargins(
jRightAlignedLiveValueLabel(mapLiveValue(func(O color) -> S { "Color Code: #" + color }, S, dm_fieldLiveValue('color))),
jSection("THE COLOR", colorPanel = singleColorPanel(toColor(color)))),
jPreferredSizeToMinSizePlusY(5, theForm)),
"New Color", rThread newColor);
}
void newColor enter {
setField(color := makeRandomColor());
setField(myGuess := or((S) dm_callModule(dm_colorNamesModule(), 'getClosestColorName, color.getColor()), "no idea"));
setField(yourName := myGuess);
changeSingleColorPanel(colorPanel, color.getColor());
selectAll(tfYourName);
}
void saveName enter {
setField(yourName := trim(yourName));
if (empty(yourName)) ret;
if (eqic(myGuess, yourName))
infoBox("Got that one right!");
else
infoBox(quote(yourName) + "... I see.");
dm_callModule(dm_colorNamesModule(), 'addColorName, color.getColor(), yourName, "");
newColor();
}
RGB makeRandomColor() {
ret randomHSBColor();
}
}