diff options
author | Karl Berry <karl@freefriends.org> | 2009-09-29 14:00:37 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-09-29 14:00:37 +0000 |
commit | 93b70a6b5bf985b86b936248e34c810edfb1ebcb (patch) | |
tree | e3aef4bed05158dc1a5cdd4178fc531bdf4f04b3 /Master/texmf/asymptote | |
parent | d80f6a20d7b907ac933f687a7a0f1fd100a219f8 (diff) |
asy 1.87
git-svn-id: svn://tug.org/texlive/trunk@15555 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf/asymptote')
-rwxr-xr-x | Master/texmf/asymptote/GUI/xasyVersion.py | 2 | ||||
-rw-r--r-- | Master/texmf/asymptote/asy-mode.el | 157 | ||||
-rw-r--r-- | Master/texmf/asymptote/embed.asy | 5 | ||||
-rw-r--r-- | Master/texmf/asymptote/external.asy | 2 | ||||
-rw-r--r-- | Master/texmf/asymptote/geometry.asy | 1 | ||||
-rw-r--r-- | Master/texmf/asymptote/graph.asy | 73 | ||||
-rw-r--r-- | Master/texmf/asymptote/graph3.asy | 6 | ||||
-rw-r--r-- | Master/texmf/asymptote/grid3.asy | 1 | ||||
-rw-r--r-- | Master/texmf/asymptote/markers.asy | 1 | ||||
-rw-r--r-- | Master/texmf/asymptote/palette.asy | 22 | ||||
-rw-r--r-- | Master/texmf/asymptote/plain_picture.asy | 2 | ||||
-rw-r--r-- | Master/texmf/asymptote/plain_shipout.asy | 5 | ||||
-rw-r--r-- | Master/texmf/asymptote/slide.asy | 16 | ||||
-rw-r--r-- | Master/texmf/asymptote/three.asy | 220 | ||||
-rw-r--r-- | Master/texmf/asymptote/three_surface.asy | 32 | ||||
-rw-r--r-- | Master/texmf/asymptote/trembling.asy | 1 | ||||
-rw-r--r-- | Master/texmf/asymptote/tube.asy | 1 | ||||
-rw-r--r-- | Master/texmf/asymptote/version.asy | 2 |
18 files changed, 360 insertions, 189 deletions
diff --git a/Master/texmf/asymptote/GUI/xasyVersion.py b/Master/texmf/asymptote/GUI/xasyVersion.py index bce81122205..9c236521c06 100755 --- a/Master/texmf/asymptote/GUI/xasyVersion.py +++ b/Master/texmf/asymptote/GUI/xasyVersion.py @@ -1,2 +1,2 @@ #!/usr/bin/env python -xasyVersion = "1.86" +xasyVersion = "1.87-r15549" diff --git a/Master/texmf/asymptote/asy-mode.el b/Master/texmf/asymptote/asy-mode.el index ac31d8555eb..7ccdfdf1197 100644 --- a/Master/texmf/asymptote/asy-mode.el +++ b/Master/texmf/asymptote/asy-mode.el @@ -2,8 +2,8 @@ ;; Copyright (C) 2006-8 ;; Author: Philippe IVALDI 20 August 2006 +;; http://www.piprime.fr/ ;; Modified by: John Bowman -;; Last modification: 05 December 2008 (P. Ivaldi) ;; ;; This program is free software ; you can redistribute it and/or modify ;; it under the terms of the GNU Lesser General Public License as published by @@ -43,7 +43,7 @@ ;; ;; See also paragraph II of the documentation below to automate asy-insinuate-latex. -(defvar asy-mode-version "1.5") +(defvar asy-mode-version "1.6") ;;;###autoload (define-derived-mode asy-mode objc-mode "Asymptote" @@ -75,11 +75,11 @@ Note that some keys binding are added to the LaTeX-mode-map in lasy-mode if the II. To add a menu bar in current 'latex-mode' buffer and activate hot keys, use 'M-x asy-insinuate-latex <RET>'. You can automate this feature for all the 'latex-mode' buffers by inserting the five following lines in your .emacs initialization file: - (eval-after-load \"latex\" - '(progn - ;; Add here your personal features for 'latex-mode': - (asy-insinuate-latex t) ;; Asymptote globally insinuates Latex. - )) +(eval-after-load \"latex\" + '(progn + ;; Add here your personal features for 'latex-mode': + (asy-insinuate-latex t) ;; Asymptote globally insinuates Latex. + )) You can access this help within Emacs by the key binding C-h f asy-mode <RET> @@ -687,6 +687,24 @@ the current mode." (defun lasy-mode () "Treat, in some cases, the current buffer as a literal Asymptote program." (interactive) + (save-excursion + (let ((prefix + (progn + (goto-char (point-max)) + (re-search-backward "^\\([^\n]+\\)Local Variables:" + (- (point-max) 3000) t) + (match-string 1))) + (pos-b (point))) + (when + (and prefix + (progn + (re-search-forward (regexp-quote + (concat prefix + "End:")) (point-max) t) + (re-search-backward (concat "\\(" prefix "mode: .*\\)") pos-b t)) + ) + (error (concat "lasy-mode can not work if a mode is specified as local file variable. +You should remove the line " (int-to-string (line-number-at-pos))))))) (set (make-local-variable 'asy-insinuate-latex-p) asy-insinuate-latex-p) (make-local-variable 'lasy-fontify-asy-p) (when (< emacs-major-version 22) @@ -724,6 +742,7 @@ the current mode." (when (< emacs-major-version 22) (setq font-lock-keywords-only t)) )))) + ;; (setq two-mode-switch-hook nil) ;; Solve a problem restoring a TeX file via desktop.el previously in lasy-mode. (if (boundp 'desktop-buffer-mode-handlers) @@ -935,16 +954,16 @@ is in a asy environnement." ["PS" asy-master-tex-view-ps-f :active t] ["PDF (pdflatex)" asy-master-tex-view-pdflatex-f :active t] ["PDF (ps2pdf)" asy-master-tex-view-ps2pdf-f :active t])"--" - ["Asymptote insinuates globally LaTeX" asy-insinuate-latex-globally :active (not asy-insinuate-latex-globally-p)] - ("Disable Asymptote insinuate Latex" - ["locally" asy-no-insinuate-locally :active t] - ["globally" asy-no-insinuate-globally :active t]) - ("Debugger Buffer" - ["Visible" (setq asy-compilation-buffer 'visible) :style radio :selected (eq asy-compilation-buffer 'visible) :active t] - ["Available" (setq asy-compilation-buffer 'available) :style radio :selected (eq asy-compilation-buffer 'available) :active t] - ["None" (setq asy-compilation-buffer 'none) :style radio :selected (eq asy-compilation-buffer 'none) :active t] - ["Never" (setq asy-compilation-buffer 'never) :style radio :selected (eq asy-compilation-buffer 'never) :active t]) - )) + ["Asymptote insinuates globally LaTeX" asy-insinuate-latex-globally :active (not asy-insinuate-latex-globally-p)] + ("Disable Asymptote insinuate Latex" + ["locally" asy-no-insinuate-locally :active t] + ["globally" asy-no-insinuate-globally :active t]) + ("Debugger Buffer" + ["Visible" (setq asy-compilation-buffer 'visible) :style radio :selected (eq asy-compilation-buffer 'visible) :active t] + ["Available" (setq asy-compilation-buffer 'available) :style radio :selected (eq asy-compilation-buffer 'available) :active t] + ["None" (setq asy-compilation-buffer 'none) :style radio :selected (eq asy-compilation-buffer 'none) :active t] + ["Never" (setq asy-compilation-buffer 'never) :style radio :selected (eq asy-compilation-buffer 'never) :active t]) + )) (if running-xemacs-p (setq asy-latex-menu-item (nconc '("Asymptote") asy-latex-menu-item)) (setq asy-latex-menu-item (nconc '("Asymptote" :visible asy-insinuate-latex-p) asy-latex-menu-item))) @@ -971,6 +990,23 @@ For internal use only." (add-hook 'LaTeX-mode-hook 'asy-insinuate-latex-maybe) (setq lasy-mode-map (copy-keymap LaTeX-mode-map)) (setq LaTeX-mode-map-backup (copy-keymap LaTeX-mode-map)) + + (defadvice TeX-add-local-master (after asy-adjust-local-variable ()) + "Delete the line that defines the mode in a file .tex because two-mode-mode reread +the local variables after switching mode." + (when (string= (file-name-extension buffer-file-name) "tex") + (save-excursion + (goto-char (point-max)) + (delete-matching-lines + "mode: latex" + (re-search-backward "^\\([^\n]+\\)Local Variables:" + (- (point-max) 3000) t) + (re-search-forward (regexp-quote + (concat (match-string 1) + "End:"))) nil)))) + (ad-activate 'TeX-add-local-master) + ;; (ad-deactivate 'TeX-add-local-master) + (when lasy-extra-key (define-key lasy-mode-map (kbd "<C-return>") (lambda () @@ -1135,7 +1171,7 @@ See `asy-insinuate-latex'." ""))) (defun lasy-compile-tex() - "Compile region between \\begin{asy}[text with backslash] and \\end{asy} passing by a reconstructed file .tex." + "Compile region between \\begin{asy}[text with backslash] and \\end{asy} through a reconstructed file .tex." (interactive) (setq lasy-run-tex t) (save-excursion @@ -1400,6 +1436,20 @@ In Windows the associated system file type is used instead." (start-process "" nil command Filename) (call-process-shell-command command nil 0)))) +(defun lasy-TeX-master-file () + "Return the file name of the master file for the current document. +The returned string contain the directory but does not contain the extension of the file." + (expand-file-name + (concat (TeX-master-directory) (TeX-master-file nil t)))) + +(defun lasy-must-compile-p (TeX-Master-File out-file &optional Force) + "" + (or Force + (file-newer-than-file-p + (concat TeX-Master-File ".tex") out-file) + (and (stringp (TeX-master-file)) ;; current buffer is not a mater tex file + (file-newer-than-file-p buffer-file-name out-file)))) + (defun lasy-view-ps (&optional Force Filename fromtex) "Compile a LaTeX document embedding Asymptote code with latex->asy->latex->dvips and/or view the PostScript output. If optional argument Force is t then force compilation." @@ -1407,27 +1457,26 @@ If optional argument Force is t then force compilation." (setq lasy-run-tex t) (setq lasy-compile-tex fromtex) (if (buffer-modified-p) (save-buffer)) + (when (eq asy-compilation-buffer 'never) (write-region "" 0 (asy-log-filename) nil)) (let* - ((b-b-n (if Filename Filename (file-name-sans-extension buffer-file-name))) + ((b-b-n (if Filename Filename (lasy-TeX-master-file))) (b-b-n-tex (asy-protect-file-name (concat b-b-n ".tex"))) (b-b-n-ps (asy-protect-file-name (concat b-b-n ".ps"))) (b-b-n-dvi (asy-protect-file-name (concat b-b-n ".dvi"))) (b-b-n-asy (asy-protect-file-name (concat b-b-n ".asy"))) (stderr (eq asy-compilation-buffer 'never))) - (if (or (file-newer-than-file-p - (concat b-b-n ".tex") - (concat b-b-n ".ps")) - Force) + (if (lasy-must-compile-p b-b-n (concat b-b-n ".ps") Force) (progn - (asy-internal-compile (concat lasy-latex-command " " b-b-n-tex)) - (when (and (zerop asy-last-compilation-code) (file-readable-p (concat b-b-n ".asy"))) - (asy-internal-compile (concat asy-command-location lasy-command " " b-b-n-asy) nil nil stderr) - (when (zerop asy-last-compilation-code) - (asy-internal-compile (concat lasy-latex-command " " b-b-n-tex)))) - (when (zerop asy-last-compilation-code) - (asy-internal-compile (concat lasy-dvips-command " " b-b-n-dvi " -o " b-b-n-ps) nil t) + (let ((default-directory (file-name-directory b-b-n))) + (asy-internal-compile (concat lasy-latex-command " " b-b-n-tex)) + (when (and (zerop asy-last-compilation-code) (file-readable-p (concat b-b-n ".asy"))) + (asy-internal-compile (concat asy-command-location lasy-command " " b-b-n-asy) nil nil stderr) + (when (zerop asy-last-compilation-code) + (asy-internal-compile (concat lasy-latex-command " " b-b-n-tex)))) (when (zerop asy-last-compilation-code) - (asy-open-file (concat b-b-n ".ps"))))) + (asy-internal-compile (concat lasy-dvips-command " " b-b-n-dvi " -o " b-b-n-ps) nil t) + (when (zerop asy-last-compilation-code) + (asy-open-file (concat b-b-n ".ps")))))) (asy-open-file (concat b-b-n ".ps"))))) (defun lasy-view-pdf-via-pdflatex (&optional Force Filename fromtex) @@ -1439,24 +1488,22 @@ If optional argument Force is t then force compilation." (if (buffer-modified-p) (save-buffer)) (when (eq asy-compilation-buffer 'never) (write-region "" 0 (asy-log-filename) nil)) (let* - ((b-b-n (if Filename Filename (file-name-sans-extension buffer-file-name))) + ((b-b-n (if Filename Filename (lasy-TeX-master-file))) (b-b-n-tex (asy-protect-file-name (concat b-b-n ".tex"))) (b-b-n-pdf (asy-protect-file-name (concat b-b-n ".pdf"))) (b-b-n-asy (asy-protect-file-name (concat b-b-n ".asy"))) ;; (stderr (or (eq asy-compilation-buffer 'never) lasy-compile-tex))) (stderr (eq asy-compilation-buffer 'never))) - (if (or (file-newer-than-file-p - (concat b-b-n ".tex") - (concat b-b-n ".pdf")) - Force) + (if (lasy-must-compile-p b-b-n (concat b-b-n ".pdf") Force) (progn - (asy-internal-compile (concat lasy-pdflatex-command " " b-b-n-tex)) - (when (and (zerop asy-last-compilation-code) (file-readable-p (concat b-b-n ".asy"))) - (asy-internal-compile (concat asy-command-location lasy-command " " b-b-n-asy) nil nil stderr) + (let ((default-directory (file-name-directory b-b-n))) + (asy-internal-compile (concat lasy-pdflatex-command " " b-b-n-tex)) + (when (and (zerop asy-last-compilation-code) (file-readable-p (concat b-b-n ".asy"))) + (asy-internal-compile (concat asy-command-location lasy-command " " b-b-n-asy) nil nil stderr) + (when (zerop asy-last-compilation-code) + (asy-internal-compile (concat lasy-pdflatex-command " " b-b-n-tex) t))) (when (zerop asy-last-compilation-code) - (asy-internal-compile (concat lasy-pdflatex-command " " b-b-n-tex) t))) - (when (zerop asy-last-compilation-code) - (asy-open-file (concat b-b-n ".pdf")))) + (asy-open-file (concat b-b-n ".pdf"))))) (asy-open-file (concat b-b-n ".pdf"))))) (defun lasy-view-pdf-via-ps2pdf (&optional Force Filename fromtex) @@ -1468,7 +1515,7 @@ If optional argument Force is t then force compilation." (if (buffer-modified-p) (save-buffer)) (when (eq asy-compilation-buffer 'never) (write-region "" 0 (asy-log-filename) nil)) (let* - ((b-b-n (if Filename Filename (file-name-sans-extension buffer-file-name))) + ((b-b-n (if Filename Filename (lasy-TeX-master-file))) (b-b-n-tex (asy-protect-file-name (concat b-b-n ".tex"))) (b-b-n-ps (asy-protect-file-name (concat b-b-n ".ps"))) (b-b-n-dvi (asy-protect-file-name (concat b-b-n ".dvi"))) @@ -1476,22 +1523,20 @@ If optional argument Force is t then force compilation." (b-b-n-asy (asy-protect-file-name (concat b-b-n ".asy"))) ;; (stderr (or (eq asy-compilation-buffer 'never) lasy-compile-tex))) (stderr (eq asy-compilation-buffer 'never))) - (if (or (file-newer-than-file-p - (concat b-b-n ".tex") - (concat b-b-n ".pdf")) - Force) + (if (lasy-must-compile-p b-b-n (concat b-b-n ".pdf") Force) (progn - (asy-internal-compile (concat lasy-latex-command " " b-b-n-tex)) - (when (and (zerop asy-last-compilation-code) (file-readable-p (concat b-b-n ".asy"))) - (asy-internal-compile (concat asy-command-location lasy-command " " b-b-n-asy) nil nil stderr) - (when (zerop asy-last-compilation-code) - (asy-internal-compile (concat lasy-latex-command " " b-b-n-tex)))) - (when (zerop asy-last-compilation-code) - (asy-internal-compile (concat lasy-dvips-pre-pdf-command " " b-b-n-dvi " -o " b-b-n-ps)) + (let ((default-directory (file-name-directory b-b-n))) + (asy-internal-compile (concat lasy-latex-command " " b-b-n-tex)) + (when (and (zerop asy-last-compilation-code) (file-readable-p (concat b-b-n ".asy"))) + (asy-internal-compile (concat asy-command-location lasy-command " " b-b-n-asy) nil nil stderr) + (when (zerop asy-last-compilation-code) + (asy-internal-compile (concat lasy-latex-command " " b-b-n-tex)))) (when (zerop asy-last-compilation-code) - (asy-internal-compile (concat lasy-ps2pdf-command " " b-b-n-ps " " b-b-n-pdf) t) + (asy-internal-compile (concat lasy-dvips-pre-pdf-command " " b-b-n-dvi " -o " b-b-n-ps)) (when (zerop asy-last-compilation-code) - (asy-open-file (concat b-b-n ".pdf")))))) + (asy-internal-compile (concat lasy-ps2pdf-command " " b-b-n-ps " " b-b-n-pdf) t) + (when (zerop asy-last-compilation-code) + (asy-open-file (concat b-b-n ".pdf"))))))) (asy-open-file (concat b-b-n ".pdf"))))) ;; Goto error of last compilation diff --git a/Master/texmf/asymptote/embed.asy b/Master/texmf/asymptote/embed.asy index 5695eadab56..ac8a09acb83 100644 --- a/Master/texmf/asymptote/embed.asy +++ b/Master/texmf/asymptote/embed.asy @@ -4,9 +4,8 @@ if(latex()) { \usepackage[3D,dvipdfmx]{movie15} \else% \usepackage[3D]{movie15} -\fi% -"); - usepackage("hyperref","setpagesize=false,unicode"); +\fi%"); +usepackage("hyperref",settings.hyperrefOptions); } // See http://www.ctan.org/tex-archive/macros/latex/contrib/movie15/README diff --git a/Master/texmf/asymptote/external.asy b/Master/texmf/asymptote/external.asy index 5573561fc36..9560e319299 100644 --- a/Master/texmf/asymptote/external.asy +++ b/Master/texmf/asymptote/external.asy @@ -1,4 +1,4 @@ -usepackage("hyperref","setpagesize=false,unicode"); +usepackage("hyperref",settings.hyperrefOptions); // Embed object to be run in an external window. An image file name can be // specified; if not given one will be automatically generated. diff --git a/Master/texmf/asymptote/geometry.asy b/Master/texmf/asymptote/geometry.asy index 0db3172d365..3d9d84563b7 100644 --- a/Master/texmf/asymptote/geometry.asy +++ b/Master/texmf/asymptote/geometry.asy @@ -2,6 +2,7 @@ // Copyright (C) 2007 // Author: Philippe IVALDI 2007/09/01 +// http://www.piprime.fr/ // This program is free software ; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by diff --git a/Master/texmf/asymptote/graph.asy b/Master/texmf/asymptote/graph.asy index 55974c63f7d..e9f01880d67 100644 --- a/Master/texmf/asymptote/graph.asy +++ b/Master/texmf/asymptote/graph.asy @@ -609,38 +609,40 @@ tickvalues generateticks(int sign, Label F="", ticklabel ticklabel=null, if(divisor.length > 0) { bool autoscale=locate.S.automin && locate.S.automax; real h=0.5*(b-a); - for(int d=divisor.length-1; d >= 0; --d) { - int N0=divisor[d]; - Step=len/N0; - int N1=N0; - int m=2; - while(Step > h) { - N0=m*N1; + if(h > 0) { + for(int d=divisor.length-1; d >= 0; --d) { + int N0=divisor[d]; Step=len/N0; - m *= 2; - } - if(axiscoverage(N0,T,g,locate,Step,side,sign,Size,F,ticklabel,norm, - limit)) { - N=N0; - if(N0 == 1 && !autoscale && d < divisor.length-1) { - // Try using 2 ticks (otherwise 1); - int div=divisor[d+1]; - Step=quotient(div,2)*len/div; - calcStep=false; - if(axiscoverage(2,T,g,locate,Step,side,sign,Size,F,ticklabel, - norm,limit)) N=2; - else Step=len; + int N1=N0; + int m=2; + while(Step > h) { + N0=m*N1; + Step=len/N0; + m *= 2; } - // Found a good divisor; now compute subtick divisor - if(n == 0) { - if(step != 0) n=ceil(Step/step); - else { - n=quotient(divisor[divisor.length-1],N); - if(N == 1) n=(a*b >= 0) ? 2 : 1; - if(n == 1) n=2; + if(axiscoverage(N0,T,g,locate,Step,side,sign,Size,F,ticklabel,norm, + limit)) { + N=N0; + if(N0 == 1 && !autoscale && d < divisor.length-1) { + // Try using 2 ticks (otherwise 1); + int div=divisor[d+1]; + Step=quotient(div,2)*len/div; + calcStep=false; + if(axiscoverage(2,T,g,locate,Step,side,sign,Size,F,ticklabel, + norm,limit)) N=2; + else Step=len; + } + // Found a good divisor; now compute subtick divisor + if(n == 0) { + if(step != 0) n=ceil(Step/step); + else { + n=quotient(divisor[divisor.length-1],N); + if(N == 1) n=(a*b >= 0) ? 2 : 1; + if(n == 1) n=2; + } } + break; } - break; } } } @@ -826,12 +828,17 @@ tickvalues None(tickvalues v) {return v;} tickmodifier OmitTick(... real[] x) { return new tickvalues(tickvalues v) { - if(v.major.length == 0) return v; - real norm=max(abs(v.major)); - for(int i=0; i < x.length; ++i) { - int j=find(abs(v.major-x[i]) < zerotickfuzz*norm); - if(j >= 0) v.major.delete(j); + void omit(real[] a) { + if(a.length != 0) { + real norm=max(abs(a)); + for(int i=0; i < x.length; ++i) { + int j=find(abs(a-x[i]) < zerotickfuzz*norm); + if(j >= 0) a.delete(j); + } + } } + omit(v.major); + omit(v.minor); return v; }; } diff --git a/Master/texmf/asymptote/graph3.asy b/Master/texmf/asymptote/graph3.asy index c2630e10f11..1357f3e7c87 100644 --- a/Master/texmf/asymptote/graph3.asy +++ b/Master/texmf/asymptote/graph3.asy @@ -1572,8 +1572,10 @@ surface surface(triple[][] f, bool[][] cond={}) } } - if(uperiodic(f)) s.ucyclic(true); - if(vperiodic(f)) s.vcyclic(true); + if(count == nx*ny) { + if(uperiodic(f)) s.ucyclic(true); + if(vperiodic(f)) s.vcyclic(true); + } return s; } diff --git a/Master/texmf/asymptote/grid3.asy b/Master/texmf/asymptote/grid3.asy index dcb220e0746..afd621eb741 100644 --- a/Master/texmf/asymptote/grid3.asy +++ b/Master/texmf/asymptote/grid3.asy @@ -1,5 +1,6 @@ // grid3.asy // Author: Philippe Ivaldi (Grids in 3D) +// http://www.piprime.fr/ // Created: 10 janvier 2007 import graph3; diff --git a/Master/texmf/asymptote/markers.asy b/Master/texmf/asymptote/markers.asy index 3fef6eb2d6c..84adc8e6cf6 100644 --- a/Master/texmf/asymptote/markers.asy +++ b/Master/texmf/asymptote/markers.asy @@ -1,4 +1,5 @@ // Mark routines and markers written by Philippe Ivaldi. +// http://www.piprime.fr/ marker operator * (transform T, marker m) { diff --git a/Master/texmf/asymptote/palette.asy b/Master/texmf/asymptote/palette.asy index e9d3fb921db..fabbdc2cd5b 100644 --- a/Master/texmf/asymptote/palette.asy +++ b/Master/texmf/asymptote/palette.asy @@ -45,15 +45,19 @@ pen[] adjust(picture pic, real min, real max, real rmin, real rmax, { real dmin=pic.scale.z.T(min); real dmax=pic.scale.z.T(max); - int minindex=floor((dmin-rmin)/(rmax-rmin)*palette.length); - if(minindex < 0) minindex=0; - int maxindex=floor((dmax-rmin)/(rmax-rmin)*palette.length); - if(maxindex > palette.length) maxindex=palette.length; - if(minindex > 0 || maxindex < palette.length) { - pen[] newpalette; - for(int i=minindex; i < maxindex; ++i) - newpalette.push(palette[i]); - return newpalette; + real delta=rmax-rmin; + if(delta > 0) { + real factor=palette.length/delta; + int minindex=floor(factor*(dmin-rmin)); + if(minindex < 0) minindex=0; + int maxindex=floor(factor*(dmax-rmin)); + if(maxindex > palette.length) maxindex=palette.length; + if(minindex > 0 || maxindex < palette.length) { + pen[] newpalette; + for(int i=minindex; i < maxindex; ++i) + newpalette.push(palette[i]); + return newpalette; + } } return palette; } diff --git a/Master/texmf/asymptote/plain_picture.asy b/Master/texmf/asymptote/plain_picture.asy index 432a4a6ae6d..e13120a198c 100644 --- a/Master/texmf/asymptote/plain_picture.asy +++ b/Master/texmf/asymptote/plain_picture.asy @@ -399,7 +399,7 @@ struct transformation { oblique=false; } transform3 compute() { - return projection*modelview; + return infinity ? modelview : projection*modelview; } transformation copy() { transformation T=new transformation; diff --git a/Master/texmf/asymptote/plain_shipout.asy b/Master/texmf/asymptote/plain_shipout.asy index 2e86822cad0..9691a8e2fcf 100644 --- a/Master/texmf/asymptote/plain_shipout.asy +++ b/Master/texmf/asymptote/plain_shipout.asy @@ -93,10 +93,11 @@ void shipout(string prefix=defaultfilename, picture pic=currentpicture, if(!uptodate()) { bool inlinetex=settings.inlinetex; bool prc=prc(format); - if(prc && !pic.empty3()) + bool empty3=pic.empty3(); + if(prc && !empty3) settings.inlinetex=settings.inlineimage; frame f=pic.fit(prefix,format,view=view,options,script,light,P); - if(!pic.empty2() || settings.render == 0 || prc) + if(!pic.empty2() || settings.render == 0 || prc || empty3) shipout(prefix,orientation(f),format,wait,view); settings.inlinetex=inlinetex; } diff --git a/Master/texmf/asymptote/slide.asy b/Master/texmf/asymptote/slide.asy index b23a352fc5d..579253b182f 100644 --- a/Master/texmf/asymptote/slide.asy +++ b/Master/texmf/asymptote/slide.asy @@ -18,11 +18,8 @@ bool landscape=orientation == Landscape || orientation == Seascape; if(landscape) { orientation=Portrait; - real temp=settings.paperwidth; - settings.paperwidth=settings.paperheight; - settings.paperheight=temp; - pagewidth += settings.paperwidth; - pageheight += settings.paperheight; + pagewidth += settings.paperheight; + pageheight += settings.paperwidth; } else { pagewidth += settings.paperwidth; pageheight += settings.paperheight; @@ -430,12 +427,13 @@ void multifigure(string[] slist, string options="", string caption="", firststep=false; } -void indexedfigure(string prefix, int n, string options="", string caption="", - pair align=S, pen p=itempen, pen figuremattpen=figuremattpen) +void indexedfigure(string prefix, int first, int last, + string options="", string caption="", + pair align=S, pen p=itempen, pen figuremattpen=figuremattpen) { string[] s; - for (int i=0; i<n; ++i) - s.push(prefix+"+"+string(i)); + for(int i=first; i <= last; ++i) + s.push(prefix+string(i)); multifigure(s, options, caption, align, p, figuremattpen); } diff --git a/Master/texmf/asymptote/three.asy b/Master/texmf/asymptote/three.asy index d79daf3586c..23a23223141 100644 --- a/Master/texmf/asymptote/three.asy +++ b/Master/texmf/asymptote/three.asy @@ -21,6 +21,15 @@ real rendermargin=0.02; string defaultembed3Doptions; string defaultembed3Dscript; +real defaulteyetoview=63mm/1000mm; + +string defaultlabelname="label"; +string Billboard=" "+defaultlabelname; + +string defaultlabelname() +{ + return settings.billboard ? Billboard : defaultlabelname; +} string partname(string s, int i=0) { @@ -245,9 +254,9 @@ projection orthographic(triple camera, triple up=Z, triple target=O, real zoom=1, pair viewportshift=0, bool showtarget=true, bool center=false) { - return projection(camera,up,target,zoom,viewportshift,showtarget,center=center, - new transformation(triple camera, triple up, - triple target) { + return projection(camera,up,target,zoom,viewportshift,showtarget, + center=center,new transformation(triple camera, triple up, + triple target) { return transformation(look(camera,up,target));}); } @@ -313,11 +322,24 @@ projection LeftView=orthographic(-X,showtarget=true); projection RightView=orthographic(X,showtarget=true); projection FrontView=orthographic(-Y,showtarget=true); projection BackView=orthographic(Y,showtarget=true); -projection BottomView=orthographic(-Z,showtarget=true); -projection TopView=orthographic(Z,showtarget=true); +projection BottomView=orthographic(-Z,up=-Y,showtarget=true); +projection TopView=orthographic(Z,up=Y,showtarget=true); currentprojection=perspective(5,4,2); +projection projection() +{ + projection P; + real[] a=_projection(); + if(a[10] == 0.0) return currentprojection; + int k=0; + return a[0] == 1 ? + orthographic((a[++k],a[++k],a[++k]),(a[++k],a[++k],a[++k]), + (a[++k],a[++k],a[++k]),a[++k],(a[k += 2],a[++k])) : + perspective((a[++k],a[++k],a[++k]),(a[++k],a[++k],a[++k]), + (a[++k],a[++k],a[++k]),a[++k],a[++k],(a[++k],a[++k])); +} + // Map pair z to a triple by inverting the projection P onto the // plane perpendicular to normal and passing through point. triple invert(pair z, triple normal, triple point, @@ -1040,9 +1062,14 @@ path3 invert(path p, triple normal, triple point, return path3(p,new triple(pair z) {return invert(z,normal,point,P);}); } +path3 invert(path p, triple point, projection P=currentprojection) +{ + return path3(p,new triple(pair z) {return invert(z,P.vector(),point,P);}); +} + path3 invert(path p, projection P=currentprojection) { - return path3(p,new triple(pair z) {return invert(z,P);}); + return path3(p,new triple(pair z) {return invert(z,P.vector(),P.target,P);}); } // Construct a path from a path3 by applying P to each control point. @@ -1763,11 +1790,11 @@ transform3 align(triple u) // return a rotation that maps X,Y to the projection plane. transform3 transform3(projection P=currentprojection) { - triple v=unit(P.oblique ? P.camera : P.vector()); - triple u=unit(perp(P.up,v)); - if(u == O) u=cross(perp(v),v); - v=cross(u,v); - return v != O ? transform3(v,u) : identity(4); + triple w=unit(P.oblique ? P.camera : P.vector()); + triple v=unit(perp(P.up,w)); + if(v == O) v=cross(perp(w),w); + triple u=cross(v,w); + return u != O ? transform3(u,v,w) : identity(4); } triple[] triples(real[] x, real[] y, real[] z) @@ -2133,14 +2160,16 @@ draw=new void(frame f, path3 g, material p=currentpen, void draw(frame f, explicit path3[] g, material p=currentpen, light light=nolight, string name="", projection P=currentprojection) { - for(int i=0; i < g.length; ++i) draw(f,g[i],p,light,name,P); + for(int i=0; i < g.length; ++i) + draw(f,g[i],p,light,partname(name,i),P); } void draw(picture pic=currentpicture, explicit path3[] g, material p=currentpen, margin3 margin=NoMargin3, light light=nolight, string name="") { - for(int i=0; i < g.length; ++i) draw(pic,g[i],p,margin,light,name); + for(int i=0; i < g.length; ++i) + draw(pic,g[i],p,margin,light,partname(name,i)); } include three_arrows; @@ -2365,6 +2394,7 @@ void writeJavaScript(string name, string preamble, string script) file out=output(name); write(out,preamble); if(script != "") { + write(out,endl); file in=input(script); while(true) { string line=in; @@ -2616,8 +2646,8 @@ object embed(string label="", string text=label, string prefix=defaultfilename, triple lambda=M-m; S.viewportmargin=viewportmargin((lambda.x,lambda.y)); - S.width=lambda.x+2*viewportmargin.x; - S.height=lambda.y+2*viewportmargin.y; + S.width=lambda.x+2*S.viewportmargin.x; + S.height=lambda.y+2*S.viewportmargin.y; S.f=shift((-0.5(m.x+M.x),-0.5*(m.y+M.y),0))*S.f; // Eye will be at (0,0,0) } else { if(P.angle == 0) { @@ -2797,54 +2827,119 @@ frame embedder(string prefix, frame f, string format, bool view, },prefix,format,view,light); } -void addViews(picture dest, picture src, bool group=true, - filltype filltype=NoFill) -{ - if(group) begingroup(dest); - frame Front=src.fit(FrontView); - add(dest,Front,filltype); - frame Top=src.fit(TopView); - add(dest,shift(0,min(Front).y-max(Top).y)*Top,filltype); - frame Right=src.fit(RightView); - add(dest,shift(min(Front).x-max(Right).x)*Right,filltype); - if(group) endgroup(dest); -} +projection[][] ThreeViewsUS={{TopView}, + {FrontView,RightView}}; -void addViews(picture src, bool group=true, filltype filltype=NoFill) -{ - addViews(currentpicture,src,group,filltype); -} +projection[][] SixViewsUS={{null,TopView}, + {LeftView,FrontView,RightView,BackView}, + {null,BottomView}}; -void addAllViews(picture dest, picture src, - real xmargin=0, real ymargin=xmargin, - bool group=true, - filltype filltype=NoFill) -{ - picture picL,picM,picR,picLM; - if(xmargin == 0) xmargin=sqrtEpsilon; - if(ymargin == 0) ymargin=sqrtEpsilon; +projection[][] ThreeViewsFR={{RightView,FrontView}, + {null,TopView}}; - add(picL,src.fit(FrontView),(0,0),ymargin*N); - add(picL,src.fit(BackView),(0,0),ymargin*S); +projection[][] SixViewsFR={{null,BottomView}, + {RightView,FrontView,LeftView,BackView}, + {null,TopView}}; - add(picM,src.fit(TopView),(0,0),ymargin*N); - add(picM,src.fit(BottomView),(0,0),ymargin*S); +projection[][] ThreeViews={{FrontView,TopView,RightView}}; - add(picR,src.fit(RightView),(0,0),ymargin*N); - add(picR,src.fit(LeftView),(0,0),ymargin*S); +projection[][] SixViews={{FrontView,TopView,RightView}, + {BackView,BottomView,LeftView}}; - add(picLM,picL.fit(),(0,0),xmargin*W); - add(picLM,picM.fit(),(0,0),xmargin*E); +void addViews(picture dest, picture src, projection[][] views=SixViewsUS, + bool group=true, filltype filltype=NoFill) +{ + frame[][] F=array(views.length,new frame[]); + pair[][] M=array(views.length,new pair[]); + pair[][] m=array(views.length,new pair[]); + + for(int i=0; i < views.length; ++i) { + projection[] viewsi=views[i]; + frame[] Fi=F[i]; + pair[] Mi=M[i]; + pair[] mi=m[i]; + for(projection P : viewsi) { + if(P != null) { + frame f=src.fit(P); + mi.push(min(f)); + Mi.push(max(f)); + Fi.push(f); + } else { + pair Infinity=(infinity,infinity); + mi.push(Infinity); + Mi.push(-Infinity); + Fi.push(newframe); + } + } + } + + real[] my=new real[views.length]; + real[] My=new real[views.length]; + + int Nj=0; + for(int i=0; i < views.length; ++i) { + my[i]=minbound(m[i]).y; + My[i]=maxbound(M[i]).y; + Nj=max(Nj,views[i].length); + } + + real[] mx=array(Nj,infinity); + real[] Mx=array(Nj,-infinity); + for(int i=0; i < views.length; ++i) { + pair[] mi=m[i]; + pair[] Mi=M[i]; + for(int j=0; j < views[i].length; ++j) { + mx[j]=min(mx[j],mi[j].x); + Mx[j]=max(Mx[j],Mi[j].x); + } + } if(group) begingroup(dest); - add(dest,picLM.fit(),(0,0),xmargin*W,filltype); - add(dest,picR.fit(),(0,0),xmargin*E,filltype); + + real y; + for(int i=0; i < views.length; ++i) { + real x; + pair[] mi=m[i]; + for(int j=0; j < views[i].length; ++j) { + if(size(F[i][j]) != 0) + add(dest,shift(x-mx[j],y+my[i])*F[i][j],filltype); + x += (Mx[j]-mx[j]); + } + y -= (My[i]-my[i]); + } + if(group) endgroup(dest); } -void addAllViews(picture src, bool group=true, filltype filltype=NoFill) +void addViews(picture src, projection[][] views=SixViewsUS, bool group=true, + filltype filltype=NoFill) { - addAllViews(currentpicture,src,group,filltype); + addViews(currentpicture,src,views,group,filltype); +} + +void addStereoViews(picture dest, picture src, bool group=true, + filltype filltype=NoFill, real eyetoview=defaulteyetoview, + bool leftright=true, projection P=currentprojection) +{ + triple v=P.vector(); + triple h=0.5*abs(v)*eyetoview*unit(cross(P.up,v)); + projection leftEye=P.copy(); + leftEye.camera -= h; + leftEye.calculate(); + projection rightEye=P.copy(); + rightEye.camera += h; + rightEye.calculate(); + addViews(dest,src,leftright ? + new projection[][] {{leftEye,rightEye}} : + new projection[][] {{rightEye,leftEye}},group,filltype); +} + +void addStereoViews(picture src, bool group=true, + filltype filltype=NoFill, + real eyetoview=defaulteyetoview, bool leftright=true, + projection P=currentprojection) +{ + addStereoViews(currentpicture,src,group,filltype,eyetoview,leftright,P); } // Fit an array of 3D pictures simultaneously using the sizing of picture all. @@ -2859,24 +2954,33 @@ frame[] fit3(string prefix="", picture[] pictures, picture all, triple M=all.max(S.t); out=new frame[pictures.length]; int i=0; - bool loop=settings.loop; + bool reverse=settings.reverse; + settings.animating=true; + for(picture pic : pictures) { picture pic2; frame f=pic.fit3(S.t,pic2,S.P); - if(loop && !settings.loop) break; + if(settings.interrupt) break; add(f,pic2.fit2()); draw(f,m,nullpen); draw(f,M,nullpen); - out[i]=loop ? f : embedder(prefix,f,format,view,options,script,light,S.P); + out[i]=f; ++i; } - while(settings.loop) - for(int i=0; i < pictures.length; ++i) { - if(!settings.loop) break; + while(!settings.interrupt) { + for(int i=settings.reverse ? pictures.length-1 : 0; + i >= 0 && i < pictures.length && !settings.interrupt; + settings.reverse ? --i : ++i) { embedder(prefix,out[i],format,view,options,script,light,S.P); - } + } + if(!settings.loop) break; + } + settings.animating=false; + settings.interrupt=false; + settings.reverse=reverse; + return out; } diff --git a/Master/texmf/asymptote/three_surface.asy b/Master/texmf/asymptote/three_surface.asy index 823e6e4b498..b60a9be6156 100644 --- a/Master/texmf/asymptote/three_surface.asy +++ b/Master/texmf/asymptote/three_surface.asy @@ -1130,8 +1130,8 @@ real PRCshininess(real shininess) return s(shininess); } -void draw3D(frame f, patch s, material m, light light=currentlight, - string name="") +void draw3D(frame f, patch s, triple center=O, material m, + light light=currentlight, string name="") { if(s.colors.length > 0) m=mean(s.colors); @@ -1142,8 +1142,8 @@ void draw3D(frame f, patch s, material m, light light=currentlight, if(prc()) PRCshininess=PRCshininess(m.shininess); real granularity=m.granularity >= 0 ? m.granularity : defaultgranularity; - draw(f,s.P,s.straight,m.p,m.opacity,m.shininess,PRCshininess,granularity, - s.planar ? s.normal(0.5,0.5) : O,s.colors,lighton,name); + draw(f,s.P,center,s.straight,m.p,m.opacity,m.shininess,PRCshininess, + granularity,s.planar ? s.normal(0.5,0.5) : O,s.colors,lighton,name); } void tensorshade(transform t=identity(), frame f, patch s, @@ -1355,7 +1355,7 @@ path[] path(Label L, pair z=0, projection P) void label(frame f, Label L, triple position, align align=NoAlign, pen p=currentpen, bool targetsize=false, light light=nolight, - projection P=currentprojection) + string name=defaultlabelname(), projection P=currentprojection) { Label L=L.copy(); L.align(align); @@ -1365,8 +1365,9 @@ void label(frame f, Label L, triple position, align align=NoAlign, if(L.defaulttransform3) L.T3=transform3(P); if(is3D()) { + int i=-1; for(patch S : surface(L,position).s) - draw3D(f,S,L.p,light); + draw3D(f,S,position,L.p,light,partname(name,++i)); } else { if(L.filltype == NoFill) fill(f,path(L,project(position,P.t),P), @@ -1382,7 +1383,7 @@ void label(frame f, Label L, triple position, align align=NoAlign, void label(picture pic=currentpicture, Label L, triple position, align align=NoAlign, pen p=currentpen, bool targetsize=false, - light light=nolight) + light light=nolight, string name=defaultlabelname()) { Label L=L.copy(); L.align(align); @@ -1400,9 +1401,11 @@ void label(picture pic=currentpicture, Label L, triple position, L.T=L.T*scale(abs(P.camera-v)/abs(P.vector())); if(L.defaulttransform3) L.T3=transform3(P); - if(is3D()) + if(is3D()) { + int i=-1; for(patch S : surface(L,v).s) - draw3D(f,S,L.p,light); + draw3D(f,S,v,L.p,light,partname(name,++i)); + } if(pic != null) { if(L.filltype == NoFill) fill(project(v,P.t),pic,path(L,P), @@ -1571,13 +1574,15 @@ restricted surface unitplane=surface(unitplane); restricted surface unitdisk=surface(unitcircle3); void dot(frame f, triple v, material p=currentpen, - light light=nolight, projection P=currentprojection) + light light=nolight, string name="", projection P=currentprojection) { pen q=(pen) p; if(is3D()) { material m=material(p,p.granularity >= 0 ? p.granularity : dotgranularity); + int i=-1; for(patch s : unitsphere.s) - draw3D(f,shift(v)*scale3(0.5*linewidth(dotsize(q)+q))*s,m,light); + draw3D(f,shift(v)*scale3(0.5*linewidth(dotsize(q)+q))*s,m,light, + partname(name,++i)); } else dot(f,project(v,P.t),q); } @@ -1594,7 +1599,7 @@ void dot(frame f, path3[] g, material p=currentpen, } void dot(picture pic=currentpicture, triple v, material p=currentpen, - light light=nolight) + light light=nolight, string name="") { pen q=(pen) p; real size=0.5*linewidth(dotsize(q)+q); @@ -1602,8 +1607,9 @@ void dot(picture pic=currentpicture, triple v, material p=currentpen, if(is3D()) { material m=material(p,p.granularity >= 0 ? p.granularity : dotgranularity); + int i=-1; for(patch s : unitsphere.s) - draw3D(f,shift(t*v)*scale3(size)*s,m,light); + draw3D(f,shift(t*v)*scale3(size)*s,m,light,partname(name,++i)); } if(pic != null) dot(pic,project(t*v,P.t),q); diff --git a/Master/texmf/asymptote/trembling.asy b/Master/texmf/asymptote/trembling.asy index b01d572d6e2..61e78a4fca3 100644 --- a/Master/texmf/asymptote/trembling.asy +++ b/Master/texmf/asymptote/trembling.asy @@ -1,4 +1,5 @@ // Copyright (c) 2008, Philippe Ivaldi. +// http://www.piprime.fr/ // trembling.asy: handwriting package for the software Asymptote. // This program is free software ; you can redistribute it and/or modify diff --git a/Master/texmf/asymptote/tube.asy b/Master/texmf/asymptote/tube.asy index 844a39c92f0..33e2ea3c868 100644 --- a/Master/texmf/asymptote/tube.asy +++ b/Master/texmf/asymptote/tube.asy @@ -1,4 +1,5 @@ // Author: Philippe Ivaldi +// http://www.piprime.fr/ // Based on this paper: // http://www.cs.hku.hk/research/techreps/document/TR-2007-07.pdf // Note: the additional rotation for a cyclic smooth spine curve is not diff --git a/Master/texmf/asymptote/version.asy b/Master/texmf/asymptote/version.asy index 7c9d6eefb14..c40fcb370f8 100644 --- a/Master/texmf/asymptote/version.asy +++ b/Master/texmf/asymptote/version.asy @@ -1 +1 @@ -string VERSION="1.86"; +string VERSION="1.87-r15549"; |