5

Slider2D@{.5,.5} makes a draggable orange point with gray lines in a square.

slider2d

I want to use that dot in my plots. I also want to use that color and thickness of gray line. I could extract all of this information approximately from the image. But I think there's a way to get the pieces used to construct that object in a way analagous to FullForm@Slider2D@{.5,.5} (this code of course does not yield a list of lines, other graphics primitives etc.). Perhaps the solution involves FullGraphics or AbsoluteOptions or AbsoluteCurrentValue.

Adam
  • 3,937
  • 6
  • 22

2 Answers2

7

The orange png image used as slider thumb:

slider2dThumb = Import["C:\\Program Files\\Wolfram Research\\Mathematica\\11.3\\SystemFiles\\FrontEnd\\SystemResources\\\
Bitmaps\\Typeset\\Slider2D\\ThumbLarge.png"] 

enter image description here

GrayLevel graphics objects:

FrontEndResource["SliderThumb2D"] // Short

enter image description here

RawBoxes /@ {FrontEndResource["SliderThumb2D"], 
  FrontEndResource["SliderBackground2D"], 
  FrontEndResource["SliderBar2DHorizontal"], 
  FrontEndResource["SliderBar2DVertical"]}

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
5

I don't think this is actually made with Wolfram graphics primitives, but you can still find the image it uses! Open the application package and navigate to Contents > SystemFiles > FrontEnd > SystemResources > Bitmaps > Typeset > Slider2D. (That's where the orange disk is on a Mac, anyway.) You have a choice of different sizes.

I found what might be the rest of the information in the file Contents > SystemFiles > FrontEnd > TextResources > Controls.tr. If you find Slider2D in that document, you can see that the resource SliderBar2DHorizontal, for example, is given as

GraphicsBox[{GrayLevel[0.65], AbsoluteThickness[1.5], 
  LineBox[{{0, 0}, {4, 0}}]}, PlotRange -> {{-0.25, 4.25}, {-0.3, 0.3}}]

GraphicsBox is a lower-level undocumented form of Graphics that represents graphics as an expression per se, so applying ToExpression or, to be more precise, RawBoxes, works.

Edit: Also see @klgr's answer for a demonstration of using FrontEndResource within Mathematica to get this information! :)

thorimur
  • 9,010
  • 18
  • 32
  • ah...klgr beat me by about 10 seconds, looks like! well, their answer is more comprehensive anyway, given that it employs FrontEndResource. Though, I suppose it doesn't mention the file Controls.tr, so I've at least contributed something... :) – thorimur Mar 23 '21 at 02:03
  • I've never gone spelunking in /opt/Mathematica before, thank you for the intro! (unix master race) – Adam Mar 23 '21 at 03:03
  • Ah, is it under /opt for you? (Are you on Linux?) For me it's literally inside the application itself! – thorimur Mar 23 '21 at 03:08
  • The Mac toolbar is full of surprises! I don't have Controls in my Notebook -- nice to have find / -name "Controls.tr" in a linux bash shell though. – Adam Mar 23 '21 at 03:16
  • 1
    Oh, not the toolbar! (That would really be something!) I mean I navigate to Mathematica.app, then "show package contents". Ah, very nice! – thorimur Mar 23 '21 at 03:17