restart: with(Maplets): with(Maplets[Elements]): s_info:="Color Exchanger is a simple example": s_0:=" ": PicPoints:=op([1,1],plot(sin,-2*Pi..2*Pi)): F_Color:=COLOR(RGB,1,0,0): B_Color:=COLOR(RGB,0.5,0.6,0.7): Pic:=PLOT(CURVES(PicPoints,F_Color,THICKNESS(2)),AXESSTYLE(NONE)): ConvertToCOLOR:=proc(s) local ns: ns:=substring(s,2..-1): map2(substring,ns,[1..2,3..4,5..6]); map(convert,%,decimal,hex)/255; COLOR(RGB,op(%)); end proc: Select:=proc() local r: Display( Maplet( ColorDialog[CD]( onapprove = Shutdown([CD]), oncancel = Shutdown() ) ) ): op(%): end proc: SetColor:=proc() local c: global Pic,F_Color,B_Color: c:=Select(); if Maplets:-Tools:-Get(RBMI_F) then F_Color:=ConvertToCOLOR(c): Maplets:-Tools:-Set(L_BF(foreground)=F_Color): Pic:=PLOT(CURVES(PicPoints,F_Color,THICKNESS(2)),AXESSTYLE(NONE)) else B_Color:=c: Maplets:-Tools:-Set(L_BF(foreground)=B_Color): Maplets:-Tools:-Set(P(background)=c): end if: Maplets:-Tools:-Set(P(value)=Pic): end proc: ChangeF:=proc() Maplets:-Tools:-Set(L_BF(caption)="Foreground",L_BF(foreground)=F_Color) end proc: ChangeB:=proc() Maplets:-Tools:-Set(L_BF(caption)="Background",L_BF(foreground)=B_Color) end proc: ChangeI:=proc() `if`(Maplets:-Tools:-Get(CBMI),s_info,s_0): Maplets:-Tools:-Set(L_Info(caption)=%): end proc: M:=Maplet( Window(title="Color Exchanger", menubar=MB, layout=BoxLayout( BoxColumn(border=true,caption="Plotter", BoxRow(border=true,inset=0, BoxCell(Label[L_Info](s_info)) ), BoxCell( Plotter[P]( width=200,height=200,background=B_Color,value=Pic) ), BoxRow(border=true, BoxCell(Label[L_BF]( "Background",foreground=B_Color,font=Font("courier",bold,12)),halign=right), BoxCell(Button("Set Color",onclick=A_SetColor)) ) ) ) ), Action[A_SetColor](Evaluate(function=SetColor)), MenuBar[MB]( Menu("&File", CheckBoxMenuItem[CBMI](value=true,"&Info",onclick=A_Info), MenuSeparator(), MenuItem("&Close",Shutdown())), Menu("&Edit", RadioButtonMenuItem[RBMI_F]( value=false,"&Foreground",group=BG,onclick=A_F), RadioButtonMenuItem[RBMI_B]( value=true, "&Background",group=BG,onclick=A_B) ) ), Action[A_Info](Evaluate(function=ChangeI)), Action[A_F](Evaluate(function=ChangeF)), Action[A_B](Evaluate(function=ChangeB)), ButtonGroup[BG]() ): Display(M);