summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/psfile.cc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-04-19 23:59:33 +0000
committerKarl Berry <karl@freefriends.org>2010-04-19 23:59:33 +0000
commitdddce3148a2bc785603576b18ffcf72d39adbe47 (patch)
tree14f4c79ef11bcf0820a8d4ff2ab0c5ac009c365c /Build/source/utils/asymptote/psfile.cc
parenta01e51b01f5819b6091af48cdca581e9f2a9282e (diff)
asy 1.93
git-svn-id: svn://tug.org/texlive/trunk@17934 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/psfile.cc')
-rw-r--r--Build/source/utils/asymptote/psfile.cc86
1 files changed, 27 insertions, 59 deletions
diff --git a/Build/source/utils/asymptote/psfile.cc b/Build/source/utils/asymptote/psfile.cc
index 4605758de67..659f7e09057 100644
--- a/Build/source/utils/asymptote/psfile.cc
+++ b/Build/source/utils/asymptote/psfile.cc
@@ -221,28 +221,26 @@ void psfile::setpen(pen p)
else setcolor(p);
// Defer dynamic linewidth until stroke time in case currentmatrix changes.
- if(p.width() != lastpen.width()) {
+ if(p.width() != lastpen.width())
*out << p.width() << (pdfformat ? " setlinewidth" : " Setlinewidth")
<< newl;
- }
- if(p.cap() != lastpen.cap()) {
+ if(p.cap() != lastpen.cap())
*out << p.cap() << " setlinecap" << newl;
- }
- if(p.join() != lastpen.join()) {
+ if(p.join() != lastpen.join())
*out << p.join() << " setlinejoin" << newl;
- }
- if(p.miter() != lastpen.miter()) {
+ if(p.miter() != lastpen.miter())
*out << p.miter() << " setmiterlimit" << newl;
- }
-
- if(p.stroke() != lastpen.stroke() ||
- p.linetype().offset != lastpen.linetype().offset) {
+
+ const LineType *linetype=p.linetype();
+ const LineType *lastlinetype=lastpen.linetype();
+
+ if(!(linetype->pattern == lastlinetype->pattern) ||
+ linetype->offset != lastlinetype->offset) {
out->setf(std::ios::fixed);
- *out << "[" << p.stroke() << "] " << std::setprecision(6)
- << p.linetype().offset << " setdash" << newl;
+ *out << linetype->pattern << " " << linetype->offset << " setdash" << newl;
out->unsetf(std::ios::fixed);
}
@@ -286,7 +284,7 @@ void psfile::write(path p, bool newPath)
}
}
-void psfile::latticeshade(const vm::array& a, const bbox& b)
+void psfile::latticeshade(const vm::array& a, const transform& t)
{
checkLevel();
size_t n=a.size();
@@ -303,8 +301,7 @@ void psfile::latticeshade(const vm::array& a, const bbox& b)
*out << "<< /ShadingType 1" << newl
<< "/Matrix ";
-
- write(matrix(b.Min(),b.Max()));
+ write(t);
*out << newl;
*out << "/ColorSpace /Device" << ColorDeviceSuffix[colorspace] << newl
<< "/Function" << newl
@@ -323,7 +320,6 @@ void psfile::latticeshade(const vm::array& a, const bbox& b)
*out << "/Size [" << m << " " << n << "]" << newl
<< "/DataSource <" << newl;
- beginHex();
for(size_t i=n; i > 0;) {
array *ai=read<array *>(a,--i);
checkArray(ai);
@@ -334,12 +330,12 @@ void psfile::latticeshade(const vm::array& a, const bbox& b)
p->convert();
if(!p->promote(colorspace))
reportError(inconsistent);
- writeHex(p,ncomponents);
+ *out << p->hex() << newl;
}
}
- endHex();
-
- *out << ">>" << newl
+
+ *out << ">" << newl
+ << ">>" << newl
<< ">>" << newl
<< "shfill" << newl;
}
@@ -350,6 +346,8 @@ void psfile::gradientshade(bool axial, ColorSpace colorspace,
const pen& penb, const pair& b, double rb)
{
checkLevel();
+ endclip(pena);
+
setopacity(pena);
checkColorSpace(colorspace);
@@ -377,10 +375,13 @@ void psfile::gradientshade(bool axial, ColorSpace colorspace,
<< "shfill" << newl;
}
-void psfile::gouraudshade(const array& pens, const array& vertices,
+void psfile::gouraudshade(const pen& pentype,
+ const array& pens, const array& vertices,
const array& edges)
{
checkLevel();
+ endclip(pentype);
+
size_t size=pens.size();
if(size == 0) return;
@@ -417,10 +418,12 @@ void psfile::vertexpen(array *pi, int j, ColorSpace colorspace)
}
// Tensor-product patch shading
-void psfile::tensorshade(const array& pens, const array& boundaries,
- const array& z)
+void psfile::tensorshade(const pen& pentype, const array& pens,
+ const array& boundaries, const array& z)
{
checkLevel();
+ endclip(pentype);
+
size_t size=pens.size();
if(size == 0) return;
size_t nz=z.size();
@@ -483,15 +486,6 @@ void psfile::tensorshade(const array& pens, const array& boundaries,
<< "shfill" << newl;
}
-inline unsigned char byte(double r) // Map [0,1] to [0,255]
-{
- if(r < 0.0) r=0.0;
- else if(r > 1.0) r=1.0;
- int a=(int)(256.0*r);
- if(a == 256) a=255;
- return a;
-}
-
void psfile::write(pen *p, size_t ncomponents)
{
switch(ncomponents) {
@@ -515,32 +509,6 @@ void psfile::write(pen *p, size_t ncomponents)
}
}
-void psfile::writeHex(pen *p, size_t ncomponents)
-{
- switch(ncomponents) {
- case 0:
- break;
- case 1:
- write2(byte(p->gray()));
- writenewl();
- break;
- case 3:
- write2(byte(p->red()));
- write2(byte(p->green()));
- write2(byte(p->blue()));
- writenewl();
- break;
- case 4:
- write2(byte(p->cyan()));
- write2(byte(p->magenta()));
- write2(byte(p->yellow()));
- write2(byte(p->black()));
- writenewl();
- default:
- break;
- }
-}
-
string filter()
{
return settings::getSetting<Int>("level") >= 3 ?