Class Shaders
java.lang.Object
uk.ac.starlink.ttools.plot.Shaders
Provides some implementations of the
Shader interface.
Many other lookup tables are available.
See for instance
http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml.
The utility class LutSteal is available to help turn these into
lut files that can be used here.
- Since:
- 5 Jun 2007
- Author:
- Mark Taylor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ShaderInterpolates between black (0) and white (1).static final ShaderColorBrewer diverging brown-blue-green shader.static final ShaderColorBrewer sequential blue-green shader.static final ShaderColorBrewer sequential blue-purple shader.static final ShaderColorBrewer sequential orange-red shader.static final ShaderColorBrewer diverging pink-green shader.static final ShaderColorBrewer sequential purple-blue shader.static final ShaderColorBrewer sequential purple-red shader.static final ShaderColorBrewer diverging red-blue shader.static final ShaderStandard cubehelix shader.static final ShaderEnhanced hue cubehelix shader.static final ShaderLurid cubehelix shader.static final ShaderInterpolates between cyan (0) and magenta (1).static final ShaderShader used by default for the transverse axis of non-absolute ramps.static final ShaderShader which interpolates between the base colour and black.static final ShaderShader which interpolates between the base colour and white.static final ShaderFixes blue level at parameter value.static final ShaderFixes green level at parameter value.static final ShaderShader which fixes hue.static final ShaderShader which sets intensity.static final ShaderFixes red level at parameter value.static final ShaderFixes U in YUV colour space.static final ShaderFixes V in YUV colour space.static final ShaderFixes Y in YUV colour space.static final ShaderHue-chroma-luminance cyclic shader.static final ShaderFixes H in HSV colour space.static final ShaderFixes S in HSV colour space.static final ShaderFixes V in HSV colour space.static final ShaderShader based on lookup table Accent.static final ShaderShader based on lookup table Aips0.static final ShaderShader based on lookup table Backgr.static final ShaderShader copied from Matplotlib BRG lookup table.static final ShaderBubblegum sequential shader from CMasher.static final ShaderChroma sequential shader from CMasher.static final ShaderCividis shader derived from DOI:10.1371/journal.pone.0199239.static final ShaderShader based on lookup table Cold.static final ShaderShader based on lookup table Color.static final ShaderCosmic sequential shader from CMasher.static final ShaderEmber sequential shader from CMasher.static final ShaderGem sequential shader from CMasher.static final ShaderShader copied from glNemo2 application.static final ShaderShader copied from Matplotlib Gnuplot lookup table.static final ShaderShader copied from Matplotlib Gnuplot2 lookup table.static final ShaderGothic sequential shader from CMasher.static final ShaderGuppy diverging shader from CMasher.static final ShaderShader based on lookup table Heat.static final ShaderDiverging hot-cold shader provided by Daniel Michalik.static final ShaderIceburn diverging shader from CMasher.static final ShaderShader based on lookup table IDL2.static final ShaderShader based on lookup table IDL4.static final ShaderInfinity cyclic shader from CMasher.static final ShaderShader based on lookup table Isophot.static final ShaderShader based on lookup table Light.static final ShaderShader based on lookup table Manycol.static final ShaderShader copied from Matplotlib 2.0 Inferno lookup table.static final ShaderShader copied from Matplotlib 2.0 Magma lookup table.static final ShaderShader copied from Matplotlib 2.0 Plasma lookup table.static final ShaderShader copied from Matplotlib 2.0 Viridis lookup table.static final ShaderNeon sequential shader from CMasher.static final ShaderPainbow shader scraped from https://xkcd.com/2537/.static final ShaderShader copied from Matplotlib Paired lookup table.static final ShaderShader based on lookup table Pastel.static final ShaderPride diverging shader from CMasher.static final ShaderShader based on lookup table Rainbow.static final ShaderShader copied from Matplotlib gist_rainbow lookup table.static final ShaderRainforest sequential shader from CMasher.static final ShaderShader based on lookup table Ramp.static final ShaderShader based on lookup table Random.static final ShaderShader based on lookup table Real.static final ShaderRedshift diverging shader from CMasher.static final ShaderShader copied from Matplotlib Set1 lookup table.static final Shader[]Selection of lookup table-based shaders.static final ShaderShader based on lookup table Smooth.static final ShaderShader copied from SPECX blue2yellow lookup table.static final ShaderShader based on lookup table Staircase.static final ShaderShader based on lookup table Standard.static final ShaderTropical sequential shader from CMasher.static final ShaderVoltage sequential shader from CMasher.static final StringProperty containing a File.pathSeparator-separated list of text files containing custom lookup tables.static final ShaderShader which does nothing.static final ShaderInterpolates between red (0) and blue (1).static final ShaderScales blue level by parameter value.static final ShaderScales green level by parameter value.static final ShaderScales H in HSV colour space.static final ShaderShader which scales intensity.static final ShaderScales red level by parameter value.static final ShaderScales S in HSV colour space.static final ShaderScales V in HSV colour space.static final ShaderScales Y in YUV colour space.static final ShaderRainbow shader copied from SRON technical note SRON/EPS/TN/09-002.static final ShaderRachel did this one.static final ShaderScales alpha channel by parameter value.static final ShaderInterpolates between white (0) and black (1). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ShaderapplyShader(Shader shader, Color baseColor, int nsample) Creates a shader by applying an existing shader to a given base colour.static Iconcreate2dIcon(Shader xShader, Shader yShader, boolean xFirst, Color baseColor, int width, int height, int xpad, int ypad) Constructs an icon which represents two shaders in two dimensions.static ShadercreateFixedShader(String name, Color color) Creates a shader which always returns a fixed colour regardless of the supplied parameter.static ShadercreateInterpolationShader(String name, Color[] colors) Constructs a shader which interpolates between a sequence of colours.static ShadercreateInterpolationShader(String name, Color color0, Color color1) Constructs a shader which interpolates smoothly between two colours.static ShadercreateMaskShader(String name, float minMask, float maxMask, boolean sense) Creates a shader which for each value either does nothing to a colour or turns it completely transparent.static IconcreateShaderIcon(Shader shader, boolean horizontal, int width, int height, int xpad, int ypad) Returns an icon which displays a shader in action, using a default grid shader if required.static IconcreateShaderIcon(Shader shader, Shader gridShader, boolean horizontal, int width, int height, int xpad, int ypad) Returns an icon which displays a shader in action, using an explicitly provided grid shader.static ShaderReturns a shader which scales the alpha value of all its colours by a given constant.static Shader[]Returns an array of any custom shaders specified by theLUTFILES_PROPERTYproperty.static ShaderReturns a shader which runs in the opposite direction to a given one.static booleanisTransparent(Shader shader) Indicates whether the given shader object is capable of introducing transparency into a colour (modifying rgba[3] from 1 to a lower value).static ShaderReturns a shader which splits the colour map into a set of discrete levels.static ShaderReturns a shader which delegates all behaviour to a supplied base instance, except it has a given name.static ShaderReturns a shader which corresponds to a sub-range of a given shader.
-
Field Details
-
LUTFILES_PROPERTY
Property containing a File.pathSeparator-separated list of text files containing custom lookup tables. Each line should contain three space-separated floating point values between zero and one giving the Red, Green and Blue components of a colour.- See Also:
-
FIX_RED
Fixes red level at parameter value. -
FIX_GREEN
Fixes green level at parameter value. -
FIX_BLUE
Fixes blue level at parameter value. -
SCALE_RED
Scales red level by parameter value. -
SCALE_GREEN
Scales green level by parameter value. -
SCALE_BLUE
Scales blue level by parameter value. -
FIX_Y
Fixes Y in YUV colour space. -
FIX_U
Fixes U in YUV colour space. -
FIX_V
Fixes V in YUV colour space. -
SCALE_Y
Scales Y in YUV colour space. -
HSV_H
Fixes H in HSV colour space. -
HSV_S
Fixes S in HSV colour space. -
HSV_V
Fixes V in HSV colour space. -
SCALE_H
Scales H in HSV colour space. -
SCALE_S
Scales S in HSV colour space. -
SCALE_V
Scales V in HSV colour space. -
RED_BLUE
Interpolates between red (0) and blue (1). -
CYAN_MAGENTA
Interpolates between cyan (0) and magenta (1). -
WHITE_BLACK
Interpolates between white (0) and black (1). -
BLACK_WHITE
Interpolates between black (0) and white (1). -
SUNSET
Rachel did this one. -
SRON_RAINBOW
Rainbow shader copied from SRON technical note SRON/EPS/TN/09-002. -
CUBEHELIX
Standard cubehelix shader. -
CUBEHELIX2
Enhanced hue cubehelix shader. -
CUBEHELIX3
Lurid cubehelix shader. -
LUT_AIPS0
Shader based on lookup table Aips0. -
LUT_BACKGR
Shader based on lookup table Backgr. -
LUT_COLOR
Shader based on lookup table Color. -
LUT_HEAT
Shader based on lookup table Heat. -
LUT_IDL2
Shader based on lookup table IDL2. -
LUT_IDL4
Shader based on lookup table IDL4. -
LUT_ISOPHOT
Shader based on lookup table Isophot. -
LUT_LIGHT
Shader based on lookup table Light. -
LUT_MANYCOL
Shader based on lookup table Manycol. -
LUT_PASTEL
Shader based on lookup table Pastel. -
LUT_RAINBOW
Shader based on lookup table Rainbow. -
LUT_RAMP
Shader based on lookup table Ramp. -
LUT_RANDOM
Shader based on lookup table Random. -
LUT_REAL
Shader based on lookup table Real. -
LUT_SMOOTH
Shader based on lookup table Smooth. -
LUT_STAIRCASE
Shader based on lookup table Staircase. -
LUT_STANDARD
Shader based on lookup table Standard. -
LUT_ACCENT
Shader based on lookup table Accent. -
LUT_COLD
Shader based on lookup table Cold. -
LUT_GLNEMO2
Shader copied from glNemo2 application. -
LUT_GNUPLOT
Shader copied from Matplotlib Gnuplot lookup table. -
LUT_GNUPLOT2
Shader copied from Matplotlib Gnuplot2 lookup table. -
LUT_SPECXB2Y
Shader copied from SPECX blue2yellow lookup table. -
LUT_BRG
Shader copied from Matplotlib BRG lookup table. -
LUT_PAIRED
Shader copied from Matplotlib Paired lookup table. -
LUT_RAINBOW3
Shader copied from Matplotlib gist_rainbow lookup table. -
LUT_SET1
Shader copied from Matplotlib Set1 lookup table. -
LUT_MPL2MAGMA
Shader copied from Matplotlib 2.0 Magma lookup table. -
LUT_MPL2INFERNO
Shader copied from Matplotlib 2.0 Inferno lookup table. -
LUT_MPL2PLASMA
Shader copied from Matplotlib 2.0 Plasma lookup table. -
LUT_MPL2VIRIDIS
Shader copied from Matplotlib 2.0 Viridis lookup table. -
LUT_HOTCOLD
Diverging hot-cold shader provided by Daniel Michalik. -
LUT_CIVIDIS
Cividis shader derived from DOI:10.1371/journal.pone.0199239. -
LUT_PAINBOW
Painbow shader scraped from https://xkcd.com/2537/. Thanks Randall. -
LUT_GUPPY
Guppy diverging shader from CMasher. -
LUT_ICEBURN
Iceburn diverging shader from CMasher. -
LUT_REDSHIFT
Redshift diverging shader from CMasher. -
LUT_PRIDE
Pride diverging shader from CMasher. -
LUT_INFINITY
Infinity cyclic shader from CMasher. -
LUT_COSMIC
Cosmic sequential shader from CMasher. -
LUT_EMBER
Ember sequential shader from CMasher. -
LUT_GOTHIC
Gothic sequential shader from CMasher. -
LUT_RAINFOREST
Rainforest sequential shader from CMasher. -
LUT_VOLTAGE
Voltage sequential shader from CMasher. -
LUT_BUBBLEGUM
Bubblegum sequential shader from CMasher. -
LUT_GEM
Gem sequential shader from CMasher. -
LUT_CHROMA
Chroma sequential shader from CMasher. -
LUT_NEON
Neon sequential shader from CMasher. -
LUT_TROPICAL
Tropical sequential shader from CMasher. -
LUT_SHADERS
Selection of lookup table-based shaders. -
BREWER_BUGN
ColorBrewer sequential blue-green shader. -
BREWER_BUPU
ColorBrewer sequential blue-purple shader. -
BREWER_ORRD
ColorBrewer sequential orange-red shader. -
BREWER_PUBU
ColorBrewer sequential purple-blue shader. -
BREWER_PURD
ColorBrewer sequential purple-red shader. -
BREWER_RDBU
ColorBrewer diverging red-blue shader. -
BREWER_PIYG
ColorBrewer diverging pink-green shader. -
BREWER_BRBG
ColorBrewer diverging brown-blue-green shader. -
HCL_POLAR
Hue-chroma-luminance cyclic shader. Got from hclwizard.org with parameters: qualitative, H1=0 H2=351, N=40, C1=90, L1=60 -
DFLT_GRID_SHADER
Shader used by default for the transverse axis of non-absolute ramps. -
NULL
Shader which does nothing. -
TRANSPARENCY
Scales alpha channel by parameter value. -
FIX_INTENSITY
Shader which sets intensity. -
SCALE_INTENSITY
Shader which scales intensity. -
FADE_BLACK
Shader which interpolates between the base colour and black. -
FADE_WHITE
Shader which interpolates between the base colour and white. -
FIX_HUE
Shader which fixes hue.
-
-
Constructor Details
-
Shaders
public Shaders()
-
-
Method Details
-
createInterpolationShader
-
createInterpolationShader
Constructs a shader which interpolates between a sequence of colours. The shading is defined by a sequence of linear segments.- Parameters:
name- namecolors- sequence of colours; value 0 corresponds to the first colour and value 1 corresponds to the last- Returns:
- shader
-
createFixedShader
-
createMaskShader
Creates a shader which for each value either does nothing to a colour or turns it completely transparent. The pass range is specified by a minimum and maximum value and a sense.- Parameters:
name- shader nameminMask- minimum value (exclusive) for rangemaxMask- maximum value (exclusive) for rangesense- if true, values outside the range are transparent, if false, values within the range are transparent
-
getCustomShaders
Returns an array of any custom shaders specified by theLUTFILES_PROPERTYproperty.- Returns:
- array of zero or more custom shaders
-
invert
-
fade
-
rename
-
stretch
Returns a shader which corresponds to a sub-range of a given shader.- Parameters:
shader- base shaderfrac0- parameter value in base shader corresponding to value 0 in this one (must be in range 0-1)frac1- parameter value in base shader corresponding to value 1 in this one (must be in range 0-1)- Returns:
- new shader
-
quantise
-
applyShader
Creates a shader by applying an existing shader to a given base colour. This only does useful work if the existing shader is non-absolute.- Parameters:
shader- shader to apply (presumably non-absolute)baseColor- colour to which the shader will be appliednsample- number of samples in the lookup table- Returns:
- new absolute shader
-
create2dIcon
public static Icon create2dIcon(Shader xShader, Shader yShader, boolean xFirst, Color baseColor, int width, int height, int xpad, int ypad) Constructs an icon which represents two shaders in two dimensions.- Parameters:
xShader- shader for X directionyShader- shader for Y directionxFirst- true if X shader is to be applied firstbaseColor- base colour for the shaders to work onwidth- total width of the iconheight- total height of the iconxpad- internal padding in the X directionypad- internal padding in the Y direction- Returns:
- icon
-
createShaderIcon
public static Icon createShaderIcon(Shader shader, Shader gridShader, boolean horizontal, int width, int height, int xpad, int ypad) Returns an icon which displays a shader in action, using an explicitly provided grid shader.- Parameters:
shader- shader to illustrategridShader- defines the pixels along the transverse direction of the shader; ignored (may be null) for absolute shadershorizontal- true for shading running horizontally, false for verticallywidth- total icon width in pixelsheight- total icon height in pixelsxpad- internal padding in the X directionypad- internal padding in the Y direction- Returns:
- icon
-
createShaderIcon
public static Icon createShaderIcon(Shader shader, boolean horizontal, int width, int height, int xpad, int ypad) Returns an icon which displays a shader in action, using a default grid shader if required.- Parameters:
shader- shader to illustratehorizontal- true for shading running horizontally, false for verticallywidth- total icon width in pixelsheight- total icon height in pixelsxpad- internal padding in the X directionypad- internal padding in the Y direction- Returns:
- icon
-
isTransparent
Indicates whether the given shader object is capable of introducing transparency into a colour (modifying rgba[3] from 1 to a lower value).- Parameters:
shader- shader to test- Returns:
- true if shader adjusts transparency or is null
-