A sketchy implementation of cubehelix color scheme algorithm for Max/MSP/Jitter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

175 lines
4.5 KiB

{
"patcher" : {
"fileversion" : 1,
"appversion" : {
"major" : 8,
"minor" : 5,
"revision" : 6,
"architecture" : "x64",
"modernui" : 1
}
,
"classnamespace" : "jit.gen",
"rect" : [ 188.0, 268.0, 672.0, 730.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 1,
"gridsize" : [ 15.0, 15.0 ],
"gridsnaponopen" : 1,
"objectsnaponopen" : 1,
"statusbarvisible" : 2,
"toolbarvisible" : 1,
"lefttoolbarpinned" : 0,
"toptoolbarpinned" : 0,
"righttoolbarpinned" : 0,
"bottomtoolbarpinned" : 0,
"toolbars_unpinned_last_save" : 0,
"tallnewobj" : 0,
"boxanimatetime" : 200,
"enablehscroll" : 1,
"enablevscroll" : 1,
"devicewidth" : 0.0,
"description" : "",
"digest" : "",
"tags" : "",
"style" : "",
"subpatcher_template" : "",
"assistshowspatchername" : 0,
"boxes" : [ {
"box" : {
"id" : "obj-11",
"linecount" : 3,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 50.0, 135.0, 570.0, 48.0 ],
"text" : "Original cubehelix implementation from: Green, D. A., 2011, ‘A colour scheme for the display of astronomical intensity images’, Bulletin of the Astronomical Society of India, 39, 289.\n(2011BASI...39..289G at ADS.): https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/"
}
}
, {
"box" : {
"id" : "obj-8",
"linecount" : 2,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 50.0, 188.0, 570.0, 34.0 ],
"text" : "Below implementation based on D3 implementation by @mbostock https://github.com/d3/d3-plugins/tree/master/cubehelix"
}
}
, {
"box" : {
"id" : "obj-7",
"linecount" : 4,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 220.0, 47.0, 406.0, 62.0 ],
"text" : "Default values are meant to reproduce the default cubehelix color scheme.\nhue_offset is here to shift common Max hue values (with 0 as red) by 120° and make them work with the cubehelix algorithm (made to work with 0 as blue)."
}
}
, {
"box" : {
"id" : "obj-5",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 50.0, 47.0, 155.0, 22.0 ],
"text" : "param hue_offset 0.333333"
}
}
, {
"box" : {
"id" : "obj-3",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 304.0, 5.0, 203.0, 22.0 ],
"text" : "param color_end -0.666666 0.5 1. 1."
}
}
, {
"box" : {
"id" : "obj-2",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 92.0, 5.0, 202.0, 22.0 ],
"text" : "param color_start 0.888888 0.5 0. 1."
}
}
, {
"box" : {
"code" : "h_s = (color_start.x + hue_offset) * TWOPI;\r\nh_e = (color_end.x + hue_offset) * TWOPI - h_s;\r\ns_s = color_start.y;\r\ns_e = color_end.y - s_s;\r\nl_s = color_start.z;\r\nl_e = color_end.z - l_s;\r\n\r\n\r\nh = h_s + h_e * norm;\r\nl = pow(l_s + l_e * norm, gamma);\r\na = (s_s + s_e * norm) * l * (1 - l);\r\n\r\ncosh = cos(h);\r\nsinh = sin(h);\r\n\r\nr = l + a * (-0.14861 * cosh + 1.78277 * sinh);\r\n\r\ng = l + a * (-0.29227 * cosh - 0.90649 * sinh);\r\n\r\nb = l + a * (1.97294 * cosh);\r\n\r\nout1 = vec(1, r, g, b);",
"fontface" : 0,
"fontname" : "<Monospaced>",
"fontsize" : 12.0,
"id" : "obj-12",
"maxclass" : "codebox",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 50.0, 224.0, 531.0, 382.0 ]
}
}
, {
"box" : {
"id" : "obj-10",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 527.0, 5.0, 99.0, 22.0 ],
"text" : "param gamma 1."
}
}
, {
"box" : {
"id" : "obj-1",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 50.0, 5.0, 28.0, 22.0 ],
"text" : "in 1"
}
}
, {
"box" : {
"id" : "obj-4",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 50.0, 623.0, 35.0, 22.0 ],
"text" : "out 1"
}
}
],
"lines" : [ {
"patchline" : {
"destination" : [ "obj-4", 0 ],
"source" : [ "obj-12", 0 ]
}
}
],
"autosave" : 0
}
}