Tree @688050c8-00bf-45cb-bdde-85796de4622a/main (Download .tar.gz)
- base
- build-scripts
- debian
- doc
- examples
- GL
- gl-matrix-2.4.0-pruned
- GUI
- patches
- prc
- tests
- webgl
- absyn.cc
- absyn.h
- access.cc
- access.h
- align.h
- angle.h
- application.cc
- application.h
- array.cc
- array.h
- arrayop.h
- aspy.py
- asy-keywords.el
- asy-list.pl
- asy.ico
- asy.rc
- asymptote.nsi
- asymptote.spec
- autogen.sh
- ax_pthread.m4
- bbox.h
- bbox3.h
- beziercurve.cc
- beziercurve.h
- bezierpatch.cc
- bezierpatch.h
- BUGS
- builtin.cc
- builtin.h
- callable.cc
- callable.h
- camp.l
- camp.tab.cc
- camp.tab.h
- camp.y
- camperror.cc
- camperror.h
- castop.h
- cc-mode2.el
- ChangeLog
- coder.cc
- coder.h
- coenv.cc
- coenv.h
- common.h
- config.guess
- config.h.in
- config.sub
- configure
- configure.ac
- constructor.cc
- dec.cc
- dec.h
- Delaunay.cc
- Delaunay.h
- drawclipbegin.h
- drawclipend.h
- drawelement.h
- drawfill.cc
- drawfill.h
- drawgrestore.h
- drawgroup.h
- drawgsave.h
- drawimage.h
- drawlabel.cc
- drawlabel.h
- drawlayer.h
- drawpath.cc
- drawpath.h
- drawpath3.cc
- drawpath3.h
- drawsurface.cc
- drawsurface.h
- drawverbatim.h
- entry.cc
- entry.h
- env.cc
- env.h
- envcompleter.cc
- envcompleter.h
- EnvVarUpdate.nsh
- errormsg.cc
- errormsg.h
- errors
- errortest.asy
- exp.cc
- exp.h
- fftw++.cc
- fftw++.h
- fftw++asy.cc
- fileio.cc
- fileio.h
- findsym.pl
- flatguide.cc
- flatguide.h
- fpu.h
- frame.h
- fundec.cc
- fundec.h
- gc-8.0.4.tar.gz
- genv.cc
- genv.h
- getopt.c
- getopt.h
- getopt1.c
- glew.c
- glrender.cc
- glrender.h
- gsl.cc
- guide.cc
- guide.h
- guideflags.h
- impdatum.cc
- inst.h
- INSTALL
- install-sh
- interact.cc
- interact.h
- item.h
- jsfile.cc
- jsfile.h
- keywords.cc
- keywords.pl
- knot.cc
- knot.h
- lex.yy.cc
- lexical.h
- libatomic_ops-7.6.10.tar.gz
- LICENSE
- LICENSE.LESSER
- lnkX64IconFix.nsh
- locate.cc
- locate.h
- main.cc
- Makefile.in
- material.h
- mathop.h
- memory.h
- mod.h
- modifier.h
- name.cc
- name.h
- newexp.cc
- newexp.h
- opcodes.h
- opsymbols.pl
- pair.h
- parser.cc
- parser.h
- path.cc
- path.h
- path3.cc
- path3.h
- pen.cc
- pen.h
- picture.cc
- picture.h
- pipestream.cc
- pipestream.h
- Pipfile
- policy.h
- prcfile.h
- predicates.cc
- predicates.h
- primitives.h
- process.cc
- process.h
- profile.py
- profiler.h
- program.cc
- program.h
- psfile.cc
- psfile.h
- README
- record.cc
- record.h
- refaccess.cc
- refaccess.h
- ReleaseNotes
- revision.cc
- rounding.h
- runarray.cc
- runarray.h
- runarray.in
- runbacktrace.cc
- runbacktrace.h
- runbacktrace.in
- runfile.cc
- runfile.h
- runfile.in
- runhistory.cc
- runhistory.h
- runhistory.in
- runlabel.cc
- runlabel.h
- runlabel.in
- runmath.cc
- runmath.h
- runmath.in
- runpair.cc
- runpair.h
- runpair.in
- runpath.cc
- runpath.h
- runpath.in
- runpath3d.cc
- runpath3d.h
- runpath3d.in
- runpicture.cc
- runpicture.h
- runpicture.in
- runstring.cc
- runstring.h
- runstring.in
- runsystem.cc
- runsystem.h
- runsystem.in
- runtime.cc
- runtime.h
- runtime.in
- runtime.pl
- runtimebase.in
- runtriple.cc
- runtriple.h
- runtriple.in
- seconds.h
- settings.cc
- settings.h
- shaders.cc
- shaders.h
- simpson.cc
- stack.cc
- stack.h
- statistics.h
- stm.cc
- stm.h
- symbol.cc
- symbol.h
- table.h
- texfile.cc
- texfile.h
- TODO
- tr.cc
- tr.h
- transform.h
- triple.h
- types.cc
- types.h
- util.cc
- util.h
- varinit.cc
- varinit.h
- virtualfieldaccess.cc
- virtualfieldaccess.h
- vm.h
- wce
- xstream.h
drawpath.cc @688050c8-00bf-45cb-bdde-85796de4622a/main — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | /***** * drawpath.cc * Andy Hammerlindl 2002/06/06 * * Stores a path that has been added to a picture. *****/ #include <sstream> #include <vector> #include <cfloat> #include "drawpath.h" #include "psfile.h" #include "util.h" using vm::array; using vm::read; namespace camp { double PatternLength(double arclength, const array& pat, bool cyclic, double penwidth) { double sum=0.0; size_t n=pat.size(); for(unsigned i=0; i < n; i ++) sum += read<double>(pat,i)*penwidth; if(sum == 0.0) return 0.0; if(n % 2 == 1) sum *= 2.0; // On/off pattern repeats after 2 cycles. double pat0=read<double>(pat,0); // Fix bounding box resolution problem. Example: // asy -f pdf testlinetype; gv -scale -2 testlinetype.pdf if(!cyclic && pat0 == 0) sum += 1.0e-3*penwidth; double terminator=(cyclic && arclength >= 0.5*sum) ? 0.0 : pat0*penwidth; int ncycle=(int)((arclength-terminator)/sum+0.5); return (ncycle >= 1 || terminator >= 0.75*arclength) ? ncycle*sum+terminator : 0.0; } bool isdashed(pen& p) { const LineType *linetype=p.linetype(); size_t n=linetype->pattern.size(); return n > 0; } pen adjustdash(pen& p, double arclength, bool cyclic) { pen q=p; // Adjust dash sizes to fit arclength; also compensate for linewidth. const LineType *linetype=q.linetype(); size_t n=linetype->pattern.size(); if(n > 0) { double penwidth=linetype->scale ? q.width() : 1.0; double factor=penwidth; if(linetype->adjust && arclength) { double denom=PatternLength(arclength,linetype->pattern,cyclic,penwidth); if(denom != 0.0) factor *= arclength/denom; } if(factor != 1.0) q.adjust(max(factor,0.1)); } return q; } // Account for square or extended pen cap contributions to bounding box. void cap(bbox& b, double t, path p, pen pentype) { transform T=pentype.getTransform(); double h=0.5*pentype.width(); pair v=p.dir(t); transform S=rotate(conj(v))*shiftless(T); double xx=S.getxx(), xy=S.getxy(); double yx=S.getyx(), yy=S.getyy(); double y=hypot(yx,yy); if(y == 0) return; double numer=xx*yx+xy*yy; double x=numer/y; pair z=shift(T)*p.point(t); switch(pentype.cap()) { case 0: { pair d=rotate(v)*pair(x,y)*h; b += z+d; b += z-d; break; } case 2: { transform R=rotate(v); double w=(xx*yy-xy*yx)/y; pair dp=R*pair(x+w,y)*h; pair dm=R*pair(x-w,y)*h; b += z+dp; b += z+dm; b += z-dp; b += z-dm; break; } } } void drawPathPenBase::strokebounds(bbox& b, const path& p) { Int l=p.length(); if(l < 0) return; bbox penbounds=pentype.bounds(); if(cyclic() || pentype.cap() == 1) { b += pad(p.bounds(),penbounds); return; } b += p.internalbounds(penbounds); cap(b,0,p,pentype); cap(b,l,p,pentype); } bool drawPath::draw(psfile *out) { Int n = p.size(); if (n == 0 || pentype.invisible()) return true; pen q=isdashed(pentype) ? adjustdash(pentype, p.transformed(inverse(pentype.getTransform())).arclength(), p.cyclic()) : pentype; penSave(out); penTranslate(out); if(n > 1) out->write(p); else out->dot(p,q); penConcat(out); out->setpen(q); out->stroke(q,n == 1); penRestore(out); return true; } drawElement *drawPath::transformed(const transform& t) { return new drawPath(transpath(t),transpen(t),KEY); } } //namespace camp |