Browse Source

Gmt module: Functions ColorGray, ColorRGB, ColorHSV, ColorCMYK now using new parameter reading scheme and error reporting.

gmtdatadir
Michael Uleysky 8 years ago
parent
commit
d02fd289f8
  1. 76
      modules/gmt/modgmt_func.cpp

76
modules/gmt/modgmt_func.cpp

@ -24,69 +24,65 @@ const ObjectBase* GMT_Footer(const ObjectList* input)
const ObjectBase* GMT_ColorGray(const ObjectList* input)
{
struct gmt_color c;
bool suc=true;
Base2RGB g(input,0);
Base2Transp t(input,1);
RPosPar<Base2RGB> g("gray");
OPosPar<Base2TransD> t("transparency",0.0);
ParsePositionalParameters params(input,g,t);
if(!params) return new ObjectError("ColorGray",params.Error());
c.model=gmt_color::GRAY;
c.gray=g(&suc);
c.transparency=t(&suc);
c.gray=g; c.transparency=t;
if(suc) return new ObjectGMTColor(c);
else return 0;
return new ObjectGMTColor(c);
}
const ObjectBase* GMT_ColorRGB(const ObjectList* input)
{
struct gmt_color c;
bool suc=true;
Base2RGB r(input,0),g(input,1),b(input,2);
Base2Transp t(input,3);
RPosPar<Base2RGB> r("red"),g("green"),b("blue");
OPosPar<Base2TransD> t("transparency",0.0);
ParsePositionalParameters params(input,r,g,b,t);
if(!params) return new ObjectError("ColorRGB",params.Error());
c.model=gmt_color::RGB;
c.r=r(&suc);
c.g=g(&suc);
c.b=b(&suc);
c.transparency=t(&suc);
c.r=r; c.g=g; c.b=b; c.transparency=t;
if(suc) return new ObjectGMTColor(c);
else return 0;
return new ObjectGMTColor(c);
}
const ObjectBase* GMT_ColorHSV(const ObjectList* input)
{
struct gmt_color c;
bool suc=true;
Base2Hue h(input,0);
Base2SV s(input,1),v(input,2);
Base2Transp t(input,3);
RPosPar<Base2Hue> h("hue");
RPosPar<Base2SV> s("saturation"), v("value");
OPosPar<Base2TransD> t("transparency",0.0);
ParsePositionalParameters params(input,h,s,v,t);
if(!params) return new ObjectError("ColorHSV",params.Error());
c.model=gmt_color::HSV;
c.hue=h(&suc);
c.saturation=s(&suc);
c.value=v(&suc);
c.transparency=t(&suc);
c.hue=h; c.saturation=s; c.value=v; c.transparency=t;
if(suc) return new ObjectGMTColor(c);
else return 0;
return new ObjectGMTColor(c);
}
const ObjectBase* GMT_ColorCMYK(const ObjectList* input)
{
struct gmt_color c;
bool suc=true;
Base2CMYK cyan(input,0),m(input,1),y(input,2),k(input,3);
Base2Transp t(input,4);
c.model=gmt_color::CMYK;
c.cyan=cyan(&suc);
c.magenta=m(&suc);
c.yellow=y(&suc);
c.black=k(&suc);
c.transparency=t(&suc);
if(suc) return new ObjectGMTColor(c);
else return 0;
struct gmt_color C;
RPosPar<Base2CMYK> c("cyan"),m("magenta"),y("yellow"),k("black");
OPosPar<Base2TransD> t("transparency",0.0);
ParsePositionalParameters params(input,c,m,y,k,t);
if(!params) return new ObjectError("ColorCMYK",params.Error());
C.model=gmt_color::CMYK;
C.cyan=c; C.magenta=m; C.yellow=y; C.black=k; C.transparency=t;
return new ObjectGMTColor(C);
}
// Shifting layer

Loading…
Cancel
Save