SVG fill colors, with support for fg/bg averaged colors and none
Brought to you by:
johnston
|
From: <ivt...@li...> - 2002-11-07 00:29:20
|
Patch: ivtools-021106-johnston-073
For: ivtools-1.0.6
Author: joh...@us...
Subject: SVG fill colors, with support for fg/bg averaged colors and none
Requires:
This is an intermediate patch to ivtools-1.0.6. To apply, cd to the
top-level directory of the ivtools source tree (the directory with src
and config subdirs), and apply like this:
patch -p0 <ThisFile
Summary of Changes:
- expanded support for SVG fill colors, with support for a none color,
and for blending foreground and background colors (from 0 to 100%).
Index: OverlayUnidraw/scriptview.c
diff -c OverlayUnidraw/scriptview.c:1.3 OverlayUnidraw/scriptview.c:1.4
*** OverlayUnidraw/scriptview.c:1.3 Tue Oct 22 12:10:09 2002
--- src/OverlayUnidraw/scriptview.c Wed Nov 6 12:08:24 2002
***************
*** 145,150 ****
--- 145,185 ----
}
}
+ void OverlayScript::Colors (ostream& out) {
+ if (!svg_format()) {
+ FgColor(out);
+ BgColor(out);
+ } else {
+
+ PSColor* fgcolor = (PSColor*)
GetOverlayComp()->GetGraphic()->GetFgColor();
+ PSColor* bgcolor = (PSColor*)
GetOverlayComp()->GetGraphic()->GetBgColor();
+
+ ColorIntensity fr, fg, fb;
+ fgcolor->GetIntensities(fr, fg, fb);
+
+ out << "stroke: rgb("
+ << (int)(fr*100) << "%,"
+ << (int)(fg*100) << "%,"
+ << (int)(fb*100) << "%); ";
+
+ ColorIntensity br, bg, bb;
+ bgcolor->GetIntensities(br, bg, bb);
+
+ PSPattern* pat = (PSPattern*)
GetOverlayComp()->GetGraphic()->GetPattern();
+ if (pat != nil && !pat->None() &&
+ pat->GetGrayLevel()>=0.0 && pat->GetGrayLevel()<=1.0) {
+
+ float fp = 100.0*(1.0-pat->GetGrayLevel());
+ float bp = 100.0-fp;
+ out << "fill: rgb("
+ << (int)(fr*fp+br*bp) << "%,"
+ << (int)(fg*fp+bg*bp) << "%,"
+ << (int)(fb*fp+bb*bp) << "%); ";
+ }
+ }
+
+ }
+
void OverlayScript::FgColor (ostream& out) {
PSColor* fgcolor = (PSColor*)
GetOverlayComp()->GetGraphic()->GetFgColor();
***************
*** 154,173 ****
ColorIntensity r, g, b;
fgcolor->GetIntensities(r, g, b);
! if (!svg_format()) {
! out << " :fgcolor \"" << name << "\"";
! out << "," << r << "," << g << "," << b;
! } else {
! out << "stroke: rgb("
! << (int)(r*100) << "%,"
! << (int)(g*100) << "%,"
! << (int)(b*100) << "%) ";
! out << "fill-color: rgb("
! << (int)(r*100) << "%,"
! << (int)(g*100) << "%,"
! << (int)(b*100) << "%) ";
! }
!
}
}
--- 189,197 ----
ColorIntensity r, g, b;
fgcolor->GetIntensities(r, g, b);
! out << " :fgcolor \"" << name << "\"";
! out << "," << r << "," << g << "," << b;
!
}
}
***************
*** 180,190 ****
ColorIntensity r, g, b;
bgcolor->GetIntensities(r, g, b);
- if (!svg_format()) {
out << " :bgcolor \"" << name << "\"";
out << "," << r << "," << g << "," << b;
! }
!
}
}
--- 204,212 ----
ColorIntensity r, g, b;
bgcolor->GetIntensities(r, g, b);
out << " :bgcolor \"" << name << "\"";
out << "," << r << "," << g << "," << b;
!
}
}
***************
*** 212,220 ****
if (pat->None()) {
! if (!svg_format()) {
out << " :nonepat";
! }
} else if (pat->GetSize() > 0) {
--- 234,243 ----
if (pat->None()) {
! if (!svg_format())
out << " :nonepat";
! else
! out << "fill: none;";
} else if (pat->GetSize() > 0) {
***************
*** 754,761 ****
out << " gs(";
FillBg(out);
Brush(out);
! FgColor(out);
! BgColor(out);
Font(out);
Pattern(out);
out << ")";
--- 777,783 ----
out << " gs(";
FillBg(out);
Brush(out);
! Colors(out);
Font(out);
Pattern(out);
out << ")";
***************
*** 853,860 ****
if (svg_format()) out << "style=\"";
FillBg(out);
Brush(out);
! FgColor(out);
! BgColor(out);
Pattern(out);
if (svg_format()) out << "\" ";
}
--- 875,881 ----
if (svg_format()) out << "style=\"";
FillBg(out);
Brush(out);
! Colors(out);
Pattern(out);
if (svg_format()) out << "\" ";
}
***************
*** 870,877 ****
else {
FillBg(out);
Brush(out);
! FgColor(out);
! BgColor(out);
Font(out);
Pattern(out);
}
--- 891,897 ----
else {
FillBg(out);
Brush(out);
! Colors(out);
Font(out);
Pattern(out);
}
***************
*** 899,906 ****
if (cb)
out << " :gs " << MatchedGS(cb);
else {
! FgColor(out);
! BgColor(out);
}
}
Transformation(out);
--- 919,925 ----
if (cb)
out << " :gs " << MatchedGS(cb);
else {
! Colors(out);
}
}
Transformation(out);
Index: OverlayUnidraw/scriptview.h
diff -c OverlayUnidraw/scriptview.h:1.3 OverlayUnidraw/scriptview.h:1.4
*** OverlayUnidraw/scriptview.h:1.3 Tue Oct 22 12:10:09 2002
--- src/OverlayUnidraw/scriptview.h Wed Nov 6 12:08:24 2002
***************
*** 174,179 ****
--- 174,180 ----
protected:
virtual void FillBg(ostream& out);
virtual void Brush(ostream& out);
+ virtual void Colors(ostream& out);
virtual void FgColor(ostream& out);
virtual void BgColor(ostream& out);
virtual void Font(ostream& out);
*** /dev/null Wed Nov 6 12:09:00 PST 2002
--- patches/ivtools-021106-johnston-073
*************** patches/ivtools-021106-johnston-073
*** 0 ****
--- 1 ----
+ ivtools-021106-johnston-073
|