Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
isisscripts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
20
Issues
20
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
remeis
isisscripts
Commits
4a536738
Commit
4a536738
authored
Feb 12, 2024
by
Jakob Stierhof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Index fix
parent
69d22205
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
33 deletions
+40
-33
src/slang/color/palettes.sl
src/slang/color/palettes.sl
+40
-33
No files found.
src/slang/color/palettes.sl
View file @
4a536738
...
...
@@ -111,38 +111,6 @@ private define hpluv_palette (n)
return rgb2hex(hsluv2rgb(hues, qualifier("s", 0.9), qualifier("l", 0.6)));
}
private define colormap_palette (n, name)
%!%+
%\function{palette--map}
%\synopsis{Retrieve a set of colors from a colormap}
%\usage{UInt_Type[] palette = get_color_palette (String_Type name, UInt_Type len);}
%\qualifiers{
% \qualifier{start[=0.0]}{Starting "color" (lowest value)}
% \qualifier{range[=1.0]}{Range of "color", larger than one causes repetitions}
%}
%\description
% This function is useful if a range of colors is required.
% It returns \code{len} values from a linear mapping of the
% given colormap. If \code{n} is more than 256, repetitions will
% occure.
%!%-
{
#ifexists png_add_colormap
variable map;
try
map = png_get_colormap(name);
catch AnyError:
throw UsageError, "Unknown palette: '$name'"$;
variable ind = (qualifier("start", 0.0) + [0:qualifier("range", 1.0):#n]) mod 1.0;
ind = int((ind-int(ind))*255);
return map[ind];
#else
return ColorPalettes[""];
#endif
}
% HSL, HSLuv palettes %{{{
add_color_palette("hsl", &hsl_palette);
add_color_palette("hsluv", &hsluv_palette);
...
...
@@ -378,7 +346,7 @@ private define blend_palette (n)
mb[winf] = 0.;
weights = weights[[:-2]];
variable idx = [0, int(weights*
n
), n-1];
variable idx = [0, int(weights*
(n-1)
), n-1];
variable tr = r[[:-2]]-mr*weights;
variable tg = g[[:-2]]-mg*weights;
variable tb = b[[:-2]]-mb*weights;
...
...
@@ -557,6 +525,45 @@ private define cubehelix_palette (n)
add_color_palette("cubehelix", &cubehelix_palette);
%}}}
private define colormap_palette (n, name)
%!%+
%\function{palette--map}
%\synopsis{Retrieve a set of colors from a colormap}
%\usage{UInt_Type[] palette = get_color_palette (String_Type name, UInt_Type len);}
%\qualifiers{
% \qualifier{start[=0.0]}{Starting "color" (lowest value)}
% \qualifier{range[=1.0]}{Range of "color", larger than one causes repetitions}
%}
%\description
% This function is useful if a range of colors is required.
% It returns \code{len} values from a linear mapping of the
% given colormap. The colors are constructed from palette--blend
% and forwards all qualifiers to this constructor.
%!%-
{
#ifexists png_add_colormap
variable map;
try
map = png_get_colormap(name);
catch AnyError:
throw UsageError, "Unknown palette: '$name'"$;
variable start = qualifier("start", 0.0);
variable range = qualifier("range", 1.0);
while (start<0) start += 1.0;
start = int(start*(length(map)-1));
range = int(range*(length(map)-1));
variable ind = [start:start+range] mod length(map);
vmessage("start: %06x, stop: %06x", (map[ind])[0], (map[ind])[-1]);
return blend_palette(n;; struct { @__qualifiers(), colors=map[ind] });
#else
return ColorPalettes[""];
#endif
}
define get_color_palette (name, n)
%!%+
%\function{get_color_palette}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment