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

Loading…
Cancel
Save