Skip to content

Latest commit

 

History

History
34 lines (18 loc) · 732 Bytes

MATLAB_PALETTE.md

File metadata and controls

34 lines (18 loc) · 732 Bytes

You can create a JSON formatted palette from a MATLAB colormap using this Matlab function:

function json = colormap2json(cm)
% Example: 
%  json = colormap2json(jet(10)); 

if max(cm(:))<=1, warning('Info: converting colormap from 0-1 range to 0-255 range'); cm=cm*255; end
cm=floor(cm);

json='';
for i=1:size(cm,1)
    json = sprintf('%s,''#%02X%02X%02X''', json, cm(i,1), cm(i,2), cm(i,3));
end
json = sprintf('[%s]',json(2:end)); % Chomp leading command and wrap in brackets

end

Then use it in the AFrame component like this:

  <a-entity aframe-heatmap3d="...; palette: ['#0000AA','#0000FF','#0055FF','#00AAFF','#00FFFF','#55FFAA','#AAFF55','#FFFF00','#FFAA00','#FF5500']; ..."></a-entity>