Message Boards Message Boards

1
|
4384 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Color palette for text?

Posted 3 years ago

Does anyone know how to build a color palette? To apply a color to a text, we must go to the Format, Text Color menu and click on the desired color. I would like to create a palette that would make this operation faster and more practical.

Good weekend.

POSTED BY: Sinval Santos
2 Replies
Posted 3 years ago

Thank you for your response and attention Gustavo.

POSTED BY: Sinval Santos

This is how I do it. First define this function to that you can apply or insert a color with a single button:

colorPasteButton = Button[" ",
    ib := InputNotebook[];
    If[NotebookRead[ib] === {}, Paste[ib, #], 
     FrontEndExecute[{FrontEndToken[ib, FontColor, #]}]],
    Appearance -> "Palette", Background -> #, ImageSize -> Full] &;

Then, create your palette in the notebook, for example:

Pane[
 Grid[
  {
   {Tooltip[colorPasteButton[Black], "Black 100%"],
    Tooltip[colorPasteButton[GrayLevel[0.15]], "Black 85%"],
    Tooltip[colorPasteButton[GrayLevel[0.50]], "Black 50%"],
    Tooltip[colorPasteButton[GrayLevel[0.75]], "Black 25%"],
    Tooltip[colorPasteButton[GrayLevel[0.85]], "Black 15%"]}
   },
  ItemSize -> {2, 1}, Alignment -> Left, Spacings -> {.1, 0}],
 FrameMargins -> 5] 

Then convert it to a palette:

CreatePalette[%]

And finally go to the Palettes menu, and select "Install palette".

If interested in learning more about the colorPasteButton see: https://mathematica.stackexchange.com/questions/95243/paste-set-color-with-a-single-button-for-palettes?form=MY01SV&OCID=MY01SV

POSTED BY: Gustavo Delfino
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract