« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Gauges
Build Custom Meters
In[1]:=
X
Voltmeter[v_, opts___] := Graphics[{{(*case*){EdgeForm[{Thickness[.007], GrayLevel[0]}], GrayLevel[.2], Rectangle[{-1.2, -1.1}, {1.2, 1.3}, RoundingRadius -> .2]},(*case holes*){White, Disk[{-1, -.9}, .05], Disk[{1, -.9}, .05], Disk[{1, 1.1}, .05], Disk[{-1, 1.1}, .05]},(*case outer rim*){Black, Disk[{0, .1}, 1.15], GrayLevel[.5], Disk[{-.02, .12}, 1.13], GrayLevel[.2], Disk[{0, .1}, 1.11]},(*face highlight*) EdgeForm[{CapForm["Round"], Thickness[.02], Hue[.125, .7, .6]}], Hue[.125, 1, 1], Disk[{.02, .1}, 1, {1.1 Pi, -.1 Pi}],(*face shadow*){EdgeForm[{CapForm["Round"], Thickness[.01], Hue[.125, 1, 1]}], Hue[.125, 1, 1], Disk[{-.02, .12}, 1, {1.1 Pi, -.1 Pi}]},(*face*){EdgeForm[], Hue[.125, .5, 1], Rotate[Polygon[({.1, -.04} + # &) /@ Flatten[{{{0, 0}, {0, 1}}, Array[{Sin[2 Pi*(#/50)], Cos[2 Pi*(#/50)]} &, 30]}, 1], VertexColors -> Flatten[{Hue[.125, 0, 1], Array[Hue[.125, .5, 1] &, 50 + 1]}]], 30/50 Pi, {0, 0}]},(*case mid line highlight*){Hue[.125, .7, .6], Thickness[.025], CapForm["Round"], Line[{{-.95, -.2}, {0, .1}, {.95, -.2}}]},(*case mid disk \ highlight*){Hue[.125, .7, .6], Disk[{0, 0}, .25, {.95 Pi, .05 Pi}]}}, Inset[ AngularGauge[v, {0, 100}, GaugeFaceStyle -> None, GaugeFrameStyle -> None, GaugeMarkers -> Graphics[{Hue[0, 1, .7], Polygon[{{.1, .03}, {.1, -.03}, {.95, -.03}, {1, 0}, {.95, .03}}]}], GaugeLabels -> {Placed[ Style["VOLTS", FontFamily -> "Helvetica", Bold, FontSize -> Scaled[.08], White], {.5, .35}]}, LabelStyle -> Directive[FontFamily -> "Helvetica", FontSize -> Scaled[.06]], ScaleOrigin -> {{.85 Pi, .15 Pi}, .9}, ScaleDivisions -> {2, 10}, ScaleRanges -> {{Scaled[.75], Scaled[1]}}, ScaleRangeStyle -> Hue[0, 1, .7, .7], AxesStyle -> Opacity[0], TicksStyle -> {Thickness[.01], Thickness[.005]}, ImageSize -> Automatic, ImagePadding -> None], {0, 0}, {0, 0}, {1.75, Automatic}], {(*case mid disk*)GrayLevel[.2], Disk[{0, 0}, .2], GrayLevel[0], Disk[{0, 0}, .075], Disk[{-.85, -.4}, .05], Disk[{.85, -.4}, .05]}}, PlotRangeClipping -> True, opts];
Create custom meters by combining gauges and graphics.
In[2]:=
X
Grid[Partition[Table[Voltmeter[v], {v, 10, 90, 10}], 3]]
Out[2]=