Latest version | 0.1 |
---|---|
Minimum Core | 9 |
Compatible Core | 9 |
Last updated | 2 years ago |
Created | 2 years ago |
Authors | |
Languages |
English |
Systems | All systems |
Project source | Project URL |
Read-me | Readme URL |
This is a fork of jscolor for use as a library for Foundry VTT modules. For further info about features and licensing, see the jscolor website.
jsColor for Foundry VTT is a customisable color picker with a built-in opacity (alpha) slider.
As with FoundryVTT's ClientSettings.register function, use the JsColor.register(module, key, {settingOptions}, {pickerOptions})
function to register a new color picker setting for a module. module
is the ID of the module, key
is the name of the setting, {settingOptions}
is a comma-separated list of options related to the ClientSettings.register
function (see Setting Options) and {pickerOptions}
is a comma-separated list of options for the picker (see Picker Options).
The name of the setting for end users.
Example: name: 'Background Color'
The description of the registered setting and its behavior.
Example: hint: 'Set the background color'
The default color value, e.g., '#FF0000FF'
for opaque red. If unset, the default is '#FFFFFFFF'
.
Example: default: '#FF0000FF'
The scope of the setting:
Example: scope: 'world'
Whether to display the setting in the configuration view. If set to false
, the color picker will not be available. Default is true
.
Example: config: false
JsColor.register(
'my-module',
'background-color',
{
name: 'Background Color',
hint: 'Set the background color'
scope: 'world',
config: true
},
{
format: 'hexa',
alphaChannel: true
}
)
<input type="text" data-jscolor="{pickerOptions}" value="">
pickerOptions
is a list of comma-separated options in the format: option: value
. See "Picker Options" for a list of optionstype
does not need to be defined, but Foundry VTT will automatically format the element if it is included.JsColor.install()
to your script after the template is rendered.The initial alpha (opacity) value.
Example: alpha: 0.5
Whether the alpha (opacity) channel is enabled and the alpha slider is visible. The default is auto
.
Example: alphaChannel: true
The DOM element that will be used to edit and display the alpha value (opacity).
The background color of the color picker (in CSS color notation). Default is 'rgba(255, 255, 255, 1)'
.
Example: backgroundColor: 'rgba(218, 216, 204, 1
The border color of the color picker (in CSS color notation). Default is 'rgba(187, 187, 187 ,1)'
.
Example: borderColor: 'rgba(122, 121, 113, 1)'
The border radius of the color picker (in pixels). Default is 5
.
Example: borderRadius: 10
The border width of the color pickeer (in pixels). Default is 1
.
Example: borderWidth: 2
The text and border color of the Close button (in CSS notation). Default is 'rgba(0, 0, 0, 1)'
Example: buttonColor: 'rgba(0, 0, 0, 1)'
The height of the Close button (in pixels). Default is 18
.
Example: buttonHeight: 25
Whether the Close button is displayed. Default is false
.
Example: closeButton: true
The text of the Close button. Default is Close
.
Example: closeText: 'Exit'
The border color of the color picker's controls (in CSS color notation). Default is 'rgba(187, 187, 187, 1)'
.
Example: controlBorderColor: 'rgba(122, 121, 113, 1)'
The border width of the color picker's controls (in pixels). Default is 1
.
Example: controlBorderWidth: 2
The size of the crosshair cursor (in pixels). Default is 8
.
Whether to overwrite the CSS style of the previewElement using the !important flag. Default is true
.
Example: forceStyle: false
The format of the displayed color value.
Example: format: 'hexa'
Whether the valueElement should be prefixed with #. Default is true
Example: hash: false
The height of the color spectrum area (in pixels). Default is 101
.
Example: height: 200
Whether to hide the color picker when clicking away from the target element. Default is true
.
Example: hideOnleave: false
Whether to hide the color picker when clicking the palette. Default is false
.
Example: hideOnPaletteClick: true
The layout of the color picker controls. Default is HSV
.
Example: mode: 'HVS'
A callback function called when the color is changed.
A callback function called repeatedly as the color is changed.
The padding of the color picker (in pixels). Default is 12
Example: padding: 5
The colors to be displayed in the palette (in array or space-separated string notation).
Array notation example: palette: ['#ffe438', '#88dd20', 'rgba(0,154,255,0.6)', 'rgba(187,0,255,0.3)']
String notation example: palette: '#ffe438 #88dd20 rgba(0,154,255,0.6) rgba(187,0,255,0.3)'
The number of columns in the palette. Default is 10
.
Example: paletteCols: 5
The maximum height of a row in the palette (in pixels). Default is 16
.
Example: paletteHeight: 10
Whether the palette colors will set alpha. Default is auto
.
Example: paletteSetsAlpha: true
The distance between color samples in the palette. Default is 4
.
Example: paletteSpacing: 2
The border color of the pointers inside the color picker's controls (in CSS color notation). Default is 'rgba(255, 255, 255, 1)'
Example: pointerBorderColor: 'rgba(0, 14, 238, 1)'
The border width of the pointers inside the color picker's controls. Default is 1
.
Example: pointerBorderColor: 2
The color of the pointers iside the color picker's controls (in CCS color notation). Default is 'rgba(76,76,76,1)'
.
The thickness of the pointers inside the color picker's controls (in pixels). Default is 2
Example: pointerThickness: 1
The position of the color pickeer relative to the target element. Default is: 'bottom'
.
Available values:
Example: position: 'right'
The DOM element that will contain a preview of the picked color using CSS background image. Default is targetElement
.
The space between the color preview image and content of the previewElement
(in pixels). Default is 8
.
Example: previewPadding: 20
The position of the color preview image in the previewElement
. Default is 'left'
.
Available values:
Example: previewPosition: 'right'
The width of the color preview image in the previewElement
(in pixels). Default is 32
Example: previewSize: 50
Whether to generate a random initial color. Default is false
.
Example: random: false
Whether the valueElement
must always contain a color value. Default is true
.
Example: required: false
Whether to display a shadow behind the color picker. Default is true
.
Example: shadow: false
The blur radius of the color picker's shadow (in pixels). Default is 15
.
Example: shadowBlur: 5
The color of the color picker's shadow (in CSS color notation). Default is 'rgba(0,0,0,0.2)'
.
Example: shadowColor: 'rgba(255, 0, 0 , 1)'
Whether to display the color picker on clicking the target element. Default is true
.
Example: showOnClick: false
The width of the sliders (in pixels). Default is 16
.
Example: sliderSize: 10
Whether to automatically move the position of the color picker when there is not enough space for it at the specified position
. Default is true
.
Example: smartPosition: false
Whether to display the hex color code in uppercase. Default is true
.
Example: uppercase: false
The initial color value in any support formatted. If not set, the value attribute of the valueElement
will be used.
Example: value: '#ffffffff'
The DOM element that will contain the color code. Default is the target element.
The width of the color spectrum area (in pixels). Default is 181
.
Example: width: 200
The z-index of the color picker box. Default is 5000
.
Example: zIndex: 1
To install this package, open your Foundry Setup screen and navigate to your Module tab and click the Install Module button.
From there, you can either search for the package unique name: jscolor or copy its manifest URL:
And paste it to the input box at the bottom of your window.
You can install this package directly to your Forge account.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Advertisement cookies are used to deliver visitors with customized advertisements based on the pages they visited before and analyze the effectiveness of the ad campaign.