Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LukeFinch/bc5ca845e68aed9a120adf0cef65c72c to your computer and use it in GitHub Desktop.
Save LukeFinch/bc5ca845e68aed9a120adf0cef65c72c to your computer and use it in GitHub Desktop.
const developerColorNames = [
"shadowColor",
"labelColor",
"secondaryLabelColor",
"tertiaryLabelColor",
"quaternaryLabelColor",
"systemRedColor",
"systemGreenColor",
"systemBlueColor",
"systemOrangeColor",
"systemYellowColor",
"systemBrownColor",
"systemPinkColor",
"systemPurpleColor",
"systemTealColor",
"systemIndigoColor",
"systemGrayColor",
"linkColor",
"placeholderTextColor",
"windowFrameTextColor",
"selectedMenuItemTextColor",
"alternateSelectedControlTextColor",
"headerTextColor",
"separatorColor",
"gridColor",
"textColor",
"textBackgroundColor",
"selectedTextColor",
"selectedTextBackgroundColor",
"unemphasizedSelectedTextBackgroundColor",
"unemphasizedSelectedTextColor",
"windowBackgroundColor",
"underPageBackgroundColor",
"controlBackgroundColor",
"selectedContentBackgroundColor",
"unemphasizedSelectedContentBackgroundColor",
"alternatingContentBackgroundColor",
"findHighlightColor",
"controlColor",
"controlTextColor",
"selectedControlColor",
"selectedControlTextColor",
"disabledControlTextColor",
"keyboardFocusIndicatorColor",
"controlAccentColor",
"selectedInactiveColor",
"textSpellingIndicatorColor",
"textGrammarIndicatorColor",
"thinSplitViewDividerColor",
"contentBackgroundColor",
"alternateSelectedControlColor",
"secondarySelectedControlColor",
"quarternaryLabelColor",
"selectedMenuItemColor",
"headerColor",
"controlHighlightColor",
"controlLightHighlightColor",
"scrollBarColor",
"controlShadowColor",
"blueControlTintColor",
"graphiteControlTintColor",
"clearControlTintColor",
"blackDeviceColor",
"lightGrayDeviceColor",
"whiteDeviceColor",
"grayDeviceColor",
"sourceListBackgroundColor",
"controlDarkShadowColor",
"toolTipColor",
"toolTipTextColor",
"selectedKnobColor",
"selectedHeaderTextColor",
"alternateSelectionBlueColor",
"alternateSelectionGraphiteColor",
"springLoadedOverlayColor",
"selectedContentTextColor",
"textCorrectionIndicatorColor",
"graphiteSelectedTextBackgroundColor",
"detailAccentColor",
"controlAccentRedColor",
"controlAccentOrangeColor",
"controlAccentYellowColor",
"controlAccentGreenColor",
"controlAccentBlueColor",
"controlAccentPurpleColor",
"controlAccentPinkColor",
"controlAccentSpaceGrayColor",
"controlAccentGoldColor",
"controlAccentRoseGoldColor",
"controlAccentSilverColor",
"controlAccentNoColor",
"highlightedMenuColor",
"highlightedMenuTextColor",
"enabledTextColor",
"disabledTextColor",
"controlAlternatingRowColor",
"panelBackgroundColor",
"panelSeparatorColor",
"tabSelectedBackgroundColor",
"panelHeaderLabelColor",
"panelHeaderDisabledBackgroundColor",
"panelTabBarButtonColor",
"panelTabBarButtonSelectedColor",
"panelTabBarButtonBorderColor",
"panelButtonColor",
"panelButtonLabelColor",
"panelButtonSelectedLabelColor",
"panelTextFieldBackgroundColor",
"panelTextFieldBorderColor"
]
unique = developerColorNames.sort().filter((item, index) => developerColorNames.indexOf(item) === index);
function updateDevColors(){
developerColors = unique.map(colorKey => {
c = NSColor[colorKey]().colorUsingColorSpaceName('NSDeviceRGBColorSpace')
let value = `rgba(${Math.round(c.redComponent()*255)},${Math.round(c.greenComponent()*255)},${Math.round(c.blueComponent()*255)},${Math.round(c.alphaComponent()*100)/100})`
let color = NSColor[colorKey]().colorUsingColorSpaceName('NSDeviceRGBColorSpace').CGColor()
let rObj = {}
rObj['name'] = colorKey
rObj['color'] = MSColor.colorWithHex_alpha(c.hexValue(),c.alphaComponent())
return MSColorAsset.alloc().initWithAsset_name(rObj.color, rObj.name)
})
}
updateDevColors()
var doc = context.document
var assets = doc.documentData().assets()
doc.documentData().assets().colorAssets = []
assets.addColorAssets(developerColors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment