5
$\begingroup$

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.

$\endgroup$
7
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ Is there documentation for FrontEndResource? In my version, 12.1, I can't find FrontEndResource even in Names["FrontEnd`*"] $\endgroup$
    – Adam
    Mar 23 at 2:23
  • 1
    $\begingroup$ No, it is not documented. $\endgroup$
    – ihojnicki
    Mar 23 at 2:39
  • 1
    $\begingroup$ @Adam, it is one of those undocumented internal functions. For related Q/As on this site, see, for example, Complete list of FrontEndResources. $\endgroup$
    – kglr
    Mar 23 at 2:50
5
$\begingroup$

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! :)

$\endgroup$
5
  • $\begingroup$ 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... :) $\endgroup$
    – thorimur
    Mar 23 at 2:03
  • $\begingroup$ I've never gone spelunking in /opt/Mathematica before, thank you for the intro! (unix master race) $\endgroup$
    – Adam
    Mar 23 at 3:03
  • $\begingroup$ Ah, is it under /opt for you? (Are you on Linux?) For me it's literally inside the application itself! $\endgroup$
    – thorimur
    Mar 23 at 3:08
  • $\begingroup$ 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. $\endgroup$
    – Adam
    Mar 23 at 3:16
  • 1
    $\begingroup$ Oh, not the toolbar! (That would really be something!) I mean I navigate to Mathematica.app, then "show package contents". Ah, very nice! $\endgroup$
    – thorimur
    Mar 23 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.