File:Colormap.svg

Uploaded by Gjacquenot
Upload date 2009-02-07T13:06:24Z
MIME type image/svg+xml
Dimensions 512 × 576 px
File size 102.2 KB

Summary

Description
English: Set of colobars
Date
Source Own work
Author Guillaume Jacquenot
SVG development
InfoField
 The SVG code is valid.
 This diagram was created with MATLAB.
Source code
InfoField

MATLAB code

function Generate_colorbar(filename)
if nargin == 0
    filename = 'colormap.svg';
end

  T={ ...
    'jet'
    'hsv'
    'hot'
    'cool'
    'spring'
    'summer'
    'autumn'	
    'winter'
    'gray'
    'bone'
    'copper'
    'pink'
    'lines'
    'colorcube'
    'flag'
    'prism'
	};    

fid = fopen(filename,'w');
fprintf(fid,'<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n');
fprintf(fid,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n');
fprintf(fid,'<svg\n');
fprintf(fid,'\txmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n');
fprintf(fid,'\txmlns:svg="http://www.w3.org/2000/svg"\n');
fprintf(fid,'\txmlns="http://www.w3.org/2000/svg"\n');
fprintf(fid,'\twidth="512px"\n');
fprintf(fid,'\theight="%dpx">\n',36*numel(T));
fprintf(fid,'\t\n');
fprintf(fid,'\t\n');

for j=1:numel(T)
    cmap = colormap(T{j});
    fprintf(fid,'\t<g id="g_%s">\n',T{j});
    for i=1:size(cmap,1)
        colorname = sprintf('%02x%02x%02x',...
            fix(cmap(i,1)*255),fix(cmap(i,2)*255),fix(cmap(i,3)*255));
        fprintf(fid,'\t\t<rect\n');
        fprintf(fid,'\t\t\tid="rect%d"\n',1000+64*(j-1)+i);
        fprintf(fid,'\t\t\tx="%d"\n',8*(i-1));
        fprintf(fid,'\t\t\ty="%d"\n',36*(j-1));
        fprintf(fid,'\t\t\theight="32"\n');
        fprintf(fid,'\t\t\twidth="9"\n');
        fprintf(fid,'\t\t\tstyle="fill:#%s" />\n',colorname);   
    end
    fprintf(fid,'\t\t</g>\n\n');
end
fprintf(fid,'</svg>\n');
fclose(fid);



Licensing

I, the copyright holder of this work, hereby publish it under the following licenses:
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported, 2.5 Generic, 2.0 Generic and 1.0 Generic license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
You may select the license of your choice.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

7 February 2009

image/svg+xml

bb26baf4aa09957d40942edf615763c2308893ce

104,701 byte

576 pixel

512 pixel

Category:CC-BY-SA-3.0,2.5,2.0,1.0 Category:Color bars Category:Color gradient Category:GFDL Category:License migration redundant Category:Self-published work Category:Valid SVG created with MATLAB code