From 4553116f28d76c59ea7a0ed2e69a5f5d477d3f53 Mon Sep 17 00:00:00 2001 From: Paul Bignier Date: Fri, 6 Jan 2017 13:53:13 +0100 Subject: [PATCH] Scicos macros & tests: fix default_color * Used the opportunity to reduce obsolete xset() footprint Change-Id: Iab74485112d1665dff29caa5a2c35a55a64273e2 --- .../modules/scicos/macros/scicos_scicos/color.tst | 61 -------------------- .../scicos/macros/scicos_scicos/default_color.sci | 15 +++-- scilab/modules/scicos/tests/unit_tests/color.tst | 57 ++++++++++++++++++ 3 files changed, 66 insertions(+), 67 deletions(-) delete mode 100644 scilab/modules/scicos/macros/scicos_scicos/color.tst create mode 100644 scilab/modules/scicos/tests/unit_tests/color.tst diff --git a/scilab/modules/scicos/macros/scicos_scicos/color.tst b/scilab/modules/scicos/macros/scicos_scicos/color.tst deleted file mode 100644 index b5f1b00..0000000 --- a/scilab/modules/scicos/macros/scicos_scicos/color.tst +++ /dev/null @@ -1,61 +0,0 @@ -// Scicos -// -// Copyright (C) INRIA - METALAU Project -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// See the file ../license.txt -// - -xsetech([0 0 1 1],[0 0 1 1]) -orig=[0 0] -sz=[1 1] - -thick=xget('thickness');xset('thickness',2); -xrect(orig(1)+sz(1)/10,orig(2)+(1-1/10)*sz(2),sz(1)*8/10,sz(2)*8/10); -xx=[orig(1)+sz(1)/5,orig(1)+sz(1)/5; -orig(1)+(1-1/5)*sz(1),orig(1)+sz(1)/5]; -yy=[orig(2)+sz(2)/5,orig(2)+sz(2)/5; -orig(2)+sz(2)/5,orig(2)+(1-1/5)*sz(2)]; -xarrows(xx,yy); -t=(0:0.3:2*%pi)' -xx=orig(1)+(1/5+3*t/(10*%pi))*sz(1); -yy=orig(2)+(1/4.3+(sin(t)+1)*3/10)*sz(2); -xpoly(xx,yy,'lines'); -xset('thickness',thick) - - - -orig=[0.5 0.5] - - - -wd=xget('wdim').*[1.016,1.12]; -thick=xget('thickness');xset('thickness',2); -p=wd(2)/wd(1);p=1; -rx=sz(1)*p/2;ry=sz(2)/2; -xarcs([orig(1)+0.05*sz(1); -orig(2)+0.95*sz(2); - 0.9*sz(1)*p; - 0.9*sz(2); - 0; - 360*64],default_color(-1)); -xset('thickness',1); -xx=[orig(1)+rx orig(1)+rx; - orig(1)+rx orig(1)+rx+0.6*rx*cos(%pi/6)]; -yy=[orig(2)+ry orig(2)+ry ; - orig(2)+1.8*ry orig(2)+ry+0.6*ry*sin(%pi/6)]; -xsegs(xx,yy,10); -xset('thickness',thick); diff --git a/scilab/modules/scicos/macros/scicos_scicos/default_color.sci b/scilab/modules/scicos/macros/scicos_scicos/default_color.sci index 6cdbd36..04cb9c6 100644 --- a/scilab/modules/scicos/macros/scicos_scicos/default_color.sci +++ b/scilab/modules/scicos/macros/scicos_scicos/default_color.sci @@ -19,18 +19,21 @@ // See the file ../license.txt // -function clr=default_color(typ) +function clr = default_color(typ) + + if ~isdef("options") then + options = default_options(); + end if typ==-1 then //event links - clr=options("Link")(2), + clr = options("Link")(2); elseif typ==0 then //text, block shape, if size(options("Background"),"*")>=2 then //compatibility - clr=options("Background")(2), + clr = options("Background")(2); else - clr=1 + clr = 1 end elseif typ==1 | typ==2 then //regular links - - clr=options("Link")(1), + clr = options("Link")(1); end endfunction diff --git a/scilab/modules/scicos/tests/unit_tests/color.tst b/scilab/modules/scicos/tests/unit_tests/color.tst new file mode 100644 index 0000000..81da5c5 --- /dev/null +++ b/scilab/modules/scicos/tests/unit_tests/color.tst @@ -0,0 +1,57 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// +// <-- TEST WITH GRAPHICS --> + +loadXcosLibs(); + +xsetech([0 0 1 1], [0 0 1 1]); +orig = [0 0]; +sz = [1 1]; + +a = gca(); +thick = a.thickness; +a.thickness = 2; +xrect(orig(1)+sz(1)/10, orig(2)+(1-1/10)*sz(2), sz(1)*8/10, sz(2)*8/10); +xx = [orig(1)+sz(1)/5, orig(1)+sz(1)/5; orig(1)+(1-1/5)*sz(1), orig(1)+sz(1)/5]; +yy = [orig(2)+sz(2)/5, orig(2)+sz(2)/5; orig(2)+sz(2)/5, orig(2)+(1-1/5)*sz(2)]; +xarrows(xx, yy); +t = (0:0.3:2*%pi)'; +xx = orig(1)+(1/5+3*t/(10*%pi))*sz(1); +yy = orig(2)+(1/4.3+(sin(t)+1)*3/10)*sz(2); +xpoly(xx, yy, "lines"); +a.thickness = thick; + + +orig = [0.5 0.5]; + +f = gcf(); +wd = f.axes_size .* [1.016,1.12]; +a.thickness = 2; +p = wd(2)/wd(1); +p = 1; +rx = sz(1)*p/2; +ry = sz(2)/2; +xarcs([orig(1)+0.05*sz(1); orig(2)+0.95*sz(2); 0.9*sz(1)*p; 0.9*sz(2); 0; 360*64], default_color(-1)); +a.thickness = 1; +xx = [orig(1)+rx orig(1)+rx; orig(1)+rx orig(1)+rx+0.6*rx*cos(%pi/6)]; +yy = [orig(2)+ry orig(2)+ry; orig(2)+1.8*ry orig(2)+ry+0.6*ry*sin(%pi/6)]; +xsegs(xx, yy, 10); +a.thickness = thick; -- 1.7.9.5