The Version 6 Front End

A simple presentation about a simple idea

John Fultz
User Interface Group
Wolfram Research

What if we had a kind of output that was always up-to-date?

var=2;

var

var=4;

Dynamic[var]

var=6;

var=Expand[(a+b)^3];

Updating even during evaluations

Dynamic[var]

Do[var=i,{i,1,2×(10^6)}]

Do[var=i; If[Mod[i,5×(10^5)]==0, Pause[2]], {i, 2×(10^6)}]

The consequence on side-effect graphics

Dynamic[var]

var=Graphics[{Red,Line[{{0,0},{1,1}}]},ImageSize->200]

var=Plot[Tan[x], {x, 0, 6π},ImageSize->200]

var=Plot3D[Sin[x y], {x, 0, 2π}, {y, 0, 2π},ImageSize->200]

Tracing the dependencies of a dynamic

function[x_]:=(x^2)+var1;
var1=3;
var2=-120;

Dynamic[function[5]]

var1=10;

function[x_]:=x!+var2

var2=0;

Regular evaluations evaluate at a certain time, but Dynamics evaluate in a certain space

var1=5;var2=3;var1+var2

var1+var2+Dynamic[var1+var2]

var1=100;var2=300;

var1=.;var2=.

var1=Plot[x, {x, 0, 1}];

Dynamics can go into anything that can turn directly into typesetting

size=12;color=Red;
Style["A New Kind of Science", "Title",FontSize->Dynamic[size], FontColor->Dynamic[color]]

size=24;

color=Blue;

var=2;
Plot3D[Sin[(E^(x y))], {x, 0, 3}, {y, 0, 3}, PlotPoints->Dynamic[var]]

Dynamic[Plot3D[Sin[(E^(x y))], {x, 0, 3}, {y, 0, 3}, PlotPoints->var]]

var=5;

var=Automatic;

A dynamic can represent a graphic in a graphic...

var=.;
Graphics[{
Thickness[0.1],Blue,
Polygon[{{.5,0},{1,.5},{.5,1},{0,.5}}],
Dynamic[var]}, PlotRange->{{0,1},{0,1}},ImageSize->Small]

var=Rectangle[{.2,.2},{.8,.8}];

var={Black,var};

...or a coordinate in a graphic...

{var1,var2}={0,0};
Graphics[{Red,PointSize[0.1], Point[Dynamic[{var1,var2}]]}, Axes->True, PlotRange->{{0,1},{0,1}},ImageSize->Small]

{var1,var2}={0.5,.75};

...and coordinates can change

{var1,var2}={0,0};
{Graphics[{Red,PointSize[0.1], Point[{var1,var2}]}, Axes->True, PlotRange->{{0,1},{0,1}}],Dynamic[{var1,var2}]}

{var1,var2}={0,0};
{Graphics[{Red,PointSize[0.1], Point[Dynamic[{var1,var2}]]}, Axes->True, PlotRange->{{0,1},{0,1}}],Dynamic[{var1,var2}]}

We just made a simple control

var1=0;var2=0;
{Slider2D[Dynamic[{var1,var2}]], Dynamic[{var1,var2}]}

var=0;
{Slider[Dynamic[var]], Dynamic[var]}

var=Null;
InputField[Dynamic[var]]

InputField[Dynamic[var],Appearance->"Frameless"]

var="";
InputField[Dynamic[var],String]

A few other controls that make dynamic sorts of changes (not a complete list)

var=True;
Checkbox[Dynamic[var]]

SetterBar[Dynamic[var], {True, False, x,y}]

Row[{RadioButton[Dynamic[var],True]," True\t", RadioButton[Dynamic[var], False], " False\t",
RadioButton[Dynamic[var], Plot[Sin[x], {x, 0, 6}]], Plot[Sin[x], {x, 0, 6}]}]

PopupMenu[Dynamic[var], {True,False,Plot[Sin[x], {x,0,6}],Plot3D[Sin[x y],{x,0,6},{y,0,6}]}]

How many can we have?

var=0;
Table[
Slider[
Dynamic[var],
ImageSize->Tiny],
{100}]

Is this for real?

Table[With[{i=i},
Slider[
Dynamic[Mod[var+i,1], (var=Mod[#-i,1])&],
{0,.999},ImageSize->Tiny]],
{i, 0, 1, .01}]

Constraining the movement of graphical elements

var1=0;
var2=-1;
dynamicCoordinate:=Dynamic[{var1, var2}, 
(var1=Max[Min[#[[1]],1],-1]; var2=-Sin[ArcCos[var1]])&];
Graphics[{
{Orange, Dashing[0.03], Circle[]},
Thickness[0.05],Line[{{0,0},dynamicCoordinate}],
Green,PointSize[0.1],Point[dynamicCoordinate]},
PlotRange->{{-1,1},{0,-2}}]

A new kind of control, just for graphics

Deploy[Graphics[{
{Orange, Dashing[0.03], Circle[]},
Thickness[0.05], Line[{{0,0}, Dynamic[{var1, var2}]}],
Green, PointSize[0.1], Point[Dynamic[{var1, var2}]],
Locator[dynamicCoordinate,None]},
PlotRange->{{-1,1},{0,-2}}]]

Some things which aren't necessarily Dynamic, or even new

var=1;
Panel[
Grid[{
{Tooltip[Button[Style["◀",FontColor->Dynamic[If[var>1,Black,Gray]]],var--,Enabled->Dynamic[var>1]],"Decrement 'var'"],
Tooltip[Button[Style["▶",FontColor->Dynamic[If[var<10,Black,Gray]]],var++,Enabled->Dynamic[var<10]], "Increment 'var'"]},
{Dynamic[Plot[Sin[var x], {x, 0, 2π},Background->White]], SpanFromLeft}},
ItemSize->{12,Automatic}],
ImageMargins->10
]

A very convenient way to visualize transformations of data

var=1.;
Panel[
Column[
{Slider[Dynamic[var],{1.,10.}],InputField[Dynamic[var],Number,FieldSize->{10,1}],
Dynamic[Plot[Sin[var x], {x,0,2π},Background->White]]}
], ImageMargins->10]

Yet a problem lurks...

r=0;
g=0;
b=0;
Panel[
Column[{
Row[{Slider[Dynamic[r]], " Red"}],
Row[{Slider[Dynamic[g]], " Blue"}],
Row[{Slider[Dynamic[b]], " Green"}],
Row[{Graphics[{Dynamic[RGBColor[r,g,b]],Rectangle[]},ImageSize->50],Dynamic[RGBColor[r,g,b]]}]
}
]]

PopupMenu[Dynamic[g], {"Milky Way", "Andromeda", "LMC"}]

Maybe Module will help with namespace conflicts

Module[{r=0,g=0,b=0},
Panel[
Column[{
Row[{Slider[Dynamic[r]], " Red"}],
Row[{Slider[Dynamic[g]], " Blue"}],
Row[{Slider[Dynamic[b]], " Green"}],
Row[{Graphics[{Dynamic[RGBColor[r,g,b]],Rectangle[]},ImageSize->50],Dynamic[RGBColor[r,g,b]]}]
}
]]]

Module[{g},PopupMenu[Dynamic[g], {"Milky Way", "Andromeda", "LMC"}]]

But what happens when you copy/paste?

Module[{r=0,g=0,b=0},
Panel[
Column[{
Row[{Slider[Dynamic[r]], " Red"}],
Row[{Slider[Dynamic[g]], " Blue"}],
Row[{Slider[Dynamic[b]], " Green"}],
Row[{Graphics[{Dynamic[RGBColor[r,g,b]],Rectangle[]},ImageSize->50],Dynamic[RGBColor[r,g,b]]}]
}
]]]

Worse, what happens when you quit the kernel?

Quit

2+2

One mechanism that localizes and persists

DynamicModule[{r=0,g=0,b=0},
Panel[
Column[{
Row[{Slider[Dynamic[r]], " Red"}],
Row[{Slider[Dynamic[g]], " Blue"}],
Row[{Slider[Dynamic[b]], " Green"}],
Row[{Graphics[{Dynamic[RGBColor[r,g,b]],Rectangle[]},ImageSize->50],Dynamic[RGBColor[r,g,b]]}]
}
]]]

Quit

2+2

What have we now wrought?

Syntactic sugar makes the medicine go down

Manipulate[Plot[Sin[n x], {x,0,2π}],{n,1,10},SynchronousUpdating->True]

Manipulate[Graphics[{RGBColor[r,g,b],Rectangle[]},ImageSize->50],{{r,0,"Red"},0,1},{{g,0,"Green"},0,1},{{b,0,"Blue"},0,1}]

Manipulate[Graphics3D[{{Opacity[s],Sphere[{0,0,0},1]},{Opacity[c],Cylinder[{{-1,-1,-1},{1,1,1}},.7]}},ImageSize->Small], {{s,1,"Sphere"}, 0, 1},{{c,1,"Cylinder"},0,1}]

Manipulate[Expand[(((a+b))^n)],{n,1,100,1}]

Manipulate[Graphics[GeometricTransformation[First[ArrayPlot[CellularAutomaton[30,{{1},0},20]]],{{a,b},{c,d}}],PlotLabel->NumberForm[MatrixForm[{{a,b},{c,d}}],2]],{{a,1},-2,2},{{b,0},-2,2},{{c,0},-2,2},{{d,1},-2,2}]

Manipulate[Graphics[{EdgeForm[{AbsoluteThickness[2],Gray}],AbsoluteThickness[3],Table[Rectangle[{x+t Sin[4 Pi/8 y],y},{x+t Sin[4 Pi/8 y]+1,y+1}],{x,1,2 n-1,2},{y,0,m-1}],Gray,Line[Table[{{0,y},{2 n+1,y}},{y,0,m-1}]]},ImageSize->{{400},{250}}],{{t,0.4},-1,1},{{n,7},2,10,1},{{m,8},2,14,1}]

Needs["Graphics`Polyhedra`"]
Needs["Graphics`Shapes`"]
Manipulate[
ShrinkPolygons[OpenTruncate[Stellate[Polyhedron[shape],stellate],truncate],shrink],
{shape,Polyhedra},
{{stellate,1},0.1,2},
{{truncate,0},0,0.5},
{{shrink,1},0.1,2},
ControlPlacement->Bottom,FrameLabel->Style["Manipulate Polyhedra",FontSize->18]]

The new Complete Characters palette

The Preferences dialog

The Golden Spiral

Front end-based debugger

Fully functional debugger integrated into the FE using standard

Package editor

Open packages without mangling them or adding lots of garbage.  Move between the FE, a text editor, and WorkBench with ease.  Use the FE debugger on packages.

New 2D and 3D rendering features

Full support for transparency, specular lighting,

Interactive graphics

Interactive rotation of 3D graphics, and full editing an annotation of 2D graphics.

Size-limited output

Range[10^5]

New documentation system

Better support for topical navigation, uses a browser with a very web-like interface, and will support full-text searching