diff options
author | Karl Berry <karl@freefriends.org> | 2009-07-19 18:27:44 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-07-19 18:27:44 +0000 |
commit | b25e8a3c1794c6183fddcbf1afba1fc55b96f8a6 (patch) | |
tree | 46d56acdcbc93e37260ddaf785db4bcd9ae5ed47 /Master/texmf-dist/doc | |
parent | b198b4a00926eaf00016a5f65450228b9d7e991f (diff) |
new chinese doc asymptote-by-example (8jul09)
git-svn-id: svn://tug.org/texlive/trunk@14324 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc')
26 files changed, 7338 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/AsymptoteByExample.pdf b/Master/texmf-dist/doc/support/asymptote-by-example/AsymptoteByExample.pdf Binary files differnew file mode 100644 index 00000000000..d2244fadc10 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/AsymptoteByExample.pdf diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/README b/Master/texmf-dist/doc/support/asymptote-by-example/README new file mode 100644 index 00000000000..9a9f8648893 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/README @@ -0,0 +1,12 @@ +Asymptote by Example is an Asymptote tutorial in Simplified Chinese by milksea at ctex.org. + +Asymptote 1.70 should be used to compile the example. + +The document is released under GPL. + +If you are interested in the process of development you may observe + + http://code.google.com/p/ctex-doc/updates/list + +Report feedback in the Issues section of ctex-doc project, +or in http://bbs.ctex.org forum. diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/license.txt b/Master/texmf-dist/doc/support/asymptote-by-example/license.txt new file mode 100644 index 00000000000..d17df37628c --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/license.txt @@ -0,0 +1,716 @@ +\chapter{GNU GENERAL PUBLIC LICENSE} +\label{chap:license} + +\begin{center} +{\parindent 0in + +Version 3, 29 June 2007 + +Copyright \copyright\ 2007 Free Software Foundation, Inc. \texttt{http://fsf.org/} + +\bigskip +Everyone is permitted to copy and distribute verbatim copies of this + +license document, but changing it is not allowed.} + +\end{center} + + +\section{Preamble} + +The GNU General Public License is a free, copyleft license for +software and other kinds of works. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + +Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and +modification follow. + + +\section{Terms and Conditions} + + +\begin{enumerate} + +\addtocounter{enumi}{-1} + +\item Definitions. + +``This License'' refers to version 3 of the GNU General Public License. + +``Copyright'' also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + +``The Program'' refers to any copyrightable work licensed under this +License. Each licensee is addressed as ``you''. ``Licensees'' and +``recipients'' may be individuals or organizations. + +To ``modify'' a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a ``modified version'' of the +earlier work or a work ``based on'' the earlier work. + +A ``covered work'' means either the unmodified Program or a work based +on the Program. + +To ``propagate'' a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To ``convey'' a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays ``Appropriate Legal Notices'' +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +\item Source Code. + +The ``source code'' for a work means the preferred form of the work +for making modifications to it. ``Object code'' means any non-source +form of a work. + +A ``Standard Interface'' means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The ``System Libraries'' of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +``Major Component'', in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The ``Corresponding Source'' for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + +The Corresponding Source for a work in source code form is that +same work. + +\item Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + +\item Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + +\item Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +\item Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + \begin{enumerate} + \item The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + \item The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + ``keep intact all notices''. + + \item You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + \item If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. +\end{enumerate} +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +``aggregate'' if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + +\item Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + \begin{enumerate} + \item Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + \item Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + \item Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + \item Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + \item Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + \end{enumerate} + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + +A ``User Product'' is either (1) a ``consumer product'', which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, ``normally used'' refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + +``Installation Information'' for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +\item Additional Terms. + +``Additional permissions'' are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + \begin{enumerate} + \item Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + \item Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + \item Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + \item Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + \item Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + \item Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + \end{enumerate} + +All other non-permissive additional terms are considered ``further +restrictions'' within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + +\item Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +\item Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +\item Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An ``entity transaction'' is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +\item Patents. + +A ``contributor'' is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's ``contributor version''. + +A contributor's ``essential patent claims'' are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, ``control'' includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a ``patent license'' is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To ``grant'' such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. ``Knowingly relying'' means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is ``discriminatory'' if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +\item No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + +\item Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + +\item Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License ``or any later version'' applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + +\item Disclaimer of Warranty. + +\begin{sloppypar} + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY + APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE + COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE + RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. + SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL + NECESSARY SERVICING, REPAIR OR CORRECTION. +\end{sloppypar} + +\item Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES + AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR + DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL + DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM + (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED + INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE + OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH + HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + DAMAGES. + +\item Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + +\end{enumerate} + + +\section{End of Terms and Conditions} + +\begin{center} +How to Apply These Terms to Your New Programs +\end{center} + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the ``copyright'' line and a pointer to where the full notice is found. + +{\footnotesize +\begin{verbatim} +<one line to give the program's name and a brief idea of what it does.> + +Copyright (C) <textyear> <name of author> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +\end{verbatim} +} + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + +{\footnotesize +\begin{verbatim} +<program> Copyright (C) <year> <name of author> + +This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. +This is free software, and you are welcome to redistribute it +under certain conditions; type `show c' for details. +\end{verbatim} +} + +The hypothetical commands {\tt show w} and {\tt show c} should show +the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an ``about box''. + +You should also get your employer (if you work as a programmer) or +school, if any, to sign a ``copyright disclaimer'' for the program, if +necessary. For more information on this, and how to apply and follow +the GNU GPL, see \texttt{http://www.gnu.org/licenses/}. + +The GNU General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use +the GNU Lesser General Public License instead of this License. But +first, please read \texttt{http://www.gnu.org/philosophy/why-not-lgpl.html}. + + +\endinput diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/CLEAN.bat b/Master/texmf-dist/doc/support/asymptote-by-example/src/CLEAN.bat new file mode 100755 index 00000000000..d206eb4691c --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/CLEAN.bat @@ -0,0 +1,3 @@ +del main-??.pdf
+del *.bak *.???~
+del *.log *.aux *.toc *.out *.ilg *.ind *.idx *.bbl *.blg
\ No newline at end of file diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/MAKEPDF.bat b/Master/texmf-dist/doc/support/asymptote-by-example/src/MAKEPDF.bat new file mode 100755 index 00000000000..8eb57e3c541 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/MAKEPDF.bat @@ -0,0 +1,8 @@ +xelatex main
+asy main
+xelatex main
+makeindex main
+bibtex main
+xelatex main
+xelatex main
+ren main.pdf AsymptoteByExample.pdf
\ No newline at end of file diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/asy.bib b/Master/texmf-dist/doc/support/asymptote-by-example/src/asy.bib new file mode 100644 index 00000000000..539d9a2d775 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/asy.bib @@ -0,0 +1,63 @@ +% This file was created with JabRef 2.4.2. +% Encoding: UTF8 + +@ARTICLE{quanjing, + author = {曲安京}, + title = {商高、趙爽與劉徽關於勾股定理的證明}, + journal = {數學傳播}, + year = {1998}, + volume = {20}, + number = {3}, + owner = {milksea}, + timestamp = {2009.05.14} +} + +@MANUAL{asyman, + title = {Asymptote: the Vector Graphics Language}, + author = {Andy Hammerlindl and John Bowman and Tom Prince}, + edition = {1.70}, + year = {2009}, + note = {这是 Asymptote 的官方手册。milksea 给出了文档的一个翻译,见 \url{http://code.google.com/p/asy4cn/}。}, + owner = {milksea}, + timestamp = {2009.05.13} +} + +@MANUAL{mpman, + title = {\MP: A User's Manual}, + author = {John D. Hobby and {the MetaPost development team}}, + edition = {1.005}, + month = {May}, + year = {2008}, + owner = {milksea}, + timestamp = {2009.06.16} +} + +@BOOK{knuth1986, + title = {The \MF{}book}, + publisher = {Addison Wesley}, + year = {1986}, + author = {Donald Ervin Knuth}, + volume = {C}, + series = {Computers \& Typesetting}, + owner = {milksea}, + timestamp = {2009.06.16} +} + +@MANUAL{pstricks, + title = {PSTricks: PostScript macros for Generic \TeX{}}, + author = {Timothy Van Zandt}, + edition = {97}, + month = {July}, + year = {2003}, + owner = {milksea}, + timestamp = {2009.05.19} +} + +@comment{jabref-meta: selector_publisher:} + +@comment{jabref-meta: selector_author:} + +@comment{jabref-meta: selector_journal:} + +@comment{jabref-meta: selector_keywords:} + diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/asymptote.sty b/Master/texmf-dist/doc/support/asymptote-by-example/src/asymptote.sty new file mode 100644 index 00000000000..c16f1be1fbd --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/asymptote.sty @@ -0,0 +1,268 @@ +%%% Asymptote style file for LaTeX +%%% Contributed by Tom Prince 14 May 2003 +%%% Modified by John Bowman +%%% Adapted from comment.sty (Under GPL v2) + +% again modified by milksea + +\ProvidesPackage{asymptote}[2009/05/12 v1.06 Asymptote style file for LaTeX, modified by milksea] +\RequirePackage{keyval} +\RequirePackage{ifthen} +\RequirePackage{ifpdf} +\RequirePackage{ifxetex} +\newif\ifASYinline +\DeclareOption{inline}{\ASYinlinetrue} +\ProcessOptions* + +% Work around jobname bug in MiKTeX 2.5 and 2.6: +% Turn stars in file names (resulting from spaces, etc.) into minus signs +\def\fixstar#1*#2\relax{\def\argtwo{#2}\ifx\argtwo\empty\gdef\Jobname{#1}\else +\fixstar#1-#2\relax\fi} +\expandafter\fixstar\jobname*\relax + +\RequirePackage{color,graphicx} + +\def\makeinnocent#1{\catcode`#1=12 } +\def\csarg#1#2{\expandafter#1\csname#2\endcsname} +\newwrite\AsyStream +\newread\AsyTestStream +\newread\AsyTestTeXStream +\def\AsyFile{\jobname.asy} + +\openin\AsyTestStream=\jobname_.pre +\ifeof\AsyTestStream +\else +\input \jobname_.pre +\fi +\closein\AsyTestStream% + +\immediate\openout\AsyStream=\AsyFile +\immediate\write\AsyStream{if(!settings.multipleView)}% +\immediate\write\AsyStream{ settings.batchView=false;}% + +\newif\ifASYattach +\newif\ifASYtex + +\newif\ifASYPDF +\ifpdf + \ASYPDFtrue + \immediate\write\AsyStream{settings.tex="pdflatex";}% +\fi +\ifxetex + \ASYPDFtrue + \immediate\write\AsyStream{settings.tex="xelatex";}% +\fi + +\ifASYinline +\immediate\write\AsyStream{settings.inlinetex=true;}% +\immediate\write\AsyStream{deletepreamble();}% +\fi + +\newbox\ASYbox +\newcounter{asy} + +\def\ProcessAsymptote#1% start it all off +{\begingroup + \def\CurrentAsymptote{#1}% + \let\do\makeinnocent \dospecials + \makeinnocent\^^L% and whatever other special cases + \endlinechar`\^^M \catcode`\^^M=12 \xAsymptote} +{\catcode`\^^M=12 \endlinechar=-1 % + \gdef\xAsymptote{% + \expandafter\ProcessAsymptoteLine} + \gdef\ProcessAsymptoteLine#1^^M{\def\test{#1} + \csarg\ifx{End\CurrentAsymptote Test}\test + \edef\next{\noexpand\EndOfAsymptote{\CurrentAsymptote}}% + \else \ThisAsymptote{#1}\let\next\ProcessAsymptoteLine + \fi \next} +} + +\def\ASYstringmeaning#1{\expandafter\ASYgobblearrow\meaning#1} +\def\ASYstringcsnoescape#1{\expandafter\ASYgobbleescape\string#1} +{\escapechar-1 + \expandafter\expandafter\expandafter\gdef + \expandafter\expandafter\expandafter\ASYgobblearrow + \expandafter\string\csname macro:->\endcsname{} +} +\def\ASYgobbleescape#1{\ifnum`\\=`#1 \else #1\fi} + +\def\WriteAsyLine#1{\def\ASYtmp{#1}% + \immediate\write\AsyStream{\ASYstringmeaning\ASYtmp}} + +\def\gedefappend#1#2{% + \toks@ = \expandafter{#1}% + \global\edef#1{\the\toks@ #2}% +}% +\def\globalASYdefs{} +\def\WriteGlobalAsyLine#1{\def\ASYtmp{#1^^J}% +\gedefappend\globalASYdefs{\ASYstringmeaning\ASYtmp}} + +\def\EndOfAsymptote#1{\endgroup\end{#1}% + \csname After#1Asymptote\endcsname} +\def\AsymptoteEndDef#1{{\escapechar=-1\relax + \csarg\xdef{End#1Test}{\string\\end\string\{#1\string\}}% + }} + +\def\AfterasyAsymptote{% + \ifx\ASYwidth\empty + \ifx\ASYheight\empty + \else + \immediate\write\AsyStream{size(0,\ASYheight);}% + \fi + \else + \ifx\ASYheight\empty + \immediate\write\AsyStream{size(\ASYwidth,0);}% + \else + \immediate\write\AsyStream{size(\ASYwidth,\ASYheight);}% + \fi + \fi + \ASYtexfalse + \ifASYattach + \def\ASYdefaultviewportwidth{0} + \else + \def\ASYdefaultviewportwidth{\the\linewidth} + \ifASYinline + \ASYtextrue + \fi + \fi + \ifx\ASYviewportwidth\empty + \ifx\ASYviewportheight\empty + \else + \immediate\write\AsyStream{viewportsize=(0,\ASYviewportheight);}% + \fi + \else + \ifx\ASYviewportheight\empty + \immediate\write\AsyStream{viewportsize=(\ASYviewportwidth,0);}% + \else + \immediate\write% + \AsyStream{viewportsize=(\ASYviewportwidth,\ASYviewportheight);}% + \fi + \fi + \gdef\ASYwidth{} + \gdef\ASYheight{} + \gdef\ASYviewportwidth{\ASYdefaultviewportwidth} + \gdef\ASYviewportheight{} + \immediate\write\AsyStream{\@charrb);}% + \immediate\write\AsyStream{// End of Asymptote Figure \the\c@asy}% + \ifASYtex + \openin\AsyTestStream=\Jobname-\the\c@asy_.tex + \else + \ifASYPDF + \openin\AsyTestStream=\Jobname-\the\c@asy.pdf + \else + \openin\AsyTestStream=\Jobname-\the\c@asy.eps + \fi + \fi + \ifeof\AsyTestStream + \ifASYtex + \PackageWarning{asymptote}{file \Jobname-\the\c@asy_.tex does not exist}% + \else + \openin\AsyTestTeXStream=\Jobname-\the\c@asy_.tex + \ifeof\AsyTestTeXStream + \ifASYPDF + \PackageWarning{asymptote}{file \Jobname-\the\c@asy.pdf does not exist}% + \else + \PackageWarning{asymptote}{file \Jobname-\the\c@asy.eps does not exist}% + \fi + \else + \catcode`:=12 + \input \Jobname-\the\c@asy_.tex% + \fi + \closein\AsyTestTeXStream% + \fi + \closein\AsyTestStream% + \else + \closein\AsyTestStream% + \ifASYtex + \catcode`:=12 + \input \Jobname-\the\c@asy_.tex% + \else + \ifASYattach + \ifASYPDF + \openin\AsyTestStream=\Jobname-\the\c@asy-0.pdf + \fi + \ifeof\AsyTestStream + \setbox\ASYbox=\hbox{\includegraphics{\Jobname-\the\c@asy}}% + \else + \setbox\ASYbox=\hbox{\includegraphics{\Jobname-\the\c@asy-0}}% + \fi + \textattachfile{\Jobname-\the\c@asy.pdf}{\phantom{\copy\ASYbox}}% + \vskip-\ht\ASYbox% + \indent% + \box\ASYbox% + \closein\AsyTestStream% + \else + \includegraphics{\Jobname-\the\c@asy}% + \fi + \fi + \fi + \global\ASYattachfalse + \relax% + \endgroup} +\gdef\ASYwidth{}% +\define@key{ASYkeys}{width}{% + \gdef\ASYwidth{#1}% +} +\gdef\ASYheight{}% +\define@key{ASYkeys}{height}{% + \gdef\ASYheight{#1}% +} +\gdef\ASYviewportwidth{\ASYdefaultviewportwidth}% +\define@key{ASYkeys}{viewportwidth}{% + \gdef\ASYviewportwidth{#1}% +} +\gdef\ASYviewportheight{}% +\define@key{ASYkeys}{viewportheight}{% + \gdef\ASYviewportheight{#1}% +} +\define@key{ASYkeys}{attach}[true]{% + \ifthenelse{\equal{#1}{true}}{\global\ASYattachtrue}{\global\ASYattachfalse}% +} +\newcommand\asy[1][]{% + \begingroup + \let\par\empty + \stepcounter{asy}% + \setkeys{ASYkeys}{#1}% + \immediate\write\AsyStream{}% + \immediate\write\AsyStream{// Beginning of Asymptote Figure \the\c@asy}% + \immediate\write\AsyStream{eval(quote\@charlb}% + \immediate\write\AsyStream{defaultfilename='\Jobname-\the\c@asy';}% + \immediate\write\AsyStream{if(settings.render < 0) settings.render=4;}% + \ifASYattach + \immediate\write\AsyStream{settings.inlineimage=false;}% + \immediate\write\AsyStream{settings.embed=false;}% + \immediate\write\AsyStream{settings.outformat='pdf';}% + \immediate\write\AsyStream{settings.toolbar=true;}% + \else + \immediate\write\AsyStream{settings.inlineimage=true;}% + \immediate\write\AsyStream{settings.embed=true;}% + \immediate\write\AsyStream{settings.outformat='';}% + \immediate\write\AsyStream{settings.toolbar=false;}% + \fi + \immediate\write\AsyStream{\globalASYdefs}% + \let\ThisAsymptote\WriteAsyLine% + \ProcessAsymptote{asy}% +} +\AsymptoteEndDef{asy} +\def\asydef{% + \let\ThisAsymptote\WriteGlobalAsyLine% + \ProcessAsymptote{asydef}} +\AsymptoteEndDef{asydef} +\def\AfterasydefAsymptote{} + +\AtEndDocument{\immediate\closeout\AsyStream} + +\newcommand{\ASYanimategraphics}[5][]{% +\openin\AsyTestStream=_#3.pdf +\ifeof\AsyTestStream% +\else% +\animategraphics[{#1}]{#2}{_#3}{#4}{#5}% +\fi% +} + +\def\Asymptote{{\tt Asymptote}} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "shared" +%%% End: diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/asysyntex.sty b/Master/texmf-dist/doc/support/asymptote-by-example/src/asysyntex.sty new file mode 100644 index 00000000000..8571fecf4e7 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/asysyntex.sty @@ -0,0 +1,304 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{asysyntex}[2008/06/19 v1.77] + +\RequirePackage{xcolor} +\colorlet{comment}{green!50!black} +\colorlet{string}{blue!50!black} +\colorlet{background}{olive!25} + +\RequirePackage{listings} + +% 语言定义 +% keywords 对应 asy-keyword-name +% keywords=[2] 对应 asy-type-name +% keywords=[3] 对应 asy-function-name +% keywords=[4] 对应 asy-variable-name +\lstdefinelanguage{Asymptote}{alsoletter={}, + sensitive=true,% + keywords={and, controls, tension, atleast, curl, if, else, while, for, do, + return, break, continue, struct, typedef, new, access, import, unravel, + from, include, quote, static, public, private, restricted, this, explicit, + true, false, null, cycle, newframe, operator}, + keywords=[2]{Braid, FitResult, Label, Legend, Rmf, TreeNode, abscissa, arc, + arrowhead, binarytree, binarytreeNode, block, bool, bool3, bounds, bqe, + circle, conic, coord, coordsys, cputime, ellipse, file, filltype, frame, + grid3, guide, horner, hsv, hyperbola, indexedTransform, int, inversion, + key, line, linefit, marginT, marker, mass, object, pair, parabola, path, + path3, pen, picture, point, position, projection, real, revolution, scaleT, + scientific, segment, side, slice, splitface, string, surface, + tensionSpecifier, ticklocate, ticksgridT, tickvalues, transform, + transformation, tree, triangle, trilinear, triple, vector, vertex, void}, + keywords=[3]{AND, Arc, ArcArrow, ArcArrows, Arrow, Arrows, Automatic, + AvantGarde, BBox, BWRainbow, BWRainbow2, Bar, Bars, BeginArcArrow, + BeginArrow, BeginBar, BeginDotMargin, BeginMargin, BeginPenMargin, Blank, + Bookman, Bottom, BottomTop, Bounds, Break, Broken, BrokenLog, Ceil, Circle, + CircleBarIntervalMarker, Cos, Courier, CrossIntervalMarker, DefaultFormat, + DefaultLogFormat, Degrees, Dir, DotMargin, DotMargins, Dotted, Draw, + Drawline, Embed, EndArcArrow, EndArrow, EndBar, EndDotMargin, EndMargin, + EndPenMargin, Fill, FillDraw, Floor, Format, Full, Gaussian, Gaussrand, + Gaussrandpair, Gradient, Grayscale, Helvetica, Hermite, HookHead, + InOutTicks, InTicks, J, Label, Landscape, Left, LeftRight, LeftTicks, + Legend, Linear, Link, Log, LogFormat, Margin, Margins, Mark, MidArcArrow, + MidArrow, NOT, NewCenturySchoolBook, NoBox, NoMargin, NoModifier, NoTicks, + NoTicks3, NoZero, NoZeroFormat, None, OR, OmitFormat, OmitTick, OutTicks, + Ox, Oy, Palatino, PaletteTicks, Pen, PenMargin, PenMargins, Pentype, + Portrait, RadialShade, Rainbow, Range, Relative, Right, RightTicks, Rotate, + Round, SQR, Scale, ScaleX, ScaleY, ScaleZ, Seascape, Shift, Sin, Slant, + Spline, StickIntervalMarker, Straight, Symbol, Tan, TeXify, Ticks, Ticks3, + TildeIntervalMarker, TimesRoman, Top, TrueMargin, UnFill, UpsideDown, + Wheel, X, XEquals, XOR, XY, XYEquals, XYZero, XYgrid, XZEquals, XZZero, + XZero, XZgrid, Y, YEquals, YXgrid, YZ, YZEquals, YZZero, YZero, YZgrid, Z, + ZX, ZXgrid, ZYgrid, ZapfChancery, ZapfDingbats, _cputime, _draw, _eval, + _image, _labelpath, _strokepath, _texpath, aCos, aSin, aTan, abort, abs, + accel, acos, acosh, acot, acsc, add, addArrow, addMargins, addSaveFunction, + addnode, addnodes, addpenarc, addpenline, addseg, adjust, alias, align, + all, altitude, angabscissa, angle, angpoint, animate, annotate, + anticomplementary, antipedal, apply, approximate, arc, arcarrowsize, + arccircle, arcdir, arcfromcenter, arcfromfocus, arclength, arcnodesnumber, + arcpoint, arcsubtended, arcsubtendedcenter, arctime, arctopath, array, + arrow, arrow2, arrowbase, arrowbasepoints, arrowsize, asec, asin, asinh, + ask, assert, asy, asycode, asydir, asyfigure, asyfilecode, asyinclude, + asywrite, atan, atan2, atanh, atbreakpoint, atexit, atime, attach, attract, + atupdate, autoformat, autoscale, autoscale3, axes, axes3, axialshade, axis, + axiscoverage, azimuth, babel, background, bangles, bar, barmarksize, + barsize, basealign, baseline, bbox, beep, begin, beginclip, begingroup, + beginpoint, between, bevel, bezier, bezierP, bezierPP, bezierPPP, bezulate, + bibliography, bibliographystyle, binarytree, binarytreeNode, binomial, + binput, bins, bisector, bisectorpoint, bispline, blend, boutput, box, bqe, + breakpoint, breakpoints, brick, buildRestoreDefaults, buildRestoreThunk, + buildcycle, bulletcolor, canonical, canonicalcartesiansystem, + cartesiansystem, case1, case2, case3, cbrt, cd, ceil, center, + centerToFocus, centroid, cevian, change2, changecoordsys, checkSegment, + checkconditionlength, checker, checklengths, checkposition, checktriangle, + choose, circle, circlebarframe, circlemarkradius, circlenodesnumber, + circumcenter, circumcircle, clamped, clear, clip, clipdraw, close, cmyk, + code, colatitude, collect, collinear, color, colorless, colors, colorspace, + comma, compassmark, complement, complementary, concat, concurrent, cone, + conic, conicnodesnumber, conictype, conj, connect, containmentTree, + contains, contour, contour3, controlSpecifier, convert, coordinates, + coordsys, copy, cos, cosh, cot, countIntersections, cputime, crop, + cropcode, cross, crossframe, crosshatch, crossmarksize, csc, csv, + cubicroots, curabscissa, curlSpecifier, curpoint, currentarrow, + currentexitfunction, currentmomarrow, currentpolarconicroutine, curve, cut, + cutafter, cutbefore, cyclic, cylinder, debugger, deconstruct, defaultdir, + defaultformat, defaultpen, defaultspline, defined, degenerate, degrees, + delete, deletepreamble, determinant, diagonal, diamond, diffdiv, dimension, + dir, dirSpecifier, dirtime, display, distance, divisors, do_overpaint, dot, + dotframe, dotsize, downcase, draw, drawAll, drawDoubleLine, drawFermion, + drawGhost, drawGluon, drawMomArrow, drawPhoton, drawScalar, drawVertex, + drawVertexBox, drawVertexBoxO, drawVertexBoxX, drawVertexO, drawVertexOX, + drawVertexTriangle, drawVertexTriangleO, drawVertexX, drawarrow, + drawarrow2, drawline, drawtick, duplicate, elle, ellipse, + ellipsenodesnumber, embed, embed3, empty, enclose, end, endScript, endclip, + endgroup, endl, endpoint, endpoints, eof, eol, equation, equations, erase, + erf, erfc, error, errorbar, errorbars, eval, excenter, excircle, exit, + exitXasyMode, exitfunction, exp, expi, expm1, exradius, extend, extension, + extouch, fabs, factorial, fermat, fft, fhorner, figure, file, filecode, + fill, filldraw, filloutside, fillrule, filltype, find, finite, + finiteDifferenceJacobian, firstcut, firstframe, fit, fixedscaling, floor, + flush, fmdefaults, fmod, focusToCenter, font, fontcommand, fontsize, foot, + format, frac, frequency, fromCenter, fromFocus, fspline, functionshade, + gamma, generate_random_backtrace, generateticks, gergonne, getc, getint, + getpair, getreal, getstring, gettriple, gluon, gouraudshade, graph, + graphic, gray, grestore, grid, grid3, gsave, halfbox, hatch, hdiffdiv, + hermite, hex, histogram, history, hline, hprojection, hsv, hyperbola, + hyperbolanodesnumber, hyperlink, hypot, identity, image, incenter, + incentral, incircle, increasing, incrementposition, indexedTransform, + initXasyMode, initdefaults, input, inradius, insert, inside, integrate, + interactive, interior, interp, interpolate, intersect, intersection, + intersectionpoint, intersectionpoints, intersections, intouch, inverse, + inversion, invisible, is3D, isDuplicate, isogonal, isogonalconjugate, + isotomic, isotomicconjugate, isparabola, italic, item, key, kurtosis, + kurtosisexcess, label, labelaxis, labelmargin, labelpath, labels, + labeltick, labelx, labelx3, labely, labely3, labelz, labelz3, lastcut, + latex, latitude, latticeshade, layer, layout, ldexp, leastsquares, legend, + legenditem, length, lift, limits, line, linear, linecap, linejoin, + linemargin, lineskip, linetype, linewidth, link, list, lm_enorm, + lm_evaluate_default, lm_lmdif, lm_lmpar, lm_minimize, lm_print_default, + lm_print_quiet, lm_qrfac, lm_qrsolv, locale, locate, locatefile, location, + log, log10, log1p, logaxiscoverage, longitude, lookup, magnetize, makeNode, + makedraw, makepen, map, margin, markangle, markangleradius, markanglespace, + markarc, marker, markinterval, marknodes, markrightangle, markuniform, + mass, masscenter, massformat, math, max, max3, maxbound, maxcoords, + maxlength, maxratio, maxtimes, mean, medial, median, midpoint, min, min3, + minbound, minipage, minratio, mintimes, miterlimit, momArrowPath, + momarrowsize, monotonic, nativeformat, natural, needshipout, newl, newpage, + newslide, newton, newtree, nextframe, nextnormal, nextpage, nib, + nodabscissa, none, normalvideo, notaknot, numberpage, nurb, object, offset, + onpath, opacity, opposite, orientation, orig_circlenodesnumber, + orig_circlenodesnumber1, orig_draw, orig_ellipsenodesnumber, + orig_ellipsenodesnumber1, orig_hyperbolanodesnumber, + orig_parabolanodesnumber, origin, orthic, orthocentercenter, outformat, + outline, outprefix, output, overwrite, pack, pad, pairs, palette, parabola, + parabolanodesnumber, parallel, partialsum, path, path3, pattern, pause, + pdf, pedal, periodic, perp, perpendicular, perpendicularmark, phantom, + photon, piecewisestraight, point, polar, polarconicroutine, polargraph, + polygon, postcontrol, postscript, pow10, ppoint, prc, prc0, precision, + precontrol, prepend, print_random_addresses, project, projection, purge, + pwhermite, quadrant, quadraticroots, quantize, quarticroots, quotient, + radialshade, radians, radicalcenter, radicalline, radius, rand, randompath, + rd, read1, read2, read3, readline, realmult, realquarticroots, rectangle, + rectangular, rectify, reflect, relabscissa, relative, relativedistance, + reldir, relpoint, reltime, remainder, remark, removeDuplicates, rename, + replace, report, rescale, rescale2, resetdefaultpen, restore, + restoredefaults, reverse, reversevideo, rf, rfind, rgb, rgba, rgbint, rmf, + rms, rotate, rotateO, rotation, round, roundbox, roundedpath, + roundrectangle, samecoordsys, sameside, sample, save, savedefaults, + saveline, scale, scale3, scaleO, scaleT, scaleless, scientific, search, + searchtree, sec, secondaryX, secondaryY, seconds, section, sector, seek, + seekeof, segment, sequence, setpens, sgn, sgnd, sharpangle, sharpdegrees, + shift, shiftless, shipout, shipout3, show, side, simeq, simpson, sin, + single, sinh, size, size3, skewness, skip, slant, sleep, slope, slopefield, + solve, solveBVP, sort, sourceline, sphere, split, sqrt, square, srand, + standardizecoordsys, startScript, startTrembling, stdev, step, stickframe, + stickmarksize, stickmarkspace, stop, straight, straightness, string, + stripdirectory, stripextension, stripfile, strokepath, subdivide, subitem, + subpath, substr, sum, surface, symmedial, symmedian, system, tab, tableau, + tan, tangent, tangential, tangents, tanh, tell, tensionSpecifier, + tensorshade, tex, texcolor, texify, texpath, texpreamble, texreset, + texshipout, texsize, textpath, thick, thin, tick, tickMax, tickMax3, + tickMin, tickMin3, ticklabelshift, ticklocate, tildeframe, tildemarksize, + tile, tiling, time, times, title, titlepage, topbox, transform, + transformation, transpose, tremble, trembleFuzz, tremble_circlenodesnumber, + tremble_circlenodesnumber1, tremble_draw, tremble_ellipsenodesnumber, + tremble_ellipsenodesnumber1, tremble_hyperbolanodesnumber, + tremble_marknodes, tremble_markuniform, tremble_parabolanodesnumber, + triangle, triangleAbc, triangleabc, triangulate, tricoef, tridiagonal, + trilinear, trim, trueMagnetize, truepoint, tube, uncycle, unfill, uniform, + unit, unitrand, unitsize, unityroot, unstraighten, upcase, updatefunction, + upscale, uptodate, usepackage, usersetting, usetypescript, usleep, value, + variance, variancebiased, vbox, vector, vectorfield, verbatim, view, vline, + vprojection, windingnumber, word, write, xaxis, xaxis3, xaxis3At, xaxisAt, + xequals, xinput, xlimits, xoutput, xpart, xscale, xscaleO, xtick, xtick3, + xtrans, yaxis, yaxis3, yaxis3At, yaxisAt, yequals, ylimits, ypart, yscale, + yscaleO, ytick, ytick3, ytrans, zaxis3, zaxis3At, zero, zero3, zlimits, + zpart, ztick, ztick3, ztrans}, + keywords=[4]{AliceBlue, Align, Allow, AntiqueWhite, Apricot, Aqua, + Aquamarine, Aspect, Azure, BeginPoint, Beige, Bisque, Bittersweet, Black, + BlanchedAlmond, Blue, BlueGreen, BlueViolet, Both, Break, BrickRed, Brown, + BurlyWood, BurntOrange, CCW, CW, CadetBlue, CarnationPink, Center, + Centered, Cerulean, Chartreuse, Chocolate, Coral, CornflowerBlue, Cornsilk, + Crimson, Crop, Cyan, Dandelion, DarkBlue, DarkCyan, DarkGoldenrod, + DarkGray, DarkGreen, DarkKhaki, DarkMagenta, DarkOliveGreen, DarkOrange, + DarkOrchid, DarkRed, DarkSalmon, DarkSeaGreen, DarkSlateBlue, + DarkSlateGray, DarkTurquoise, DarkViolet, DeepPink, DeepSkyBlue, + DefaultHead, DimGray, DodgerBlue, Dotted, Draw, E, ENE, EPS, ESE, Emerald, + EndPoint, Euler, Fill, FillDraw, FireBrick, FloralWhite, ForestGreen, + Fuchsia, Gainsboro, GhostWhite, Gold, Goldenrod, Gray, Green, GreenYellow, + Honeydew, HookHead, Horizontal, HotPink, I, IgnoreAspect, IndianRed, + Indigo, Ivory, JOIN_IN, JOIN_OUT, JungleGreen, Khaki, LM_DWARF, LM_MACHEP, + LM_SQRT_DWARF, LM_SQRT_GIANT, LM_USERTOL, Label, Lavender, LavenderBlush, + LawnGreen, LeftJustified, LeftSide, LemonChiffon, LightBlue, LightCoral, + LightCyan, LightGoldenrodYellow, LightGreen, LightGrey, LightPink, + LightSalmon, LightSeaGreen, LightSkyBlue, LightSlateGray, LightSteelBlue, + LightYellow, Lime, LimeGreen, Linear, Linen, Log, Logarithmic, Magenta, + Mahogany, Mark, MarkFill, Maroon, Max, MediumAquamarine, MediumBlue, + MediumOrchid, MediumPurple, MediumSeaGreen, MediumSlateBlue, + MediumSpringGreen, MediumTurquoise, MediumVioletRed, Melon, MidPoint, + MidnightBlue, Min, MintCream, MistyRose, Moccasin, Move, MoveQuiet, + Mulberry, N, NE, NNE, NNW, NW, NavajoWhite, Navy, NavyBlue, NoAlign, + NoCrop, NoFill, NoSide, OldLace, Olive, OliveDrab, OliveGreen, Orange, + OrangeRed, Orchid, Ox, Oy, PC, PaleGoldenrod, PaleGreen, PaleTurquoise, + PaleVioletRed, PapayaWhip, Peach, PeachPuff, Periwinkle, Peru, PineGreen, + Pink, Plum, PowderBlue, ProcessBlue, Purple, RK2, RK3, RK3BS, RK4, RK5CK, + RK5DP, RK5F, RawSienna, Red, RedOrange, RedViolet, Rhodamine, + RightJustified, RightSide, RosyBrown, RoyalBlue, RoyalPurple, RubineRed, S, + SE, SSE, SSW, SW, SaddleBrown, Salmon, SandyBrown, SeaGreen, Seashell, + Sepia, Sienna, Silver, SimpleHead, SkyBlue, SlateBlue, SlateGray, Snow, + SpringGreen, SteelBlue, Suppress, SuppressQuiet, Tan, TeXHead, Teal, + TealBlue, Thistle, Ticksize, Tomato, Turquoise, UnFill, VERSION, Value, + Vertical, Violet, VioletRed, W, WNW, WSW, Wheat, White, WhiteSmoke, + WildStrawberry, XYAlign, YAlign, Yellow, YellowGreen, YellowOrange, + addpenarc, addpenline, align, allowstepping, angularsystem, animationdelay, + appendsuffix, arcarrowangle, arcarrowfactor, arrow2sizelimit, arrowangle, + arrowbarb, arrowdir, arrowfactor, arrowhookfactor, arrowlength, + arrowsizelimit, arrowtexfactor, authorpen, axis, axiscoverage, + axislabelfactor, background, backgroundcolor, backgroundpen, barfactor, + barmarksizefactor, basealign, baselinetemplate, beveljoin, bigvertexpen, + bigvertexsize, black, blue, bm, bottom, bp, brown, bullet, byfoci, + byvertices, camerafactor, chartreuse, circlemarkradiusfactor, + circlenodesnumberfactor, circleprecision, circlescale, cm, codefile, + codepen, codeskip, colorPen, coloredNodes, coloredSegments, + conditionlength, conicnodesfactor, count, cputimeformat, + crossmarksizefactor, currentcoordsys, currentpatterns, currentpen, + currentpicture, currentposition, currentprojection, curvilinearsystem, + cuttings, cyan, darkblue, darkbrown, darkcyan, darkgray, darkgreen, + darkgrey, darkmagenta, darkolive, darkred, dashdotted, dashed, datepen, + dateskip, debuggerlines, debugging, deepblue, deepcyan, deepgray, + deepgreen, deepgrey, deepmagenta, deepred, default, defaultControl, + defaultS, defaultbackpen, defaultcoordsys, defaultfilename, defaultformat, + defaultmassformat, defaultpen, diagnostics, differentlengths, dot, + dotfactor, dotframe, dotted, doublelinepen, doublelinespacing, down, + duplicateFuzz, ellipsenodesnumberfactor, eps, epsgeo, epsilon, evenodd, + extendcap, fermionpen, figureborder, figuremattpen, firstnode, firststep, + foregroundcolor, fuchsia, fuzz, gapfactor, ghostpen, gluonamplitude, + gluonpen, gluonratio, gray, green, grey, hatchepsilon, havepagenumber, + heavyblue, heavycyan, heavygray, heavygreen, heavygrey, heavymagenta, + heavyred, hline, hwratio, hyperbolanodesnumberfactor, identity4, ignore, + inXasyMode, inch, inches, includegraphicscommand, inf, infinity, + institutionpen, intMax, intMin, invert, invisible, itempen, itemskip, + itemstep, labelmargin, landscape, lastnode, left, legendhskip, + legendlinelength, legendmargin, legendmarkersize, legendmaxrelativewidth, + legendvskip, lightblue, lightcyan, lightgray, lightgreen, lightgrey, + lightmagenta, lightolive, lightred, lightyellow, linemargin, lm_infmsg, + lm_shortmsg, longdashdotted, longdashed, magenta, magneticPoints, + magneticRadius, mantissaBits, markangleradius, markangleradiusfactor, + markanglespace, markanglespacefactor, mediumblue, mediumcyan, mediumgray, + mediumgreen, mediumgrey, mediummagenta, mediumred, mediumyellow, middle, + minDistDefault, minblockheight, minblockwidth, mincirclediameter, + minipagemargin, minipagewidth, minvertexangle, miterjoin, mm, + momarrowfactor, momarrowlength, momarrowmargin, momarrowoffset, + momarrowpen, monoPen, morepoints, nCircle, newbulletcolor, ngraph, nil, + nmesh, nobasealign, nodeMarginDefault, nodesystem, nomarker, nopoint, + noprimary, nullpath, nullpen, numarray, ocgindex, oldbulletcolor, olive, + orange, origin, overpaint, page, pageheight, pagemargin, pagenumberalign, + pagenumberpen, pagenumberposition, pagewidth, paleblue, palecyan, palegray, + palegreen, palegrey, palemagenta, palered, paleyellow, + parabolanodesnumberfactor, perpfactor, phi, photonamplitude, photonpen, + photonratio, pi, pink, plain, plus, preamblenodes, pt, purple, r3, r4a, + r4b, randMax, realDigits, realEpsilon, realMax, realMin, red, + relativesystem, reverse, right, roundcap, roundjoin, royalblue, salmon, + saveFunctions, scalarpen, sequencereal, settings, shipped, + signedtrailingzero, solid, springgreen, sqrtEpsilon, squarecap, squarepen, + startposition, stdin, stdout, stepfactor, stepfraction, steppagenumberpen, + stepping, stickframe, stickmarksizefactor, stickmarkspacefactor, textpen, + ticksize, tildeframe, tildemarksizefactor, tinv, titlealign, titlepagepen, + titlepageposition, titlepen, titleskip, top, trailingzero, treeLevelStep, + treeMinNodeWidth, treeNodeStep, trembleAngle, trembleFrequency, + trembleRandom, tremblingMode, undefined, unitcircle, unitsquare, up, + urlpen, urlskip, version, vertexpen, vertexsize, viewportmargin, + viewportsize, vline, white, wye, xformStack, yellow, ylabelwidth, + zerotickfuzz, zerowinding}, + morecomment=[l]{//},% 注释 + morecomment=[s]{/*}{*/},% 注释 + morestring=[b]",% 字符串 + morestring=[b]',% 字符串 +} +% 定义别名 +\lstalias{asy}{Asymptote} +\lstset{% + language=asy, + escapechar=`, + columns=fixed, + basewidth=0.55em, + basicstyle={\ttfamily}, + keywordstyle={\bfseries}, + keywordstyle=[2]{\bfseries}, + keywordstyle=[3]{}, + keywordstyle=[4]{}, + commentstyle={\color{comment}}, + stringstyle={\color{string}}, + xleftmargin={2em}, + xrightmargin={2em}, + tabsize=8, + backgroundcolor={\color{background}}, + numberstyle=\footnotesize, + stepnumber=1, + numbersep=5pt} +% +\def\oldvert{|} % 保存字符 | 的旧定义(其 catcode 在此定义读入时已确定) +\lstMakeShortInline\| + +\endinput + +% vim:tw=77: diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/cleantmp b/Master/texmf-dist/doc/support/asymptote-by-example/src/cleantmp new file mode 100644 index 00000000000..0c42a47a24f --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/cleantmp @@ -0,0 +1,4 @@ +#!/bin/sh +rm main-??.pdf +rm *.bak *.???~ +rm *.log *.aux *.toc *.out *.ilg *.ind *.idx *.bbl *.blg diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/CJKmove.sty b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/CJKmove.sty new file mode 100644 index 00000000000..e85eb526a90 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/CJKmove.sty @@ -0,0 +1,120 @@ +%# -*- coding:GBK -*- +% CJKmove.sty +% +% ƶ CJK ַʹù̶λúʹС1em bounding box +% ֱŰʱַƫƵУ +% ˺ CJK xeCJK Ч +% +% ߣmilksea + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{CJKmove}[2008/08/10 ver 0.1] + +% frame ѡÿ CJK ַ߿鿴ַ bounding box λ +\newif\if@CJK@framed +\@CJK@framedfalse +\DeclareOption{frame}{\@CJK@framedtrue} +\DeclareOption{noframe}{\@CJK@framedfalse} +\DeclareOption*{% + \PackageWarning{CJKmove}{Unknown option \CurrentOption}% +} +\ProcessOptions + +\ifx\XeTeXinputencoding\undefined + \RequirePackage{CJK} +\else + \RequirePackage{xeCJK} +\fi + +% \CJK@symbolԭĶ +\let\CJK@symbol\CJKsymbol + +% ƶ CJK ַ +\def\CJK@moved@symbol#1{% + \leavevmode + \vbox to 1em{% + \vss + \hbox to 1em{% + \raise\CJK@movey em\hbox{\kern\CJK@movex em\CJK@symbol{#1}}\hss + }% + }% +} + +% ӿ CJK ַ +\def\CJK@framed@symbol#1{% + \bgroup + \fboxsep=0pt + \fbox{\CJK@symbol{#1}}% + \egroup +} + +% ӿƶ CJK ַ +\def\CJK@moveframed@symbol#1{% + \bgroup + \fboxsep=0pt + \fbox{\CJK@moved@symbol{#1}}% + \egroup +} + +% ݼӿѡض CJK ַ +\if@CJK@framed + \def\CJKmove{\let\CJKsymbol\CJK@moveframed@symbol} + \def\CJKnomove{\let\CJKsymbol\CJK@framed@symbol} +\else + \def\CJKmove{\let\CJKsymbol\CJK@moved@symbol} + \def\CJKnomove{\let\CJKsymbol\CJK@symbol} +\fi + +% ַͬ +\def\CJKpunctsymbol{\expandafter\CJKsymbol} + +% 趨ˮƽҺֱϵƶ룬Ϊ֣λ em +\def\setCJKmove#1#2{ + \def\CJK@movex{#1}% + \def\CJK@movey{#2}% +} +% Ĭƶ룺SimSun vertical ģʽ +\def\resetCJKmove{% + \def\CJK@movex{0}% + \def\CJK@movey{0.4}% +} + +% ʼ +\resetCJKmove +\CJKnomove + +\endinput + + +ѡ + + frame CJK ַӿ + + noframe ӿ + + +÷ + + \CJKmove CJK ַƶģʽ + + \CJKnomove CJK ַƶģʽ + + \setCJKmove <x> <y> x em y em + + \resetCJKmove ƶ룬ĬΪ 0.4em SimSun + + +ע + + ͬҪòͬƶ + + +BUG + + bounding box ƺĻDz + + +TODO + + ֲ֧ȿġɹ涨ȺͿƽƵ bounding box + diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/area.asy b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/area.asy new file mode 100644 index 00000000000..d6234f546f1 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/area.asy @@ -0,0 +1,37 @@ +// 一段 Bezier 曲线的面积(相对 x 轴,逆时钟环绕为正)
+// 直接利用 S = ∫-y(t)*x'(t) dt 做 0 到 1 的定积分得到
+// 其中 z(t) = (x(t), y(t)) = (1-t)^3*z0 + 3t*(1-t)^2*c0 + 3t^2*(1-t)*c1 + t^3*z1
+private real area(pair z0, pair c0, pair c1, pair z1)
+{
+ return (3*c1.y*(z0.x - 2*z1.x) - z0.y*(3*c1.x - 10*z0.x + z1.x)
+ - 3*c0.y*(c1.x - 2*z0.x + z1.x) + (6*c1.x + z0.x - 10*z1.x)*z1.y
+ + 3*c0.x*(c1.y - 2*z0.y + z1.y))/20.;
+}
+
+// 一条路径的有向面积
+// 仅当路径是闭合的时候,有正确的几何意义,此时应具有平移不变性
+real area(path[] p)
+{
+ real A = 0;
+ for (path g : p) {
+ for (int i = 0; i < length(g); ++i) {
+ pair z0 = point(g, i), z1 = point(g, i+1);
+ pair c0 = postcontrol(g, i), c1 = precontrol(g, i+1);
+ A += area(z0, c0, c1, z1);
+ }
+ }
+ return A;
+}
+
+
+// 应返回 3.14xxx 和 -314.xxx,后面的位不准
+write(area(unitcircle));
+write(area(reverse(circle((-2,3), 10))));
+
+import graph;
+// 应返回 3.14159265358979 和 -314.159265358979,这里 15 位都是准确的
+write(area(Circle((0,0), 1)));
+write(area(reverse(Circle((-2,3), 10))));
+
+write(area(Circle((0,0), 1, 16)));
+write(nCircle);
diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/hanoi.asy b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/hanoi.asy new file mode 100644 index 00000000000..8470c4ae2ef --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/hanoi.asy @@ -0,0 +1,95 @@ +struct Peg
+{
+ private struct Disk
+ {
+ private int size;
+
+ picture draw(pen p = pink+1mm)
+ {
+ picture pic;
+ fill(pic, scale(5mm+size*7.5mm, 4mm)*box((-1/2,-1/2),(1/2,1/2)), p);
+ label(pic, string(size));
+ return pic;
+ }
+ void operator init(int size)
+ {
+ this.size = size;
+ }
+ }
+
+ private Disk[] disks;
+ private string name;
+
+ string getname()
+ {
+ return name;
+ }
+
+ picture draw(pen p = blue+1mm)
+ {
+ picture pic;
+ int n = disks.length;
+ fill(pic, box((-2mm, -4mm),(2mm,40mm)), gray);
+ fill(pic, box((-4cm, -10mm), (4cm, -4mm)), gray);
+ label(pic, name, (0,-5mm), align=down);
+ for (int k = 0; k < n; ++k)
+ add(pic, disks[k].draw(), (0,k*5mm));
+ return pic;
+ }
+
+ void operator init(int n, string name)
+ {
+ for (int k = n; k > 0; --k)
+ disks.push(Disk(k));
+ this.name = name;
+ }
+
+ static void transfer(Peg a, Peg b)
+ {
+ Disk disk = a.disks.pop();
+ b.disks.push(disk);
+ }
+}
+from Peg unravel transfer;
+
+
+import animation;
+//usepackage("animate");
+//usepackage("movie15");
+settings.tex = "pdflatex";
+
+void solvehanoi(int n)
+{
+ animation ani;
+ int step = 0;
+ Peg A = Peg(n,"A"), B = Peg(0,"B"), C = Peg(0,"C");
+
+ picture pic;
+ add(pic, A.draw().fit(), 0, align=NW);
+ add(pic, B.draw().fit(), 0, align=NE);
+ add(pic, C.draw().fit(), 0, align=S);
+ ani.add(pic);
+ void solve(Peg src, Peg dest, Peg mid, int k)
+ {
+ if (k != 0) {
+ solve(src, mid, dest, k-1);
+
+ transfer(src, dest);
+ ++step;
+ write(format("%3d: ", step)
+ + src.getname() + " -> " + dest.getname());
+ picture pic;
+ add(pic, A.draw().fit(), 0, align=NW);
+ add(pic, B.draw().fit(), 0, align=NE);
+ add(pic, C.draw().fit(), 0, align=S);
+ ani.add(pic);
+
+ solve(mid, dest, src, k-1);
+ }
+ }
+ solve(A, B, C, n);
+ //label(ani.pdf(delay=500));
+ ani.movie(delay=500);
+}
+
+solvehanoi(2);
diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/hyper.asy b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/hyper.asy new file mode 100644 index 00000000000..d61a5183c51 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/hyper.asy @@ -0,0 +1,54 @@ +real r = 5cm;
+
+draw(circle(0,r), black+1);
+dot(0);
+
+path hyperline(pair origin, real r, real deg1, real deg2, bool iscycle=false)
+{
+ deg1 %= 360;
+ deg2 %= 360;
+ bool isCCW;
+ if (abs(deg1-deg2) == 180) {
+ if (iscycle)
+ return shift(origin) * (arc(0, r*dir(deg1), r*dir(deg2)) -- cycle);
+ else
+ return shift(origin) * (r*dir(deg1) -- r*dir(deg2));
+ }
+ if (deg1 > deg2) {
+ if (deg1-deg2 > 180) {
+ deg1 -= 360;
+ isCCW = true;
+ }
+ else
+ isCCW = false;
+ }
+ else {
+ if (deg2-deg1 > 180) {
+ deg2 -= 360;
+ isCCW = false;
+ }
+ else
+ isCCW = true;
+ }
+
+ real delta = isCCW ? deg2-deg1 : deg1-deg2;
+ pair z1 = r * dir(deg1), z2 = r * dir(deg2);
+ real rad = r/Cos(delta/2);
+ pair c = rad * dir((deg1+deg2)/2);
+ if (iscycle)
+ return shift(origin) *
+ (arc(c, z1, z2, !isCCW) & arc(0, z2, z1, !isCCW)) -- cycle;
+ else
+ return shift(origin) * arc(c, z1, z2, !isCCW);
+}
+
+path[] g1, g2;
+for (real t = 30; t <= 180; t += 30) {
+ for (real angle = 0; angle < 360; angle += 30) {
+ g1.push(hyperline(0, r, angle, angle+t, true));
+ g2.push(hyperline(0, r, angle, angle+t, false));
+ }
+}
+fill(g1, evenodd);
+draw(g2, orange+0.6);
+shipout(bbox(Fill(white)));
diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/movie15.sty b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/movie15.sty new file mode 100644 index 00000000000..fa3ac0aa929 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/movie15.sty @@ -0,0 +1,4259 @@ +% Copyright 2004--2008 Alexander Grahn +% +% This material is subject to the LaTeX Project Public License. See +% http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +% for the details of that license. +% +% This package allows inclusion of multimedia content into PDF files +% following Adobe's PDF-1.5 and 1.6 specifications. +% + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{movie15}[2008/10/08] +\RequirePackage{keyval} +\RequirePackage{ifthen} +\RequirePackage{ifpdf} +\RequirePackage{ifdraft} + +\newboolean{@MXV@iiiDfeat} % enable 3D features from PDF-1.6 spec? +\setboolean{@MXV@iiiDfeat}{false}% +\newboolean{@MXV@iiid} %set to true if a 3D file is being embedded +\newboolean{@MXV@draft} %according to global setting +\newboolean{@MXV@@draft} %per inclusion setting + +\ifdraft{%globally set by document class + \setboolean{@MXV@draft}{true}% +}{% + \setboolean{@MXV@draft}{false}% +}% + +%override global setting +\DeclareOption{draft}{% + \setboolean{@MXV@draft}{true}% +} +\DeclareOption{final}{% + \setboolean{@MXV@draft}{false}% +} + +\DeclareOption{3D}{% + \setboolean{@MXV@iiiDfeat}{true}% +} + +\newboolean{@MXV@dvips} +\newboolean{@MXV@dvipdfmx} +\ifpdf + \setboolean{@MXV@dvips}{true} +\else + \setboolean{@MXV@dvips}{false} +\fi +\setboolean{@MXV@dvipdfmx}{false} + +\DeclareOption{dvips}{% + \setboolean{@MXV@dvips}{true}% + \setboolean{@MXV@dvipdfmx}{false}% +} +\DeclareOption{dvipdfmx}{% + \setboolean{@MXV@dvips}{false}% + \setboolean{@MXV@dvipdfmx}{true}% +} + +\DeclareOption*{% + \PackageWarning{movie15}{Unknown option \CurrentOption} +} + +\ProcessOptions*\relax + +%testing for correct TeX version, +\ifpdf + \ifnum\pdftexversion<120 + \PackageError{movie15}{% + pdfeTeX, version >= 1.20, required + }{% + Install a more recent version! + }% + \fi +\fi + +\ifx\@undefined\pdfmdfivesum + \def\pdfmdfivesum file #1{#1} +\fi + +%for conditionals where \ifthenelse doesn't work +\gdef\@MXV@if#1{\csname if#1\endcsname}% + +\newboolean{@MXV@beamer} %set to true if beamer class has been loaded +%\newboolean{@MXV@powerdot} %the same for +\newboolean{@MXV@presentation} %used with presentation making package? +\newboolean{@MXV@hide} %contents hidden on the current slide? +\@ifclassloaded{beamer}{% + \setboolean{@MXV@beamer}{true}% + \setboolean{@MXV@presentation}{true}% +}{% + \setboolean{@MXV@beamer}{false}% + \setboolean{@MXV@presentation}{false}% +} +%\@ifclassloaded{powerdot}{% +% \setboolean{@MXV@powerdot}{true}% +% \setboolean{@MXV@presentation}{true}% +%}{% +% \setboolean{@MXV@powerdot}{false}% +% \setboolean{@MXV@presentation}{false}% +%} + +\AtBeginDocument{% + \provideboolean{Hy@colorlinks}% set by hyperref + \ifHy@colorlinks% coloured (movieref-)link text instead of link border + \gdef\@MXV@pdfborder{/Border [0 0 0]}% + \else% + \gdef\@MXV@pdfborder{}% + \fi% +} + +\RequirePackage{everyshi}% +\newcount\@MXV@page% counter for absolute page number +\EveryShipout{% + \global\advance\@MXV@page by 1% +} + +%define our own label making commands +\def\@MXV@newlabel#1#2{{% + \expandafter\xdef\csname#1\endcsname{#2}}}% + +\def\@MXV@getlabelvalue#1{% + \expandafter\ifx\csname#1\endcsname\relax% + undefined% + \else% + \csname#1\endcsname% + \fi% +}% + +%macro for writing labels to external *.aux file +\def\@MXV@labeltoaux#1#2{% + \@bsphack\protected@write\@auxout{}{% + \string\@MXV@newlabel{#1}{#2}% + \string\@MXV@newlabel{@#1@}{\@MXV@getlabelvalue{#1}}% + }\@esphack% + \ifthenelse{% + \equal{\@MXV@getlabelvalue{#1}}{undefined}\OR% + %double check that the value hasn't changed + \NOT\equal{\@MXV@getlabelvalue{#1}}{\@MXV@getlabelvalue{@#1@}}% + }{% + \ifthenelse{\isundefined{\@MXV@warning}}{% issue warning only once, at end + \gdef\@MXV@warning{}% of document + \AtEndDocument{% + \PackageWarningNoLine{movie15}{% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\MessageBreak + @@ Rerun to get object references right! @@\MessageBreak + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}% + }% + }{}% + }{}% +}% +% +\ifpdf% + %for storing pdf object numbers (must be counters) + \newcount\@MXV@adict% + \newcount\@MXV@aadict% + % + %returns pdf page object number + \def\@MXV@pdfpageref#1{% + \expandafter\ifx\csname#1\endcsname\relax% + 0% + \else% + \expandafter\pdfpageref\csname#1\endcsname\space% + \fi% + }% +\else\if@MXV@dvipdfmx%do nothing +\else% + \PassOptionsToPackage{pdfmark}{hyperref}% +\fi\fi + +%counter for absolute number of inclusions, +%used for labelling each annotation +\newcount\@MXV@includes + +%counter for absolute number of movie players +\newcount\@MXV@players + +%counter for absolute number of movierefs +\newcount\@MXV@links + +%measuring things +%textbox +\newdimen\@MXV@width +\newdimen\@MXV@height +\newdimen\@MXV@depth +\newdimen\@MXV@totalheight +\newdimen\@MXV@@boxdepth +%for centring the textbox within display box +\newdimen\@MXV@traiselen +\newdimen\@MXV@braiselen +%for compatibility options +\newdimen\@MXV@start +\newdimen\@MXV@end + +%stores textbox given as argument to text option +\newsavebox{\@MXV@textbox} + +%some booleans we need +\newboolean{@MXV@autoplay} +\newboolean{@MXV@autostop} +\newboolean{@MXV@autoresume} +\newboolean{@MXV@autoclose} +\newboolean{@MXV@autopause} +\newboolean{@MXV@mouse}%mouse interaction +\newboolean{@MXV@inline}%inline movie data +\newboolean{@MXV@attachment}%make embedded file extractable? +\newboolean{@MXV@externalviewer}%if true, screen annot will be removed +\newboolean{@MXV@url} +\newboolean{@MXV@boxopt}%true if text option is set +\newboolean{@MXV@textoverposter} +\newboolean{@MXV@runposter}% render poster from movie at runtime +\newboolean{@MXV@linkplay}% for \movieref command +\newboolean{@MXV@linkpause} +\newboolean{@MXV@linkresume} +\newboolean{@MXV@linkstop} +\newboolean{@MXV@linkclose} +\newboolean{@MXV@linkreset} +\newboolean{@MXV@issound} + +%macro to reset all macros and booleans +\def\@MXV@reset{% + \setboolean{@MXV@autoplay}{false}% + \setboolean{@MXV@autostop}{true}% + \setboolean{@MXV@autoresume}{false}% + \setboolean{@MXV@autopause}{false}% + \setboolean{@MXV@autoclose}{false}% + \setboolean{@MXV@mouse}{false}% + \setboolean{@MXV@inline}{true}% + \setboolean{@MXV@attachment}{true}% + \setboolean{@MXV@externalviewer}{false}% + \setboolean{@MXV@issound}{false}% + \setboolean{@MXV@url}{false}% + \setboolean{@MXV@boxopt}{false}% + \setboolean{@MXV@textoverposter}{true}% + \setboolean{@MXV@runposter}{false}% + \setboolean{@MXV@linkplay}{true}% + \setboolean{@MXV@linkpause}{false}% + \setboolean{@MXV@linkresume}{false}% + \setboolean{@MXV@linkstop}{false}% + \setboolean{@MXV@linkclose}{false}% + \setboolean{@MXV@linkreset}{false}% + \setboolean{@MXV@requirereopen}{false}% + \ifthenelse{\boolean{@MXV@draft}}{% + \setboolean{@MXV@@draft}{true}% + }{% + \setboolean{@MXV@@draft}{false}% + }% + % + \gdef\@MXV@label{}% for movieref + \gdef\@MXV@@label{}% for movieref + \gdef\@MXV@mime{@MXV@auto}% + \gdef\@MXV@player{}% + \gdef\@MXV@fsentry{}% + \gdef\@MXV@repeat{}% + \gdef\@MXV@@repeat{}% + \gdef\@MXV@volume{100}% + \gdef\@MXV@@volume{}% + \gdef\@MXV@ctrls{}% + \gdef\@MXV@@ctrls{}% + \gdef\@MXV@palindrome{}% + \gdef\@MXV@rate{}% + \gdef\@MXV@startat{}% + \gdef\@MXV@@startat{}% + \gdef\@MXV@endat{}% + \gdef\@MXV@poevent{}% + \gdef\@MXV@pcevent{}% + \gdef\@MXV@box##1##2##3{\raisebox{0pt}[##2][##3]{\makebox[##1]{}}}% + \setlength{\@MXV@depth}{0pt}% + \setlength{\@MXV@height}{0pt}% + \setlength{\@MXV@width}{0pt}% + \setlength{\@MXV@braiselen}{0pt}% + \setlength{\@MXV@traiselen}{0pt}% + \gdef\@MXV@boxdepth{}% + \gdef\@MXV@boxheight{}% + \gdef\@MXV@boxwidth{}% + % + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \setboolean{@MXV@iiid}{false}% + \gdef\@MXV@aac{30}% aperture angle of camera + \gdef\@MXV@roll{0}% camera roll angle + \gdef\@MXV@background{}% + \gdef\@MXV@jscriptiiidfile{}% + \gdef\@MXV@coo{0 0 0}% centre of orbit + \gdef\@MXV@ctoc{0 -1 0}% centre of orbit to camera vector + \gdef\@MXV@roo{0}% radius of orbit + \gdef\@MXV@viewsfile{}% file containing views of the 3D object + \setboolean{@MXV@viewsprovided}{false}% + \setboolean{@MXV@defaultviewprovided}{false}% + \gdef\@MXV@iiidview{}% + \gdef\@MXV@iiidtoolb{/TB false}% don't show toolbar by default + \gdef\@MXV@iiidia{}% 3D interactive by default + \gdef\@MXV@calc{}% camera aperture for coo and roo calculation + \setboolean{@MXV@iiidgetview}{false}% + \gdef\@MXV@iiidopt{}% option string to be passed to internal macro + \setboolean{@MXV@resource}{false}% + \gdef\@MXV@resourcetree{}% name tree of embedded 3D resources + \xdef\@MXV@animstyle{}% + \gdef\@MXV@iiidpalindrome{/Subtype/Linear}% forward + \gdef\@MXV@iiidrate{}% animation speed + \global\@MXV@iiidrepeat=-1% repeat count + \gdef\@MXV@lights{}% default lighting scheme + \gdef\@MXV@render{}% default render mode scheme + }{}% +}% + +%missing package error message +\def\@MXV@missing#1{% + \PackageError{movie15}{% + Package `#1' has not been loaded yet + }{% + Put the line `\protect\usepackage{#1}' somewhere after + `\protect\usepackage{movie15}' to the preamble of your + document! + }% +} + +%3D-need-be-enabled error message +\def\@MXV@neediiiD{% + \PackageError{movie15}{% + If you wish to embed 3D objects, enable the\MessageBreak + 3D feature first by passing option `3D' to movie15!\MessageBreak + Make sure the `fp' package for fixed point calculus\MessageBreak + is installed in your TeX system + }{Package `fp' is available from CTAN.}% +} + +%macro to guess the mime type of the media file +\def\@MXV@guessmime#1#2{% + \ifthenelse{\equal{#2}{aiff}\OR\equal{#2}{AIFF}\OR% + \equal{#2}{aif}\OR\equal{#2}{AIF}\OR% + \equal{#2}{aifc}\OR\equal{#2}{AIFC}}{% + \gdef\@MXV@mime{audio/aiff}% + }{% + \ifthenelse{\equal{#2}{wav}\OR\equal{#2}{WAV}}{% + \gdef\@MXV@mime{audio/wav}% + }{% + \ifthenelse{\equal{#2}{wma}\OR\equal{#2}{WMA}}{% + \gdef\@MXV@mime{audio/x-ms-wma}% + }{% + \ifthenelse{\equal{#2}{wmv}\OR\equal{#2}{WMV}}{% + \gdef\@MXV@mime{video/x-ms-wmv}% + }{% + \ifthenelse{\equal{#2}{au}\OR\equal{#2}{AU}\OR% + \equal{#2}{snd}\OR\equal{#2}{SND}}{% + \gdef\@MXV@mime{audio/basic}% + }{% + \ifthenelse{\equal{#2}{mid}\OR\equal{#2}{MID}\OR% + \equal{#2}{rmi}\OR\equal{#2}{RMI}}{% + \gdef\@MXV@mime{audio/midi}% + }{% + \ifthenelse{\equal{#2}{mov}\OR\equal{#2}{MOV}\OR% + \equal{#2}{qt}\OR\equal{#2}{QT}}{% + \gdef\@MXV@mime{video/quicktime}% + }{% + \ifthenelse{\equal{#2}{mp3}\OR\equal{#2}{MP3}\OR% + \equal{#2}{m3u}\OR\equal{#2}{M3U}}{% + \gdef\@MXV@mime{audio/x-mp3}% + }{% + \ifthenelse{\equal{#2}{mp4}\OR\equal{#2}{MP4}}{% + \gdef\@MXV@mime{video/mp4}% + }{% + \ifthenelse{\equal{#2}{avi}\OR\equal{#2}{AVI}}{% + \gdef\@MXV@mime{video/avi}% + }{% + \ifthenelse{\equal{#2}{gif}\OR\equal{#2}{GIF}}{% + \gdef\@MXV@mime{image/gif}% + }{% + \ifthenelse{\equal{#2}{mpeg}\OR\equal{#2}{MPEG}\OR% + \equal{#2}{mpg}\OR\equal{#2}{MPG}}{% + \gdef\@MXV@mime{video/mpeg}% + }{% + \ifthenelse{\equal{#2}{smil}\OR\equal{#2}{SMIL}}{% + \gdef\@MXV@mime{application/smil}% + }{% + \ifthenelse{\equal{#2}{swf}\OR\equal{#2}{SWF}}{% + \gdef\@MXV@mime{application/x-shockwave-flash}% + }{% + \ifthenelse{\equal{#2}{prc}\OR\equal{#2}{PRC}}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \setboolean{@MXV@iiid}{true}% + \gdef\@MXV@mime{model/prc}% (unofficial) + \gdef\@MXV@iiidsubtype{PRC}% + }{% + \@MXV@neediiiD% + }% + }{% + \ifthenelse{\equal{#2}{u3d}\OR\equal{#2}{U3D}}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \setboolean{@MXV@iiid}{true}% + \gdef\@MXV@mime{model/u3d}% (unofficial) + \gdef\@MXV@iiidsubtype{U3D}% + }{% + \@MXV@neediiiD% + }% + }{% + \ifthenelse{\equal{#2}{ra}\OR\equal{#2}{RA}}{ + \gdef\@MXV@mime{audio/vnd.rn-realaudio}% + }{% + \ifthenelse{% + \equal{#2}{rv}\OR\equal{#2}{RV}\OR + \equal{#2}{rm}\OR\equal{#2}{RM}% + }{% + \gdef\@MXV@mime{application/vnd.rn-realmedia}% + }{% + \PackageError{movie15}{% + I couldn't determine MIME type of file:\MessageBreak`#1':\MessageBreak + Unknown file name extension: `#2' + }{% + When using media files of unknown type or with a\MessageBreak + non-standard file name extension, the MIME type must\MessageBreak + explicitly be specified. Try option `mimetype=<mime type>'! + }% + }}}}}}}}}}}}}}}}}}% +} + +%sets @MXV@issound boolean +\def\@MXV@@issound#1/#2:{% argument: \@MXV@mime. + \def\@MXV@firstarg{#1}% + \def\@MXV@audio{audio}% + \ifx\@MXV@firstarg\@MXV@audio% + \setboolean{@MXV@issound}{true}% + \fi% +} + +%draft box +\def\@MXV@draftbox#1#2#3#4{%width height depth filename + \edef\@MXV@oldfboxsep{\the\fboxsep}% + \setlength{\fboxsep}{-\fboxrule}% + \framebox[#1][l]{% + \vrule width 0pt height #2 depth #3% + \edef\@tempa{#4}% + \raisebox{\depth}[0pt][0pt]{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}% + }% + \setlength{\fboxsep}{\@MXV@oldfboxsep}% +} + +\ifthenelse{\boolean{@MXV@iiiDfeat}}{% 3D related definitions and macros + \RequirePackage{fp}% needed for fixed point calculus + \newread\@MXV@@viewsfile% file handle for views file + \newcount\@MXV@viewscount%counter for number of 3D views per inclusion + \newboolean{@MXV@viewsprovided}%3d views file provided? + \newboolean{@MXV@iiidgetview}% print current 3D settings? + \newboolean{@MXV@defaultviewprovided}%default 3D view provided? + \newboolean{@MXV@resource}%3d resource file provided? + \ifpdf\else\newcount\@MXV@rescount\fi% number of embedded resource files + \newcount\@MXV@iiidrepeat% play count + \newcount\@MXV@iiidoncurpage%index of 3D annot on current page + \global\@MXV@iiidoncurpage=0% + \gdef\@MXV@oldpage{0}% needed together with previous counter + + %macro for building the transformation matrix + \def\@MXV@ciiwmatrix#1 #2 #3 #4 #5 #6 #7 #8 {% + % #1,#2,#3 centre of orbit coordinates (coo) + % #4,#5,#6 centre of orbit to camera direction vector (c2c) + % #7 orbital radius (roo) + % #8 camera roll (roll) + %view vector (opposite to c2c) + \FPupn\@MXV@viewx{#4 neg}% + \FPupn\@MXV@viewy{#5 neg}% + \FPupn\@MXV@viewz{#6 neg}% + %normalize view vector + \FPupn\@MXV@modulo{\@MXV@viewx{} copy mul % + \@MXV@viewy{} copy mul + % + \@MXV@viewz{} copy mul + 2 swap root% + }% + \FPupn\@MXV@viewx{\@MXV@viewx{} \@MXV@modulo{} div}% + \FPupn\@MXV@viewy{\@MXV@viewy{} \@MXV@modulo{} div}% + \FPupn\@MXV@viewz{\@MXV@viewz{} \@MXV@modulo{} div}% + %camera roll + \FPupn\@MXV@sinroll{#8 180.0 div \FPpi{} mul sin}% + \FPupn\@MXV@cosroll{#8 180.0 div \FPpi{} mul cos}% + % + %top and bottom views + \FPupn\@MXV@leftx{-1.0}% + \FPupn\@MXV@lefty{0.0}% + \FPupn\@MXV@leftz{0.0}% + % + \FPifneg\@MXV@viewz% top view + %up-vector + \FPupn\@MXV@upx{0.0}% + \FPupn\@MXV@upy{1.0}% + \FPupn\@MXV@upz{0.0}% + \else% bottom view + %up-vector + \FPupn\@MXV@upx{0.0}% + \FPupn\@MXV@upy{-1.0}% + \FPupn\@MXV@upz{0.0}% + \fi% + \FPupn\@MXV@sumxy{\@MXV@viewx{} abs \@MXV@viewy{} abs add}% + \FPifeq\@MXV@sumxy{0}\else% other views than top and bottom + %up-vector = up_world - (up_world dot view) view + \FPupn\@MXV@upx{\@MXV@viewz{} \@MXV@viewx{} mul neg}% + \FPupn\@MXV@upy{\@MXV@viewz{} \@MXV@viewy{} mul neg}% + \FPupn\@MXV@upz{\@MXV@viewz{} \@MXV@viewz{} mul neg 1.0 add}% + %normalize up-vector + \FPupn\@MXV@modulo{\@MXV@upx{} copy mul \@MXV@upy{} copy % + mul + \@MXV@upz{} copy mul + 2 swap root}% + \FPupn\@MXV@upx{\@MXV@upx{} \@MXV@modulo{} div}% + \FPupn\@MXV@upy{\@MXV@upy{} \@MXV@modulo{} div}% + \FPupn\@MXV@upz{\@MXV@upz{} \@MXV@modulo{} div}% + %left vector = up x view + \FPupn\@MXV@leftx{\@MXV@viewz{} \@MXV@upy{} mul % + \@MXV@viewy{} \@MXV@upz{} mul sub}% + \FPupn\@MXV@lefty{\@MXV@viewx{} \@MXV@upz{} mul % + \@MXV@viewz{} \@MXV@upx{} mul sub}% + \FPupn\@MXV@leftz{\@MXV@viewy{} \@MXV@upx{} mul % + \@MXV@viewx{} \@MXV@upy{} mul sub}% + %normalize left vector + \FPupn\@MXV@modulo{\@MXV@leftx{} copy mul \@MXV@lefty{} % + copy mul + \@MXV@leftz{} copy mul + 2 swap root}% + \FPupn\@MXV@leftx{\@MXV@leftx{} \@MXV@modulo{} div}% + \FPupn\@MXV@lefty{\@MXV@lefty{} \@MXV@modulo{} div}% + \FPupn\@MXV@leftz{\@MXV@leftz{} \@MXV@modulo{} div}% + \fi% + %apply camera roll + \FPupn\@MXV@leftxprime{\@MXV@leftx{} \@MXV@cosroll{} mul \@MXV@upx{} \@MXV@sinroll{} mul +}% + \FPupn\@MXV@leftyprime{\@MXV@lefty{} \@MXV@cosroll{} mul \@MXV@upy{} \@MXV@sinroll{} mul +}% + \FPupn\@MXV@leftzprime{\@MXV@leftz{} \@MXV@cosroll{} mul \@MXV@upz{} \@MXV@sinroll{} mul +}% + \FPupn\@MXV@upxprime{\@MXV@upx{} \@MXV@cosroll{} mul \@MXV@leftx{} \@MXV@sinroll{} mul sub}% + \FPupn\@MXV@upyprime{\@MXV@upy{} \@MXV@cosroll{} mul \@MXV@lefty{} \@MXV@sinroll{} mul sub}% + \FPupn\@MXV@upzprime{\@MXV@upz{} \@MXV@cosroll{} mul \@MXV@leftz{} \@MXV@sinroll{} mul sub}% + \FPupn\@MXV@leftx{\@MXV@leftxprime}% + \FPupn\@MXV@lefty{\@MXV@leftyprime}% + \FPupn\@MXV@leftz{\@MXV@leftzprime}% + \FPupn\@MXV@upx{\@MXV@upxprime}% + \FPupn\@MXV@upy{\@MXV@upyprime}% + \FPupn\@MXV@upz{\@MXV@upzprime}% + %rotation matrix + \xdef\@MXV@matrix{\@MXV@leftx\space\@MXV@lefty\space\@MXV@leftz\space% + \@MXV@upx\space\@MXV@upy\space\@MXV@upz\space% + \@MXV@viewx\space\@MXV@viewy\space\@MXV@viewz}% + %translation vector + \FPupn\@MXV@roo{#7 abs}% + \FPifeq\@MXV@roo{0}\FPupn\@MXV@roo{0.000000000000000001}\fi% + \FPupn\@MXV@transx{#1 \@MXV@roo{} \@MXV@viewx{} mul sub}% + \FPupn\@MXV@transy{#2 \@MXV@roo{} \@MXV@viewy{} mul sub}% + \FPupn\@MXV@transz{#3 \@MXV@roo{} \@MXV@viewz{} mul sub}% + %transformation matrix + \xdef\@MXV@matrix{% + \@MXV@matrix\space\@MXV@transx\space\@MXV@transy\space\@MXV@transz% + }% + } + + %macro for parsing one line of 3D views file + \newcommand{\@MXV@parseline}[6][]{% + \xdef\@MXV@xname{#1}% name of the view (optional) + \ifthenelse{\equal{#2}{}}{% + \xdef\@MXV@coo{0 0 0}% + }{% + \xdef\@MXV@coo{#2}% + }% + \ifthenelse{\equal{#3}{}}{% + \xdef\@MXV@ctoc{0 -1 0}% + }{% + \xdef\@MXV@ctoc{#3}% + }% + \ifthenelse{\equal{#4}{}}{% + \xdef\@MXV@roo{0}% + }{% + \xdef\@MXV@roo{#4}% + }% + \ifthenelse{\equal{#5}{}}{% + \xdef\@MXV@roll{0}% + }{% + \xdef\@MXV@roll{#5}% + }% + \ifthenelse{\equal{#6}{}}{% + \xdef\@MXV@aac{30}% + }{% + \xdef\@MXV@aac{#6}% + }% + } + + %macro for generating an array of 3D views (varray) + \def\@MXV@buildva{% + \global\@MXV@viewscount=0% + \xdef\@MXV@varray{}% empty varray + % + %default view + \edef\@MXV@args{\@MXV@coo\space\@MXV@ctoc\space\@MXV@roo\space\@MXV@roll\space}% + \expandafter\@MXV@ciiwmatrix\@MXV@args% build C2W matrix + \xdef\@MXV@xname{Default}% + \@MXV@viewobj% create pdf object of 3D view + \edef\@MXV@defaultview{\@MXV@@viewobj}% + % + %read out 3D views file + \IfFileExists{\@MXV@viewsfile}{% + \edef\@MXV@endlinechar{\the\endlinechar}% + \endlinechar=-1% suppress trailing space at input line end + \openin\@MXV@@viewsfile=\@MXV@viewsfile% + \loop% + \read\@MXV@@viewsfile to \@MXV@inputline% + \if\@MXV@inputline\relax\else% + \expandafter\@MXV@parseline\@MXV@inputline% + \edef\@MXV@args{\@MXV@coo\space\@MXV@ctoc\space\@MXV@roo\space\@MXV@roll\space}% + \expandafter\@MXV@ciiwmatrix\@MXV@args% build C2W matrix + \global\advance\@MXV@viewscount by 1% + \ifthenelse{\equal{\@MXV@xname}{}}{% + \xdef\@MXV@xname{View \the\@MXV@viewscount}% + }{}% + \@MXV@viewobj% create pdf object of 3D view + %append current view obj ref to VA array + \xdef\@MXV@varray{\@MXV@varray\space\@MXV@@viewobj}% + \setboolean{@MXV@viewsprovided}{true}% + \repeat% + \closein\@MXV@@viewsfile% + \endlinechar=\@MXV@endlinechar% reset endlinechar + }{}% + % + %make the first view in the VA array the default view, if no default one has + %explicitly been provided, but if the VA array itself is empty too (no + %additional views provided) use our fallback view (c2c=0 -1 0) as default + \ifthenelse{\NOT\boolean{@MXV@defaultviewprovided}% + \AND\boolean{@MXV@viewsprovided}}{% + \xdef\@MXV@defaultview{/3DV /F}% + }{% + \xdef\@MXV@defaultview{/3DV \@MXV@defaultview}% + }% + } + + %following macros, including the 3D inclusion macro have driver specific + %implementations + \ifpdf% + %pdfLaTeX versions + %macro for creating 3D view object + \def\@MXV@viewobj{% + %projection dict + \pdfobj {<</Subtype/P/FOV \@MXV@aac/PS/Min>>}% + \pdfrefobj\pdflastobj% + % + \pdfobj {<<% + /MS/M% define the view as C2W matrix + /CO \@MXV@roo% orbital radius + /P \the\pdflastobj\space 0 R% + /C2W [\@MXV@matrix]% + /XN(\@MXV@xname)% name of the view appearing in the drop down list + \@MXV@background% + \@MXV@lights% + \@MXV@render% + >>}\pdfrefobj\pdflastobj% + \xdef\@MXV@@viewobj{\the\pdflastobj\space 0 R}% + }% + + %macro for creating resource objects from 3D and image files, to be used + %in 3D JavaScript + \def\@MXV@addresource#1{% + %determine file type + \filename@parse{#1}% + \ifthenelse{% + \equal{\filename@ext}{u3d}\OR% + \equal{\filename@ext}{U3D}% + }{% + \def\@MXV@restype{U3D}% + }{% + \def\@MXV@restype{image}% + }% + \ifthenelse{\equal{\@MXV@restype}{image}}{% + %embed the same image file only once + \ifthenelse{\equal{\@MXV@getlabelvalue{\pdfmdfivesum file {#1}}}{undefined}}{% + \immediate\pdfximage {#1}% + \xdef\@MXV@resourcetree{% build name tree for embedded resources + \@MXV@resourcetree\space (#1) \the\pdflastximage\space 0 R% + }% + \@MXV@newlabel{\pdfmdfivesum file {#1}}{\the\pdflastximage}% + }{% + \xdef\@MXV@resourcetree{% + \@MXV@resourcetree\space (#1) \@MXV@getlabelvalue{\pdfmdfivesum file {#1}}\space 0 R% + }% + }% + }{% + %embed the same 3D file only once + \ifthenelse{\equal{\@MXV@getlabelvalue{\pdfmdfivesum file {#1}}}{undefined}}{% + \pdfobj stream % + attr {% + /Subtype/\@MXV@restype% + }% + file {#1}% + \pdfrefobj\pdflastobj% + \xdef\@MXV@resourcetree{% + \@MXV@resourcetree\space (#1) \the\pdflastobj\space 0 R% + }% + \@MXV@newlabel{\pdfmdfivesum file {#1}}{\the\pdflastobj}% + }{% + \xdef\@MXV@resourcetree{% + \@MXV@resourcetree\space (#1) \@MXV@getlabelvalue{\pdfmdfivesum file {#1}}\space 0 R% + }% + }% + }% + } + + %3D inclusion macro + \newcommand{\@MXV@includeiiid}[5][]{% + %insert box or poster + \@MXV@box{#2}{#3}{#4}% + % + \if@MXV@externalviewer\else% + \setkeys{MXV@iiid}{#1}%process deferred options + \ifnum\@MXV@iiidrepeat=0\else% + \edef\@MXV@animstyle{% animation style dict + /AN <<% + \@MXV@iiidpalindrome\@MXV@iiidrate/PC \the\@MXV@iiidrepeat% + >>% + }% + \fi% + %java script file, stream object + \IfFileExists{\@MXV@jscriptiiidfile}{% + \pdfobj stream file {\@MXV@jscriptiiidfile}% + \pdfrefobj\pdflastobj% + \xdef\@MXV@jscriptiiid{/OnInstantiate \the\pdflastobj\space 0 R}% + }{\xdef\@MXV@jscriptiiid{}}% + % + %build the array of 3D views + \@MXV@buildva% + \fi% + % + %3D stream object + \if@MXV@inline% + \ifthenelse{% + \NOT\boolean{@MXV@presentation}\OR% + \equal{\@MXV@getlabelvalue{\@MXV@label.3dstream}}{undefined}% + }{% + \pdfobj stream% + attr {% + /Subtype/\@MXV@iiidsubtype% + \if@MXV@externalviewer\else% + /VA [\@MXV@varray]% + /DV/F% use first entry in VA as default view + \@MXV@animstyle% + \@MXV@jscriptiiid% + \if@MXV@resource% + /Resources <<% + /Names [\@MXV@resourcetree]% + >>% + \fi% + \fi% + }% + file {#5}% + \pdfrefobj\pdflastobj% + \edef\@MXV@iiidstream{\the\pdflastobj}% + \if@MXV@presentation% + \@MXV@newlabel{\@MXV@label.3dstream}{\@MXV@iiidstream}% + \fi% + }{% + \edef\@MXV@iiidstream{\@MXV@getlabelvalue{\@MXV@label.3dstream}}% + }% + \fi% + % + \makebox[0pt][r]{\makebox[#2][l]{% + %insert FileAttachment annotation + \ifthenelse{\boolean{@MXV@inline}\AND\boolean{@MXV@externalviewer}% +% since Reader 7.0.7, we cannot place a file attachment annot behind +% the 3D annot :-( +% \OR\boolean{@MXV@attachment} + }{% + \pdfannot width #2 height #3 depth #4 {% + /Subtype /FileAttachment% + /F 0% + /T (\@MXV@filename)% + /Contents (3D Object (\@MXV@mime))% + \if@MXV@externalviewer% + /Name/Paperclip% + /C [1 1 1]% + \else% + /AP <</N<<>>/R<<>>/D<<>>>>% + \fi% + /FS <<% + /F(#5)% + /Type/Filespec% + /EF << /F \@MXV@iiidstream\space 0 R >>% + >>% + }% + }{% + \if@MXV@url% + %insert Link annotation, if 3D file is a URL + \pdfannot width #2 height #3 depth #4 {% + /Subtype /Link% + /F 0% + \if@MXV@externalviewer% + \@MXV@urlattr% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /A <</URI (#5) /S/URI>>% + /Contents (3D Object (\@MXV@mime))% + }% + \else% + %else insert Launch action for local external 3D file + \if@MXV@inline\else% + \pdfannot width #2 height #3 depth #4 {% + /Subtype /Link% + /F 0% + \if@MXV@externalviewer% + \@MXV@runattr% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /A <<% + /F (#5)% + /S /Launch% + >>% + /Contents (3D Object (\@MXV@mime))% + }% + \fi% + \fi% + }% + % + \if@MXV@externalviewer\else% + %appearance dict dummy, to be shared by all 3D annots + \ifthenelse{\isundefined{\@MXV@apdict}}{% + \pdfobj stream attr {/BBox [0 0 0.001 0.001]} {}\pdfrefobj\pdflastobj% + \xdef\@MXV@apdict{/AP << /N \the\pdflastobj\space 0 R >>}% + }{}% + %3D reference dict + \if@MXV@presentation% + \ifthenelse{% + \equal{\@MXV@getlabelvalue{\@MXV@label.3dref}}{undefined}% + }{% + \pdfobj {<<% + /Type/3DRef% + /3DD \@MXV@iiidstream\space 0 R% 3D stream object + >>}\pdfrefobj\pdflastobj% + \edef\@MXV@iiidstreamorref{\the\pdflastobj}% + \@MXV@newlabel{\@MXV@label.3dref}{\the\pdflastobj}% + }{% + \edef\@MXV@iiidstreamorref{\@MXV@getlabelvalue{\@MXV@label.3dref}}% + }% + \else% + \edef\@MXV@iiidstreamorref{\@MXV@iiidstream}% + \fi% + %annotation object of subtype `3D' + \pdfannot width #2 height #3 depth #4 {% + /Subtype/3D% + /F 4% we cannot put F 5 here; bug in Reader; 3D annot would be + /T (\@MXV@filename)% disabled even if plugin were available + /Contents (3D Object (\@MXV@mime))% + \ifx\@MXV@@label\@empty\else% + /NM (\@MXV@@label)% + \fi% + /P \@MXV@pdfpageref{@MXV@annot\the\@MXV@includes.page}% + \@MXV@apdict% /AP <</N<<>>/R<<>>/D<<>>>> doesn't work here + \@MXV@defaultview% + \@MXV@iiidia% + /3DD \@MXV@iiidstreamorref\space 0 R% 3D stream or reference object + /3DA << \@MXV@activation\@MXV@deactivation\@MXV@iiidtoolb >>% + }% + %label for later annot obj number determination, to be used in + %movieref's + \ifx\@MXV@@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@@label.annot}{\the\pdflastannot}% + \@MXV@newlabel{@MXV@\@MXV@@label.annot}{\the\pdflastannot}% + \fi% + \fi}}% + }% + \else\if@MXV@dvipdfmx% + %dvipdfmx versions + %macro for creating 3D view object + \def\@MXV@viewobj{% + %projection dict + \special{pdf:obj @pdict\the\@MXV@includes_\the\@MXV@viewscount <<% + /Subtype/P/FOV \@MXV@aac/PS/Min% + >>}% + % + \special{pdf:obj @viewobj\the\@MXV@includes_\the\@MXV@viewscount <<% + /MS/M% define the view as C2W matrix + /CO \@MXV@roo% orbital radius + /P @pdict\the\@MXV@includes_\the\@MXV@viewscount% + /C2W [\@MXV@matrix]% + /XN(\@MXV@xname)% name of the view appearing in the drop down list + \@MXV@background% + \@MXV@lights% + \@MXV@render% + >>}% + \xdef\@MXV@@viewobj{@viewobj\the\@MXV@includes_\the\@MXV@viewscount}% + }% + + %macro for creating resource objects from 3D and image files, to be used + %in 3D JavaScript + \def\@MXV@addresource#1{% + %determine file type + \filename@parse{#1}% + \ifthenelse{% + \equal{\filename@ext}{u3d}\OR% + \equal{\filename@ext}{U3D}% + }{% + \def\@MXV@restype{U3D}% + }{% + \def\@MXV@restype{image}% + }% + \ifthenelse{\equal{\@MXV@restype}{image}}{% + %embed the same image file only once + \ifthenelse{\equal{\@MXV@getlabelvalue{\pdfmdfivesum file {#1}}}{undefined}}{% + %increment counter of embedded resource files + \global\advance\@MXV@rescount by 1% + %create Image XObject from next raster image + \special{pdf:image @resource\the\@MXV@rescount\space(#1)}% + \xdef\@MXV@resourcetree{% build name tree for embedded resources + \@MXV@resourcetree\space(#1) @resource\the\@MXV@rescount% + }% + \@MXV@newlabel{\pdfmdfivesum file {#1}}{@resource\the\@MXV@rescount}% + }{% + \xdef\@MXV@resourcetree{% + \@MXV@resourcetree\space(#1) \@MXV@getlabelvalue{\pdfmdfivesum file {#1}}% + }% + }% + }{% + %embed the same 3D file only once + \ifthenelse{\equal{\@MXV@getlabelvalue{\pdfmdfivesum file {#1}}}{undefined}}{% + \global\advance\@MXV@rescount by 1% + \special{pdf:fstream @resource\the\@MXV@rescount\space(#1) <<% + /Subtype/\@MXV@restype>>}% + \xdef\@MXV@resourcetree{% + \@MXV@resourcetree\space(#1) @resource\the\@MXV@rescount% + }% + \@MXV@newlabel{\pdfmdfivesum file {#1}}{@resource\the\@MXV@rescount}% + }{% + \xdef\@MXV@resourcetree{% + \@MXV@resourcetree\space(#1) \@MXV@getlabelvalue{\pdfmdfivesum file {#1}}% + }% + }% + }% + } + + %3D inclusion macro + \newcommand{\@MXV@includeiiid}[5][]{% + %insert box or poster + \@MXV@box{#2}{#3}{#4}% + % + \if@MXV@externalviewer\else% + \setkeys{MXV@iiid}{#1}%process deferred options + \ifnum\@MXV@iiidrepeat=0\else% + \edef\@MXV@animstyle{% animation style dict + /AN <<% + \@MXV@iiidpalindrome\@MXV@iiidrate/PC \the\@MXV@iiidrepeat% + >>% + }% + \fi% + %java script file, stream object + \IfFileExists{\@MXV@jscriptiiidfile}{% + \special{pdf:fstream @jscriptiiid\the\@MXV@includes\space(\@MXV@jscriptiiidfile)}% + \xdef\@MXV@jscriptiiid{/OnInstantiate @jscriptiiid\the\@MXV@includes}% + }{\xdef\@MXV@jscriptiiid{}}% + % + %build the array of 3D views + \@MXV@buildva% + \fi% + % + %3D stream object + \if@MXV@inline% + \ifthenelse{% + \NOT\boolean{@MXV@presentation}\OR% + \equal{\@MXV@getlabelvalue{\@MXV@label.3dstream}}{undefined}% + }{% + \special{pdf:fstream @iiiDfile\the\@MXV@includes\space(#5) <<% + /Subtype/\@MXV@iiidsubtype% + \if@MXV@externalviewer\else% + /VA [\@MXV@varray]% + /DV/F% use first entry in VA as default view + \@MXV@animstyle% + \@MXV@jscriptiiid% + \if@MXV@resource% + /Resources <</Names [\@MXV@resourcetree]>>% + \fi% + \fi% + >>}% + \edef\@MXV@iiidstream{@iiiDfile\the\@MXV@includes}% + \if@MXV@presentation% + \@MXV@newlabel{\@MXV@label.3dstream}{\@MXV@iiidstream}% + \fi% + }{% + \edef\@MXV@iiidstream{\@MXV@getlabelvalue{\@MXV@label.3dstream}}% + }% + \fi% + % + \makebox[0pt][r]{\makebox[#2][l]{% + %insert FileAttachment annotation + \ifthenelse{\boolean{@MXV@inline}\AND\boolean{@MXV@externalviewer}% +% since Reader 7.0.7, we cannot place a file attachment annot behind +% the 3D annot :-( +% \OR\boolean{@MXV@attachment} + }{% + \special{pdf:annot width \the#2 height \the#3 depth \the#4 <<% + /Subtype /FileAttachment% + /F 0% + /T (\@MXV@filename)% + /Contents (3D Object (\@MXV@mime))% + \if@MXV@externalviewer% + /Name/Paperclip% + /C [1 1 1]% + \else% + /AP <</N<<>>/R<<>>/D<<>>>>% + \fi% + /FS <<% + /F(#5)% + /Type/Filespec% + /EF << /F \@MXV@iiidstream >>% + >>% + >>}% + }{% + \if@MXV@url% + %insert Link annotation, if 3D file is a URL + \special{pdf:annot width \the#2 height \the#3 depth \the#4 <<% + /Subtype /Link% + /F 0% + \if@MXV@externalviewer% + \@MXV@urlattr% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /A <</URI (#5) /S/URI>>% + /Contents (3D Object (\@MXV@mime))% + >>}% + \else% + %else insert Launch action for local external 3D file + \if@MXV@inline\else% + \special{pdf:annot width \the#2 height \the#3 depth \the#4 <<% + /Subtype /Link% + /F 0% + \if@MXV@externalviewer% + \@MXV@runattr% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /A <<% + /F (#5)% + /S /Launch% + >>% + /Contents (3D Object (\@MXV@mime))% + >>}% + \fi% + \fi% + }% + % + \if@MXV@externalviewer\else% + %appearance dict dummy, to be shared by all 3D annots + \ifthenelse{\isundefined{\@MXV@apdict}}{% + \special{pdf:stream @apdict\space()<</BBox[0 0 0.001 0.001]>>}% + \xdef\@MXV@apdict{/AP << /N @apdict >>}% + }{}% + %3D reference dict + \if@MXV@presentation% + \ifthenelse{% + \equal{\@MXV@getlabelvalue{\@MXV@label.3dref}}{undefined}% + }{% + \special{pdf:obj @iiiDref\the\@MXV@includes <<% + /Type/3DRef% + /3DD \@MXV@iiidstream% 3D stream object + >>}% + \edef\@MXV@iiidstreamorref{@iiiDref\the\@MXV@includes}% + \@MXV@newlabel{\@MXV@label.3dref}{\the\pdflastobj}% + }{% + \edef\@MXV@iiidstreamorref{\@MXV@getlabelvalue{\@MXV@label.3dref}}% + }% + \else% + \edef\@MXV@iiidstreamorref{\@MXV@iiidstream}% + \fi% + %annotation object of subtype `3D' + \special{pdf:annot @3Dannot\the\@MXV@includes\space width \the#2 height \the#3 depth \the#4 <<% + /Subtype/3D% + /F 4% we cannot put F 5 here; bug in Reader; 3D annot would be + /T (\@MXV@filename)% disabled even if plugin were available + /Contents (3D Object (\@MXV@mime))% + \ifx\@MXV@@label\@empty\else% + /NM (\@MXV@@label)% + \fi% + /P @thispage% + \@MXV@apdict% /AP <</N<<>>/R<<>>/D<<>>>> doesn't work here + \@MXV@defaultview% + \@MXV@iiidia% + /3DD \@MXV@iiidstreamorref% 3D stream or reference object + /3DA << \@MXV@activation\@MXV@deactivation\@MXV@iiidtoolb >>% + >>}% + %label for later annot obj number determination, to be used in + %movieref's + \ifx\@MXV@@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@@label.annot}{@3Dannot\the\@MXV@includes}% + \@MXV@newlabel{@MXV@\@MXV@@label.annot}{@3Dannot\the\@MXV@includes}% + \fi% + \fi}}% + }% + \else% + %dvips versions + %macro for creating 3D view object and associated projection dict + \def\@MXV@viewobj{% + %projection dict + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {pdict\the\@MXV@includes_\the\@MXV@viewscount}% + /type/dict% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {pdict\the\@MXV@includes_\the\@MXV@viewscount} <<% + /Subtype/P/FOV \@MXV@aac/PS/Min% + >>% + }% + }% + % + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /type/dict% + /_objdef {viewobj\the\@MXV@includes_\the\@MXV@viewscount}% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {viewobj\the\@MXV@includes_\the\@MXV@viewscount} <<% + /MS/M% + /CO \@MXV@roo% + /P {pdict\the\@MXV@includes_\the\@MXV@viewscount}% + /C2W[\@MXV@matrix]% + /XN(\@MXV@xname)% + \@MXV@background% + \@MXV@lights% + \@MXV@render% + >>% + }% + }% + \xdef\@MXV@@viewobj{{viewobj\the\@MXV@includes_\the\@MXV@viewscount}}% + }% + % + %macro for creating resource objects from 3D and image files + \def\@MXV@addresource#1{% + %determine file type + \filename@parse{#1}% + \ifthenelse{% + \equal{\filename@ext}{u3d}\OR% + \equal{\filename@ext}{U3D}% + }{% + \def\@MXV@restype{U3D}% + }{% + \def\@MXV@restype{image}% + }% + \ifthenelse{\equal{\@MXV@restype}{image}}{% + %embed the same image file only once + \ifthenelse{\equal{\@MXV@getlabelvalue{\pdfmdfivesum file {#1}}}{undefined}}{% + %increment counter of embedded resource files + \global\advance\@MXV@rescount by 1% + %create Image XObject from next raster image + \special{ps:% read image resource from file + [ /_objdef {resource\the\@MXV@rescount} /NI pdfmark + save gsave + { + /showpage {} def + /setpagedevice /pop load def + newpath clip + (#1) run + } ?pdfmark + 0 0 1 [1 0 0 1 0 0] {} image %empty dummy, in case #1 is not + grestore restore %a valid image file + }% + \xdef\@MXV@resourcetree{% build name tree for embedded resources + \@MXV@resourcetree\space (#1) {resource\the\@MXV@rescount}% + }% + \@MXV@newlabel{\pdfmdfivesum file {#1}}{resource\the\@MXV@rescount}% + }{% + \xdef\@MXV@resourcetree{% + \@MXV@resourcetree\space (#1) {\@MXV@getlabelvalue{\pdfmdfivesum file {#1}}}% + }% + }% + }{% + %embed the same 3D file only once + \ifthenelse{\equal{\@MXV@getlabelvalue{\pdfmdfivesum file {#1}}}{undefined}}{% + \global\advance\@MXV@rescount by 1% + \special{ps: + [ /_objdef {resource\the\@MXV@rescount} /type/stream /OBJ pdfmark + [ {resource\the\@MXV@rescount} <<% + /Subtype/\@MXV@restype% + >> /PUT pdfmark% + [ {resource\the\@MXV@rescount} (#1) (r) file /PUT pdfmark + }% + \xdef\@MXV@resourcetree{% + \@MXV@resourcetree\space (#1) {resource\the\@MXV@rescount}% + }% + \@MXV@newlabel{\pdfmdfivesum file {#1}}{resource\the\@MXV@rescount}% + }{% + \xdef\@MXV@resourcetree{% + \@MXV@resourcetree\space (#1) {\@MXV@getlabelvalue{\pdfmdfivesum file {#1}}}% + }% + }% + }% + } + % + %3D inclusion macro + \newcommand{\@MXV@includeiiid}[5][]{% + % + \if@MXV@externalviewer\else% + \setkeys{MXV@iiid}{#1}%process deferred options + \ifnum\@MXV@iiidrepeat=0\else% + \edef\@MXV@animstyle{% animation style dict + /AN <<% + \@MXV@iiidpalindrome\@MXV@iiidrate/PC \the\@MXV@iiidrepeat% + >>% + }% + \fi% + %java script file, stream object + \IfFileExists{\@MXV@jscriptiiidfile}{% + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {jscriptiiid\the\@MXV@includes}% + /type/stream% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {jscriptiiid\the\@MXV@includes}% + (\@MXV@jscriptiiidfile) (r) file% + }% + }% + \xdef\@MXV@jscriptiiid{% + /OnInstantiate {jscriptiiid\the\@MXV@includes}% + }% + }{\def\@MXV@jscriptiiid{}}% + % + %build the array of 3D views + \@MXV@buildva% + \fi% + % + %3D stream object + \if@MXV@inline% + \ifthenelse{% + \NOT\boolean{@MXV@presentation}\OR% + \equal{\@MXV@getlabelvalue{\@MXV@label.3dstream}}{undefined}% + }{% + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {iiiDfile\the\@MXV@includes}% + /type/stream% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {iiiDfile\the\@MXV@includes} <<% + /Subtype/\@MXV@iiidsubtype% + \if@MXV@externalviewer\else% + /VA [\@MXV@varray]% + /DV/F% use first entry in VA as default view + \@MXV@animstyle% + \if@MXV@resource% + /Resources <<% + /Names [\@MXV@resourcetree]% + >>% + \fi% + \@MXV@jscriptiiid% + \fi% + >>% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {iiiDfile\the\@MXV@includes}% + (#5) (r) file% + }% + }% + \edef\@MXV@iiidstream{iiiDfile\the\@MXV@includes}% + \if@MXV@presentation% + \@MXV@newlabel{\@MXV@label.3dstream}{\@MXV@iiidstream}% + \fi% + }{% + \edef\@MXV@iiidstream{\@MXV@getlabelvalue{\@MXV@label.3dstream}}% + }% + \fi% + % + %insert FileAttachment annotation + \ifthenelse{\boolean{@MXV@inline}\AND\boolean{@MXV@externalviewer}% +% \OR\boolean{@MXV@attachment} + }{% + \makebox[0pt][l]{% + \pdfmark[\phantom{\@MXV@box{#2}{#3}{#4}}]{% + pdfmark=/ANN,% + Subtype=/FileAttachment,% + Raw={% + /F 0% + /T (\@MXV@filename)% + /Contents (3D Object (\@MXV@mime))% + \if@MXV@externalviewer% + /Name/Paperclip% + /C [1 1 1]% + \else% + /AP <</N<<>>/R<<>>/D<<>>>>% + \fi% + /FS <<% + /F(#5)% + /Type/Filespec% + /EF <</F {\@MXV@iiidstream}>>% + >>% + }% + }% + }% + }{% + \if@MXV@url% + %insert Link annotation, if 3D file is a URL + \makebox[0pt][l]{% + \pdfmark[\phantom{\@MXV@box{#2}{#3}{#4}}]{% + pdfmark=/ANN,% + Subtype=/Link,% + Raw={% + /F 0% + \if@MXV@externalviewer% + /C [\@urlbordercolor]% + /H \@pdfhighlight% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /Action <</URI (#5) /S/URI>>% + /Contents (3D Object (\@MXV@mime))% + }% + }% + }% + \else% + %else insert Launch action for local external 3D file + \if@MXV@inline\else% + \makebox[0pt][l]{% + \pdfmark[\phantom{\@MXV@box{#2}{#3}{#4}}]{% + pdfmark=/ANN,% + Subtype=/Link,% + Raw={% + /F 0% + \if@MXV@externalviewer% + /C [\@urlbordercolor]% + /H \@pdfhighlight% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /Action <<% + /F (#5)% + /S /Launch% + >>% + /Contents (3D Object (\@MXV@mime))% + }% + }% + }% + \fi% + \fi% + }% + \if@MXV@externalviewer% + \phantom{\@MXV@box{#2}{#3}{#4}}% + \else% + %appearance dict dummy, to be shared by all 3D annots + \ifthenelse{\isundefined{\@MXV@apdict}}{% + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {apdict}% + /type/stream% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {apdict}% + ()% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {apdict} + <</BBox [0 0 0.001 0.001]>> + }% + }% + \xdef\@MXV@apdict{/AP << /N {apdict}>>}% + }{}% + %3D reference dict + \if@MXV@presentation% + \ifthenelse{% + \equal{\@MXV@getlabelvalue{\@MXV@label.3dref}}{undefined}% + }{% + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {iiiDref\the\@MXV@includes}% + /type/dict% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {iiiDref\the\@MXV@includes} <<% + /Type/3DRef% + /3DD {\@MXV@iiidstream}% 3D stream object + >>% + }% + }% + \edef\@MXV@iiidstreamorref{iiiDref\the\@MXV@includes}% + \@MXV@newlabel{\@MXV@label.3dref}{\@MXV@iiidstreamorref}% + }{% + \edef\@MXV@iiidstreamorref{\@MXV@getlabelvalue{\@MXV@label.3dref}}% + }% + \else% + \edef\@MXV@iiidstreamorref{\@MXV@iiidstream}% + \fi% + %annotation object of subtype `3D' + \pdfmark[\phantom{\@MXV@box{#2}{#3}{#4}}]{% + pdfmark=/ANN,% + Subtype=/3D,% + Raw={% + /_objdef {3Dannot\the\@MXV@includes}% + /F 4% + /T (\@MXV@filename)% + \ifx\@MXV@@label\@empty\else% + /NM (\@MXV@@label)% + \fi% + /Contents (3D Object (\@MXV@mime))% + /P {ThisPage}% + \@MXV@apdict% /AP <</N<<>>/R<<>>/D<<>>>> doesn't work here + \@MXV@defaultview% + \@MXV@iiidia% + /3DD {\@MXV@iiidstreamorref}% 3D stream or reference object + /3DA <<\@MXV@activation\@MXV@deactivation\@MXV@iiidtoolb>>% + }% + }% + \ifx\@MXV@@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@@label.annot}{\the\@MXV@includes}% + \@MXV@newlabel{@MXV@\@MXV@@label.annot}{\the\@MXV@includes}% + \fi% + \fi% + }% + \fi\fi% +}{} + +%settings for newly opened media players +\def\@MXV@settings#1#2#3#4#5#6#7{% + var settings={% + privateData: {% + paused: false + }, + autoPlay: false, + visible: false, + volume: #7 + #1% showUI (controls) + #2% palindrome + #3% repeat + #4% rate + #5% startAt + #6% endAt + }; +} + +%JavaScript event handler routines for 2D media activation +\def\@MXV@events#1#2#3{% #1: playerid, #2: mouse?, #3: autoplay? + var events=new app.media.Events({% + %on focus change from one movie to another, events are fired in the + %following order: (1) onBlur, (2) onFocus, (3) afterBlur, (4) afterFocus + onBlur: function (e) {% + if(focusonplayer > 0){% + focusonplayer=0; + } + }, + afterBlur: function (e) {% + %only resume if we click outside of any media + if(focusonplayer==0){% + try{ + e.target.settings.privateData.paused=false; + e.target.play(); + }catch(e){} + } + }, + onFocus: function (e) {% + focusonplayer=#1; + }, + afterFocus: function (e) {% + if(!e.target.isPlaying){%play on click if paused + try{ + e.target.settings.privateData.paused=false; + e.target.play(); + if(!e.target.isPlaying){%still not playing?! + %sometimes play() fails, in particular if the movie has reached + %its end before getting the focus; but this works: + if( + e.target.settings.startAt.time + || e.target.settings.startAt.frame + || e.target.settings.startAt.marker + || e.target.id == 'vnd.adobe.swname:AAPL_QuickTime' + ){ + e.target.seek(e.target.settings.startAt); + }else{ + e.target.stop(); + } + e.target.play(); + } + } + catch (e){} + } + \@MXV@if{#2}% + else{% + %media can only be paused if mouse option is set + try{ + e.target.pause(); + e.target.settings.privateData.paused=true; + }catch (e){} + } + \fi% + \if@MXV@issound\else e.target.visible=true;\fi% + }, + onPlay: function (e) {% + e.target.settings.privateData.paused=false; + }, + onPause: function (e) {% + e.target.settings.privateData.paused=true; + }, + afterReady: function (e) {% + try{ + if( + e.target.settings.startAt.time + || e.target.settings.startAt.frame + || e.target.settings.startAt.marker + ){ + e.target.play(); + e.target.pause(); + e.target.stop(); + e.target.settings.privateData.paused=false; + e.target.seek(e.target.settings.startAt); + } + \if@MXV@issound\else e.target.visible=true;\fi% + \@MXV@if{#3} + e.target.settings.privateData.paused=false; + e.target.play(); + \fi + } + catch (e){} + } + }); +}% + +%output driver specific implementations of the 2D inclusion macro +\ifpdf% + %pdfLaTeX version + \def\@MXV@includemovie#1#2#3#4{% + %insert box or poster + \@MXV@box{#1}{#2}{#3}% + % + \if@MXV@externalviewer\else% + %new action dict + \pdfobj reserveobjnum% + \@MXV@adict=\pdflastobj% + % + %new additional actions dict + \pdfobj reserveobjnum% + \@MXV@aadict=\pdflastobj% + % + \fi% + %embedded file entry `/EF' + \if@MXV@inline% + %embed the same media file only once + \ifthenelse{\equal{\@MXV@getlabelvalue{\pdfmdfivesum file {#4}}}{undefined}}{% + \pdfobj stream % + attr {% + /Type/EmbeddedFile% + /Subtype (\@MXV@mime)% + }% + file {#4}% + \pdfrefobj\pdflastobj% + \edef\@MXV@efentry{% + /EF << /F \the\pdflastobj\space 0 R >>% + }% + \@MXV@newlabel{\pdfmdfivesum file {#4}}{\the\pdflastobj}% + }{% + \edef\@MXV@efentry{% + /EF << /F \@MXV@getlabelvalue{\pdfmdfivesum file {#4}}\space 0 R >>% + }% + }% + \else\def\@MXV@efentry{}\fi% + % + \ifthenelse{\boolean{@MXV@externalviewer}\AND\NOT\boolean{@MXV@inline}}{}{% + %new file specification object + \pdfobj {<<% + /F(#4)% + \@MXV@fsentry% + \@MXV@efentry% + /Type/Filespec% + >>}\pdfrefobj\pdflastobj% + \edef\@MXV@filespec{\the\pdflastobj}% + }% + % + \makebox[0pt][r]{\makebox[#1][l]{% + %insert FileAttachment annotation + \ifthenelse{\boolean{@MXV@inline}\AND\boolean{@MXV@externalviewer}\OR% + \boolean{@MXV@attachment}% + }{% + \pdfannot width #1 height #2 depth #3 {% + /Subtype /FileAttachment% + /F 0% + /T (\@MXV@filename)% + /Contents (Media File (\@MXV@mime))% + \if@MXV@externalviewer% + %a coloured border, as with external links, would be much nicer + /Name/Paperclip% + /C [1 1 1]% + \else% + /AP <</N<<>>/R<<>>/D<<>>>>% + \fi% + /FS \@MXV@filespec\space 0 R% + }% + }{% + \if@MXV@url% + %insert Link annotation, if media file is a URL + \pdfannot width #1 height #2 depth #3 {% + /Subtype /Link% + /F 0% + \if@MXV@externalviewer% + \@MXV@urlattr% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /A <</URI (#4) /S/URI>>% + /Contents (Media File (\@MXV@mime))% + }% + \else% + %else insert Launch action for local external media file + \if@MXV@inline\else% + \pdfannot width #1 height #2 depth #3 {% + /Subtype /Link% + /F 0% + \if@MXV@externalviewer% + \@MXV@runattr% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /A <<% + /F (#4)% + /S /Launch% + >>% + /Contents (Media File (\@MXV@mime))% + }% + \fi% + \fi% + }% + % + \if@MXV@externalviewer\else% + %annotation object of subtype `Screen' + \pdfannot width #1 height #2 depth #3 {% + /Subtype /Screen% + /Border [0 0 0]% no border (PDF-1.1) + /BS <</S/S/W 0>>% no border (PDF-1.5) + /F 5% disable annot if multimedia is not available + /T (\@MXV@filename)% + /Contents (Media File (\@MXV@mime))% + /P \@MXV@pdfpageref{@MXV@annot\the\@MXV@includes.page} 0 R% + /A \the\@MXV@adict\space 0 R% + /AA \the\@MXV@aadict\space 0 R% + /AP <</N<<>>/R<<>>/D<<>>>>% + }\edef\@MXV@screenannot{\the\pdflastannot}% + %label for later annot obj number determination, to be used in + %movieref's only + \ifx\@MXV@@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@@label.annot}{\@MXV@screenannot}% + \@MXV@newlabel{@MXV@\@MXV@@label.annot}{\@MXV@screenannot}% + \fi% + % + %new media clip object of subtype `Media Clip Data' (/S/MCD) + \pdfobj {<<% + /D \@MXV@filespec\space 0 R% + /P <</TF(TEMPACCESS)>>% + /S/MCD% + /CT (\@MXV@mime)% + >>}\pdfrefobj\pdflastobj% + % + %new rendition object of subtype `Media Rendition' (/S/MR) + \pdfobj {<<% + /C \the\pdflastobj\space 0 R% + /S/MR% + /SP <</BE<</O 0.0>>>>% + /P <<% + \@MXV@player% + /BE <<% + /F 2% + \@MXV@@repeat\@MXV@@volume\@MXV@@ctrls% + /D <</S /F>>% + >>% + >>% + >>}\edef\@MXV@mediarendition{\the\pdflastobj}\pdfrefobj\pdflastobj% + %label for later rendition obj number determination + \ifx\@MXV@@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@@label.rendition}{\@MXV@mediarendition}% + \@MXV@newlabel{@MXV@\@MXV@@label.rendition}{\@MXV@mediarendition}% + \fi% + % + %action dictionary + \pdfobj useobjnum \@MXV@adict {<<% + /R \@MXV@mediarendition\space 0 R% + /S/Rendition% + /OP 0% fallback if /JS doesn't work or is empty + \@MXV@activationjsentry% + /AN \@MXV@screenannot\space 0 R% + >>}\pdfrefobj\pdflastobj% + % + %create play/stop/resume/pause actions + \pdfobj {<<% + /R \@MXV@mediarendition\space 0 R% + /S/Rendition% + \@MXV@pageopenopentry% /OP fallback if /JS doesn't work + \@MXV@pageopenjsentry% + /AN \@MXV@screenannot\space 0 R% + >>}\edef\@MXV@pageopenaction{\the\pdflastobj}\pdfrefobj\pdflastobj% + % + \pdfobj {<<% + /R \@MXV@mediarendition\space 0 R% + /S/Rendition% + \@MXV@pagecloseopentry% + \@MXV@pageclosejsentry% + /AN \@MXV@screenannot\space 0 R% + >>}\edef\@MXV@pagecloseaction{\the\pdflastobj}\pdfrefobj\pdflastobj% + % + %populate additional actions dictionary + \pdfobj useobjnum \@MXV@aadict {<<% + /PO \@MXV@pageopenaction\space 0 R% + /PC \@MXV@pagecloseaction\space 0 R% + >>}\pdfrefobj\pdflastobj% + \fi}}% + }% +\else\if@MXV@dvipdfmx + %dvipdfmx version + \def\@MXV@includemovie#1#2#3#4{% + %insert box or poster + \@MXV@box{#1}{#2}{#3}% + % + \if@MXV@externalviewer\else% + %new action dict + \special{pdf:obj @MXV@adict\the\@MXV@includes << >>}% + % + %new additional actions dict + \special{pdf:obj @MXV@aadict\the\@MXV@includes << >>}% + % + \fi% + %embedded file entry `/EF' + \if@MXV@inline% + %embed the same media file only once + \ifthenelse{\equal{\@MXV@getlabelvalue{\pdfmdfivesum file {#4}}}{undefined}}{% + \special{pdf:fstream @fstream\the\@MXV@includes\space(#4) <<% + /Type/EmbeddedFile% + /Subtype (\@MXV@mime)% + >>}% + \edef\@MXV@efentry{% + /EF << /F @fstream\the\@MXV@includes >>% + }% + \@MXV@newlabel{\pdfmdfivesum file {#4}}{@fstream\the\@MXV@includes}% + }{% + \edef\@MXV@efentry{% + /EF << /F \@MXV@getlabelvalue{\pdfmdfivesum file {#4}} >>% + }% + }% + \else\def\@MXV@efentry{}\fi% + % + \ifthenelse{\boolean{@MXV@externalviewer}\AND\NOT\boolean{@MXV@inline}}{}{% + %new file specification object + \special{pdf:obj @filespec\the\@MXV@includes <<% + /F(#4)% + \@MXV@fsentry% + \@MXV@efentry% + /Type/Filespec% + >>}% + \edef\@MXV@filespec{@filespec\the\@MXV@includes}% + }% + % + \makebox[0pt][r]{\makebox[#1][l]{% + %insert FileAttachment annotation + \ifthenelse{\boolean{@MXV@inline}\AND\boolean{@MXV@externalviewer}\OR% + \boolean{@MXV@attachment}% + }{% + \special{pdf:annot width \the#1 height \the#2 depth \the#3 <<% + /Subtype /FileAttachment% + /F 0% + /T (\@MXV@filename)% + /Contents (Media File (\@MXV@mime))% + \if@MXV@externalviewer% + %a coloured border, as with external links, would be much nicer + /Name/Paperclip% + /C [1 1 1]% + \else% + /AP <</N<<>>/R<<>>/D<<>>>>% + \fi% + /FS \@MXV@filespec% + >>}% + }{% + \if@MXV@url% + %insert Link annotation, if media file is a URL + \special{pdf:annot width \the#1 height \the#2 depth \the#3 <<% + /Subtype /Link% + /F 0% + \if@MXV@externalviewer% + \@MXV@urlattr% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /A <</URI (#4) /S/URI>>% + /Contents (Media File (\@MXV@mime))% + >>}% + \else% + %else insert Launch action for local external media file + \if@MXV@inline\else% + \special{pdf:annot width \the#1 height \the#2 depth \the#3 <<% + /Subtype /Link% + /F 0% + \if@MXV@externalviewer% + \@MXV@runattr% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /A <<% + /F (#4)% + /S /Launch% + >>% + /Contents (Media File (\@MXV@mime))% + >>}% + \fi% + \fi% + }% + % + \if@MXV@externalviewer\else% + %annotation object of subtype `Screen' + \special{pdf:annot @screenannot\the\@MXV@includes\space width \the#1 height \the#2 depth \the#3 <<% + /Subtype /Screen% + /Border [0 0 0]% no border (PDF-1.1) + /BS <</S/S/W 0>>% no border (PDF-1.5) + /F 5% disable annot if multimedia is not available + /T (\@MXV@filename)% + /Contents (Media File (\@MXV@mime))% + /P @thispage% + /A @MXV@adict\the\@MXV@includes% + /AA @MXV@aadict\the\@MXV@includes% + /AP <</N<<>>/R<<>>/D<<>>>>% + >>}% + \edef\@MXV@screenannot{@screenannot\the\@MXV@includes}% + %label for later annot obj number determination, to be used in + %movieref's only + \ifx\@MXV@@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@@label.annot}{\@MXV@screenannot}% + \@MXV@newlabel{@MXV@\@MXV@@label.annot}{\@MXV@screenannot}% + \fi% + % + %new media clip object of subtype `Media Clip Data' (/S/MCD) + \special{pdf:obj @mediaclipdata\the\@MXV@includes <<% + /D \@MXV@filespec% + /P <</TF(TEMPACCESS)>>% + /S/MCD% + /CT (\@MXV@mime)% + >>}% + % + %new rendition object of subtype `Media Rendition' (/S/MR) + \special{pdf:obj @mediarendition\the\@MXV@includes <<% + /C @mediaclipdata\the\@MXV@includes% + /S/MR% + /SP <</BE<</O 0.0>>>>% + /P <<% + \@MXV@player% + /BE <<% + /F 2% + \@MXV@@repeat\@MXV@@volume\@MXV@@ctrls% + /D <</S /F>>% + >>% + >>% + >>}% + \edef\@MXV@mediarendition{@mediarendition\the\@MXV@includes}% + %label for later rendition obj number determination + \ifx\@MXV@@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@@label.rendition}{\@MXV@mediarendition}% + \@MXV@newlabel{@MXV@\@MXV@@label.rendition}{\@MXV@mediarendition}% + \fi% + % + %action dictionary + \special{pdf:put @MXV@adict\the\@MXV@includes <<% + /R \@MXV@mediarendition% + /S/Rendition% + /OP 0% fallback if /JS doesn't work or is empty + \@MXV@activationjsentry% + /AN \@MXV@screenannot% + >>}% + % + %create play/stop/resume/pause actions + \special{pdf:obj @pageopenaction\the\@MXV@includes <<% + /R \@MXV@mediarendition% + /S/Rendition% + \@MXV@pageopenopentry% /OP fallback if /JS doesn't work + \@MXV@pageopenjsentry% + /AN \@MXV@screenannot% + >>}% + \edef\@MXV@pageopenaction{@pageopenaction\the\@MXV@includes}% + % + \special{pdf:obj @pagecloseaction\the\@MXV@includes <<% + /R \@MXV@mediarendition% + /S/Rendition% + \@MXV@pagecloseopentry% + \@MXV@pageclosejsentry% + /AN \@MXV@screenannot% + >>}% + \edef\@MXV@pagecloseaction{@pagecloseaction\the\@MXV@includes}% + % + %populate additional actions dictionary + \special{pdf:put @MXV@aadict\the\@MXV@includes <<% + /PO \@MXV@pageopenaction% + /PC \@MXV@pagecloseaction% + >>}% + \fi}}% + }% +\else% + %dvips version + \def\@MXV@includemovie#1#2#3#4{% + %insert FileAttachment annotation + \ifthenelse{\boolean{@MXV@inline}\AND\boolean{@MXV@externalviewer}\OR% + \boolean{@MXV@attachment}% + }{% + \makebox[0pt][l]{% + \pdfmark[\phantom{\@MXV@box{#1}{#2}{#3}}]{% + pdfmark=/ANN,% + Subtype=/FileAttachment,% + Raw={% + /F 0% + /T (\@MXV@filename)% + /Contents (Media File (\@MXV@mime))% + \if@MXV@externalviewer% + /Name/Paperclip% + /C [1 1 1]% + \else% + /AP <</N<<>>/R<<>>/D<<>>>>% + \fi% + /FS {filespec\the\@MXV@includes}% + }% + }% + }% + }{% + \if@MXV@url% + %insert Link annotation, if media file is a URL + \makebox[0pt][l]{% + \pdfmark[\phantom{\@MXV@box{#1}{#2}{#3}}]{% + pdfmark=/ANN,% + Subtype=/Link,% + Raw={% + /F 0% + \if@MXV@externalviewer% + /C [\@urlbordercolor]% + /H \@pdfhighlight% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /Action <</URI (#4) /S/URI>>% + /Contents (Media File (\@MXV@mime))% + }% + }% + }% + \else% + %else insert Launch action for local external media file + \if@MXV@inline\else% + \makebox[0pt][l]{% + \pdfmark[\phantom{\@MXV@box{#1}{#2}{#3}}]{% + pdfmark=/ANN,% + Subtype=/Link,% + Raw={% + /F 0% + \if@MXV@externalviewer% + /C [\@urlbordercolor]% + /H \@pdfhighlight% + \else% + /H /N% + /Border [0 0 0]% + \fi% + /Action <<% + /F (#4)% + /S /Launch% + >>% + /Contents (Media File (\@MXV@mime))% + }% + }% + }% + \fi% + \fi% + }% + % + \if@MXV@externalviewer% + \@MXV@box{#1}{#2}{#3}% + \else% + %annotation object of subtype `Screen' + \pdfmark[\@MXV@box{#1}{#2}{#3}]{% + pdfmark=/ANN,% + Subtype=/Screen,% + Border={0 0 0},% + Raw={% + /_objdef {screenannot\the\@MXV@includes}% + /F 5% + /T (\@MXV@filename)% + /Contents (Media File (\@MXV@mime))% + /BS <</S/S/W 0>>% no border (PDF-1.5) + /P {ThisPage}% + /AA {aadict\the\@MXV@includes}% + /AP <</N<<>>/R<<>>/D<<>>>>% + }% + }% + \ifx\@MXV@@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@@label.annot}{\the\@MXV@includes}% + \@MXV@newlabel{@MXV@\@MXV@@label.annot}{\the\@MXV@includes}% + \fi% + % + %entire action entry moved outside screen annotation + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {screenannot\the\@MXV@includes} <<% + /A <<% + /R {mediarendition\the\@MXV@includes}% + /S/Rendition% + /OP 0% fallback, if /JS doesn't work or is empty + \@MXV@activationjsentry% + /AN {screenannot\the\@MXV@includes}% + >>% + >>% + }% + }% + % + %new rendition object of subtype `Media Rendition' (/S/MR) + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /type/dict% + /_objdef {mediarendition\the\@MXV@includes}% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {mediarendition\the\@MXV@includes} <<% + /C {mediaclipdata\the\@MXV@includes}% + /S/MR% + %screen parameters: fully transparent, hidden if audio mime type + /SP <</BE<</O 0.0>>>>% + /P <<%Media Play Parameters + \@MXV@player% + /BE <<%Parameters need only be honored by the player in + %the best effort sense + /F 2%scale media's width and height to fit the + %annotation rectangle + \@MXV@@repeat\@MXV@@volume\@MXV@@ctrls% + /D <</S /F>>%movie remains opened + >>% + >>% + >>% + }% + }% + % + %new media clip object of subtype `Media Clip Data' (/S/MCD) + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {mediaclipdata\the\@MXV@includes}% + /type/dict% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {mediaclipdata\the\@MXV@includes} <<% + /D {filespec\the\@MXV@includes}% + /P <</TF(TEMPACCESS)>>% + /S/MCD% + /CT (\@MXV@mime)% mime type + >>% + }% + }% + \fi% + % + %new file specification object + \ifthenelse{\boolean{@MXV@externalviewer}\AND\NOT\boolean{@MXV@inline}}{}{% + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {filespec\the\@MXV@includes}% + /type/dict% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {filespec\the\@MXV@includes} <<% + \@MXV@fsentry + /F(#4)% file name + /Type/Filespec% + >>% + }% + }% + }% + % + %embedded file entry `/EF' + \if@MXV@inline% + %embed the same media file only once + \ifthenelse{\equal{\@MXV@getlabelvalue{\pdfmdfivesum file {#4}}}{undefined}}{% + %new stream object + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {fstream\the\@MXV@includes}% + /type/stream% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {fstream\the\@MXV@includes}% + (#4) (r) file% read in file contents + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {fstream\the\@MXV@includes} <<% + /Type/EmbeddedFile% + /Subtype(\@MXV@mime)% + >>% + }% + }% + \edef\@MXV@moviestream{fstream\the\@MXV@includes}% + \@MXV@newlabel{\pdfmdfivesum file {#4}}{fstream\the\@MXV@includes}% + }{% + \edef\@MXV@moviestream{\@MXV@getlabelvalue{\pdfmdfivesum file {#4}}}% + }% + % put the embedded file entry into file spec object + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {filespec\the\@MXV@includes} <<% + /EF << /F {\@MXV@moviestream} >>% + >>% + }% + }% + \fi% + % + \if@MXV@externalviewer\else% + %create actions for page open/close events + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {pageopenaction\the\@MXV@includes}% + /type/dict% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {pageopenaction\the\@MXV@includes} <<% + /R {mediarendition\the\@MXV@includes}% + /S/Rendition% + \@MXV@pageopenopentry% /OP fallback, if /JS doesn't work + \@MXV@pageopenjsentry% + /AN {screenannot\the\@MXV@includes}% + >>% + }% + }% + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {pagecloseaction\the\@MXV@includes}% + /type/dict% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {pagecloseaction\the\@MXV@includes} <<% + /R {mediarendition\the\@MXV@includes}% + /S/Rendition% + \@MXV@pagecloseopentry% + \@MXV@pageclosejsentry% + /AN {screenannot\the\@MXV@includes}% + >>% + }% + }% + % + %create and populate additional actions dictionary, always add entries + %for page open/close events + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /type/dict% + /_objdef {aadict\the\@MXV@includes}% + }% + }% + % + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {aadict\the\@MXV@includes} <<% + /PO {pageopenaction\the\@MXV@includes}% + /PC {pagecloseaction\the\@MXV@includes}% + >>% + }% + }% + \fi% + }% +\fi\fi + +%definition of user command `\includemovie' +\newcommand{\includemovie}[4][]{% + %test for hyperref package + \ifpdf\else% + \ifthenelse{\isundefined{\pdfmark}\AND\isundefined{\@pdfm@mark}}{\@MXV@missing{hyperref}}{}% + \fi% + % + \leavevmode% + \@MXV@reset% all macros and options + \setkeys{MXV@user}{#1}% parse options + % + %total height of text + \@MXV@totalheight=\@MXV@height% + \advance\@MXV@totalheight by \@MXV@depth% + %traiselen=distance at which text is to be raised to centre it vertically + %braiselen=vertical centre of media box (auxiliary measure) + \@MXV@traiselen=0.5\@MXV@height% + \advance\@MXV@traiselen by -0.5\@MXV@depth% + % + \ifthenelse{\equal{#3}{}}{% no height argument + \@MXV@braiselen=0.5\@MXV@height% + }{%override height of text, height argument given + \@MXV@braiselen=#3% + \@MXV@braiselen=0.5\@MXV@braiselen% + \setlength{\@MXV@height}{#3}% + }% + % + \ifthenelse{\equal{\@MXV@boxdepth}{}}{% no depth option given + \ifthenelse{\lengthtest{\@MXV@totalheight>\@MXV@height}}{% + %depth of text only taken into account, if the total height + %is smaller than the height of the display box + \advance\@MXV@braiselen by -0.5\@MXV@depth% + }{% + \@MXV@depth=0pt% + }% + }{%override depth of text, depth option given + \setlength{\@MXV@@boxdepth}{\@MXV@boxdepth}% + \advance\@MXV@braiselen by -0.5\@MXV@@boxdepth% + \setlength{\@MXV@depth}{\@MXV@boxdepth}% + }% + %finally centre text vertically + \ifthenelse{\NOT\equal{#3}{}\OR\NOT\equal{\@MXV@boxdepth}{}}{% + \advance\@MXV@traiselen by -\@MXV@braiselen% + \@MXV@traiselen=-\@MXV@traiselen% + \savebox{\@MXV@textbox}{\raisebox{\@MXV@traiselen}[0pt][0pt]{% + \usebox{\@MXV@textbox}}}% + }{}% + \ifthenelse{\equal{#2}{}}{}{%override horiz. dimension of text + \setlength{\@MXV@width}{#2}% + %centre text horizontally + \savebox{\@MXV@textbox}{\makebox[\@MXV@width][c]{\usebox{\@MXV@textbox}}}% + }% + % + %find out whether the contents should be hidden or not (for presentations) + \setboolean{@MXV@hide}{false}% +% \ifthenelse{\boolean{@MXV@powerdot}}{% +% \ifthenelse{\boolean{pd@overlay}}{}{% +% \ifthenelse{\pd@method=2}{}{% +% \setboolean{@MXV@hide}{true}% +% }% +% }% +% }{}% + \ifthenelse{\boolean{@MXV@beamer}}{% + \ifthenelse{\boolean{beamer@anotherslide}}{% + \setboolean{@MXV@hide}{true}% + }{}% + }{}% + % + \ifthenelse{\boolean{@MXV@hide}}{% + %insert whitespace instead of annot + \phantom{\vrule width \@MXV@width height \@MXV@height depth \@MXV@depth}% + }{% + \ifthenelse{\NOT\boolean{@MXV@url}\AND\boolean{@MXV@inline}}{% + \IfFileExists{#4}{}{% + \PackageError{movie15}{% + File `#4' cannot be opened for embedding.\MessageBreak + Did you forget to set option `url' or `inline=false'? + }{% + Try any of the options `url' or `inline=false'! + }% + }% + }{}% + % + %guess the mime type based on the filename extension + \filename@parse{#4}% + \ifthenelse{\equal{\@MXV@mime}{@MXV@auto}}{% + \@MXV@guessmime{#4}{\filename@ext}}{}% + \if\filename@ext\relax% + \xdef\@MXV@filename{\filename@base}% + \else% + \xdef\@MXV@filename{\filename@base.\filename@ext}% + \fi% + \expandafter\@MXV@@issound\@MXV@mime:% + % + %if 3D object is not embedded inline we must use some external player :( + \ifthenelse{% + \boolean{@MXV@iiid}% + \AND\NOT\boolean{@MXV@inline}% + }{% + \setboolean{@MXV@externalviewer}{true}% + }{}% + % + %some link attributes (if hyperref not loaded) + \ifthenelse{\isundefined{\@pdfborder}}{% + \def\@MXV@urlattr{}% + \def\@MXV@runattr{}% + }{% + \edef\@MXV@urlattr{% + \if@MXV@beamer% + /Border [1 1 1]% + \else% + /Border [\@pdfborder]% + \fi% + /C [\@urlbordercolor]% + /H \@pdfhighlight% + }% + \edef\@MXV@runattr{% + \if@MXV@beamer% + /Border [1 1 1]% + \else% + /Border [\@pdfborder]% + \fi% + /C [\@runbordercolor]% + /H \@pdfhighlight% + }% + }% + % + \global\advance\@MXV@includes by 1%increment counter + % + %label this annotation for later page number determination + \@MXV@labeltoaux{@MXV@annot\the\@MXV@includes.page}{% + \noexpand\the\@MXV@page}% + % + %label this annotation for later annot id number determination & + %check for multiply-defined labels + % \@MXV@label --> automatic (presentation mode) or user defined label + % \@MXV@@label = \@MXV@label (non presentation doc classes) + % \@MXV@@label = \@MXV@label + physical page No. (presentation mode) + \ifx\@MXV@label\@empty% + %when used with presentation packages, annots must be labelled, + %use the media file name, if no label provided + \ifthenelse{\boolean{@MXV@presentation}}{% + \xdef\@MXV@label{#4}% + }{}% + \fi% + \ifx\@MXV@label\@empty\else% + \ifthenelse{\boolean{@MXV@presentation}}{% + %in presentation mode, the label must be extended by the physical page No. + \xdef\@MXV@@label{\@MXV@label.\@MXV@getlabelvalue{@MXV@annot\the\@MXV@includes.page}}% + }{% + \xdef\@MXV@@label{\@MXV@label}% + }% + \fi% + \ifx\@MXV@@label\@empty\else% + \ifthenelse{% + \NOT\equal{\@MXV@getlabelvalue{@MXV@\@MXV@@label.annotid}}{undefined}% + \AND% + \NOT\equal{\@MXV@getlabelvalue{@MXV@\@MXV@@label.annotid}}{% + \the\@MXV@includes}% + }{% + \PackageWarning{movie15}{% + Label `\@MXV@label' multiply defined% + }% + \ifthenelse{\isundefined{\@MXV@multiwarning}}{% + \gdef\@MXV@multiwarning{}% + \AtEndDocument{% + \PackageWarningNoLine{movie15}{% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\MessageBreak + @@ There were multiply-defined labels! @@\MessageBreak + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}% + }% + }{}% + }{}% + \if@MXV@@draft% + \@MXV@labeltoaux{@MXV@\@MXV@label.draft}{true}% + \else% + \@MXV@labeltoaux{@MXV@\@MXV@label.draft}{false}% + \fi% + \@MXV@labeltoaux{@MXV@\@MXV@@label.annotid}{\the\@MXV@includes}% + \if@MXV@presentation\else% + \@MXV@newlabel{@MXV@\@MXV@@label.annotid}{\the\@MXV@includes}% + \fi% + \fi% + % + \ifthenelse{\boolean{@MXV@@draft}}{}{% + \ifthenelse{\boolean{@MXV@externalviewer}}{% + \ifx\@MXV@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@label.externalviewer}{true}% + \@MXV@newlabel{@MXV@\@MXV@label.externalviewer}{true}% + \fi% + }{% + %what is to be put into movie link annot depends on the following + \ifx\@MXV@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@label.externalviewer}{false}% + \@MXV@newlabel{@MXV@\@MXV@label.externalviewer}{false}% + \fi% + % + %depending on options do content specific stuff + \ifthenelse{\boolean{@MXV@iiid}}{% + % #### 3D #### + \if@MXV@externalviewer\else% + \ifthenelse{\equal{\@MXV@iiidpalindrome}{/Subtype/Oscillating}}{% + \global\multiply\@MXV@iiidrepeat by 2% + }{}% + \ifthenelse{\boolean{@MXV@autoplay}\OR\boolean{@MXV@autoresume}}{% + \def\@MXV@activation{/A/PV/AIS/L}% open 3D object, run animation + }{% + \if@MXV@runposter% + \def\@MXV@activation{/A/PV/AIS/I}%open 3D obj but don't run animation + \else% + \def\@MXV@activation{/A/XA}% explicit activation by user + \fi% + }% + \if@MXV@autostop% + \def\@MXV@deactivation{/D/PI/DIS/I}% + \else% + \if@MXV@autopause% + \def\@MXV@deactivation{/D/PI/DIS/I}% + \else% + \if@MXV@autoclose% + \def\@MXV@deactivation{/D/PI/DIS/U}% + \else%@MXV@continue + \def\@MXV@deactivation{/D/PI/DIS/L}% + \fi% + \fi% + \fi% + %counter for 3D inclusion on current page + \ifthenelse{% + \equal{% + \@MXV@getlabelvalue{@MXV@annot\the\@MXV@includes.page}% + }{\@MXV@oldpage}% + }{% + \global\advance\@MXV@iiidoncurpage by 1% + }{% + \global\@MXV@iiidoncurpage=1% + }% + \xdef\@MXV@oldpage{\@MXV@getlabelvalue{% + @MXV@annot\the\@MXV@includes.page}}% + \fi% + \ifx\@MXV@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@label.3D}{true}% + \@MXV@newlabel{@MXV@\@MXV@label.3D}{true}% + \@MXV@labeltoaux{@MXV@\@MXV@label.3Dlights}{\@MXV@lights}% + \@MXV@newlabel{@MXV@\@MXV@label.3Dlights}{\@MXV@lights}% + \@MXV@labeltoaux{@MXV@\@MXV@label.3Drender}{\@MXV@render}% + \@MXV@newlabel{@MXV@\@MXV@label.3Drender}{\@MXV@render}% + \fi% + \ifx\@MXV@@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@@label.3Doncurpage}{\the\@MXV@iiidoncurpage}% + \@MXV@newlabel{@MXV@\@MXV@@label.3Doncurpage}{\the\@MXV@iiidoncurpage}% + \fi% + }{%#### 2D #### + %get the player ID + \if@MXV@presentation% + \ifthenelse{% + \equal{\@MXV@getlabelvalue{@MXV@\@MXV@label.playerid}}{undefined}% + }{% + \global\advance\@MXV@players by 1%increment counter + }{% + \global\@MXV@players=\@MXV@getlabelvalue{@MXV@\@MXV@label.playerid}% + }% + \@MXV@labeltoaux{@MXV@\@MXV@label.playerid}{\the\@MXV@players}% + \@MXV@newlabel{@MXV@\@MXV@label.playerid}{\the\@MXV@players}% + \edef\@MXV@currplayer{\the\@MXV@players}% + \else% + \ifx\@MXV@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@label.playerid}{\the\@MXV@includes}% + \@MXV@newlabel{@MXV@\@MXV@label.playerid}{\the\@MXV@includes}% + \fi% + \edef\@MXV@currplayer{\the\@MXV@includes}% + \fi% + % + \ifx\@MXV@startat\@empty% default start position + \gdef\@MXV@startat{, startAt: 0}% + \fi% + %write player settings to aux file + \ifx\@MXV@label\@empty\else% + \@MXV@labeltoaux{@MXV@\@MXV@label.mouse}{% + \if@MXV@mouse true\else false\fi}% + \@MXV@labeltoaux{@MXV@\@MXV@label.showUI}{\@MXV@ctrls}% + \@MXV@labeltoaux{@MXV@\@MXV@label.palindrome}{\@MXV@palindrome}% + \@MXV@labeltoaux{@MXV@\@MXV@label.repeat}{\@MXV@repeat}% + \@MXV@labeltoaux{@MXV@\@MXV@label.rate}{\@MXV@rate}% + \@MXV@labeltoaux{@MXV@\@MXV@label.startAt}{\@MXV@startat}% + \@MXV@labeltoaux{@MXV@\@MXV@label.endAt}{\@MXV@endat}% + \@MXV@labeltoaux{@MXV@\@MXV@label.volume}{\@MXV@volume}% + \@MXV@labeltoaux{@MXV@\@MXV@label.autoplay}{% + \if@MXV@autoplay true\else false\fi}% + \@MXV@labeltoaux{@MXV@\@MXV@label.3D}{false}% + \@MXV@labeltoaux{@MXV@\@MXV@label.issound}{% + \if@MXV@issound true\else false\fi}% + % + \@MXV@newlabel{@MXV@\@MXV@label.mouse}{% + \if@MXV@mouse true\else false\fi}% + \@MXV@newlabel{@MXV@\@MXV@label.showUI}{\@MXV@ctrls}% + \@MXV@newlabel{@MXV@\@MXV@label.palindrome}{\@MXV@palindrome}% + \@MXV@newlabel{@MXV@\@MXV@label.repeat}{\@MXV@repeat}% + \@MXV@newlabel{@MXV@\@MXV@label.rate}{\@MXV@rate}% + \@MXV@newlabel{@MXV@\@MXV@label.startAt}{\@MXV@startat}% + \@MXV@newlabel{@MXV@\@MXV@label.endAt}{\@MXV@endat}% + \@MXV@newlabel{@MXV@\@MXV@label.volume}{\@MXV@volume}% + \@MXV@newlabel{@MXV@\@MXV@label.autoplay}{% + \if@MXV@autoplay true\else false\fi}% + \@MXV@newlabel{@MXV@\@MXV@label.3D}{false}% + \@MXV@newlabel{@MXV@\@MXV@label.issound}{% + \if@MXV@issound true\else false\fi}% + % + \fi% + % + \ifthenelse{\boolean{@MXV@autoplay}\OR\boolean{@MXV@runposter}}{% + \xdef\@MXV@pageopenopentry{/OP 4}% + }{% + \if@MXV@autoresume% + \xdef\@MXV@pageopenopentry{/OP 3}% + \else% + \xdef\@MXV@pageopenopentry{/OP 2}% + \fi% + }% + % + \if@MXV@autostop% + \xdef\@MXV@pagecloseopentry{/OP 1}% + \else% + \if@MXV@autopause% + \xdef\@MXV@pagecloseopentry{/OP 2}% + \else% + \if@MXV@autoclose% + \xdef\@MXV@pagecloseopentry{/OP 1}% + \else% @MXV@continue + \xdef\@MXV@pagecloseopentry{/OP 3}% + \fi% + \fi% + \fi% + % + %JavaScripts for playback control + %script for page invisible event + \if@MXV@autopause% + \xdef\@MXV@pageclosejsentry{% + /JS ( + try{% + if(player\@MXV@currplayer.isPlaying){% + player\@MXV@currplayer.pause(); + player\@MXV@currplayer.settings.privateData.paused=true; + } + focusonplayer=-1; %page change + player\@MXV@currplayer.visible=false; + } + catch(e){} + )% + }% + \else% + \if@MXV@autostop% + \xdef\@MXV@pageclosejsentry{% + /JS ( + try{% + player\@MXV@currplayer.settings.privateData.paused=false; + %players tend to be bugged, always stop from playing state + if(!player\@MXV@currplayer.isPlaying){ + player\@MXV@currplayer.play(); + } + player\@MXV@currplayer.stop(); + if( + player\@MXV@currplayer.settings.startAt.time + || player\@MXV@currplayer.settings.startAt.frame + || player\@MXV@currplayer.settings.startAt.marker + || player\@MXV@currplayer.id == + 'vnd.adobe.swname:AAPL_QuickTime' + ){ + player\@MXV@currplayer.seek(% + player\@MXV@currplayer.settings.startAt); + } + focusonplayer=-1; + player\@MXV@currplayer.visible=false; + } + catch(e){} + )% + }% + \else% + \if@MXV@autoclose% + \xdef\@MXV@pageclosejsentry{% + /JS ( + try{% + player\@MXV@currplayer.close(app.media.closeReason.general); + focusonplayer=-1; %page change + player\@MXV@currplayer.visible=false; + } + catch(e){} + )% + }% + \else% + \xdef\@MXV@pageclosejsentry{%@MXV@continue + /JS ( + try{% + focusonplayer=-1; %page change + player\@MXV@currplayer.visible=false; + } + catch(e){} + )% + }% + \fi% + \fi% + \fi% + % + %script for activation/resume on page open event + \xdef\@MXV@pageopenjsentry{% + /JS ( + try{% + if(player\@MXV@currplayer.isOpen){% + %drag the player on the current slide (presentation mode) + player\@MXV@currplayer.page=this.pageNum; + %... and make it visible + \if@MXV@issound\else player\@MXV@currplayer.visible=true;\fi% + % + %start or resume media which have autoplay option set; + %also resume paused media which have autoresume option set + \if@MXV@autoplay% + player\@MXV@currplayer.settings.privateData.paused=false; + player\@MXV@currplayer.play(); + if(!player\@MXV@currplayer.isPlaying){% still not playing?! + if( + player\@MXV@currplayer.settings.startAt.time + || player\@MXV@currplayer.settings.startAt.frame + || player\@MXV@currplayer.settings.startAt.marker + || player\@MXV@currplayer.id=='vnd.adobe.swname:AAPL_QuickTime' + ){ + player\@MXV@currplayer.seek( + player\@MXV@currplayer.settings.startAt); + }else{ + player\@MXV@currplayer.stop(); + } + player\@MXV@currplayer.play(); + } + \else% + \if@MXV@autoresume% + if(player\@MXV@currplayer.settings.privateData.paused){% + player\@MXV@currplayer.settings.privateData.paused=false; + player\@MXV@currplayer.play(); + if(!player\@MXV@currplayer.isPlaying){% + if( + player\@MXV@currplayer.settings.startAt.time + || player\@MXV@currplayer.settings.startAt.frame + || player\@MXV@currplayer.settings.startAt.marker + || player\@MXV@currplayer.id == + 'vnd.adobe.swname:AAPL_QuickTime' + ){ + player\@MXV@currplayer.seek(% + player\@MXV@currplayer.settings.startAt); + }else{ + player\@MXV@currplayer.stop();% + } + player\@MXV@currplayer.play(); + } + } + \fi% + \fi% + } + else{% + throw 'isClosed'; + } + } + catch(e){% + \@MXV@if{\if@MXV@autoplay true\else\if@MXV@runposter true\else % + false\fi\fi}% + if(focusonplayer==undefined){% + var focusonplayer=0; %shared by all annots + } + \@MXV@settings{\@MXV@ctrls}{\@MXV@palindrome}{\@MXV@repeat}% + {\@MXV@rate}{\@MXV@startat}{\@MXV@endat}{\@MXV@volume}% + \@MXV@events{\@MXV@currplayer}% + {\if@MXV@mouse true\else false\fi}% + {\if@MXV@autoplay true\else false\fi}% + var player\@MXV@currplayer=app.media.openPlayer({% + settings: settings, + events: events + }); + \fi% + }% + ) + }% + % + %script for normal activation by mouse click + \xdef\@MXV@activationjsentry{% + /JS ( + app.focusRect=true;% + if(focusonplayer==undefined){% + var focusonplayer=0; %shared by all annots + } + \@MXV@settings{\@MXV@ctrls}{\@MXV@palindrome}{\@MXV@repeat}% + {\@MXV@rate}{\@MXV@startat}{\@MXV@endat}{\@MXV@volume}% + \@MXV@events{\@MXV@currplayer}{\if@MXV@mouse true\else false\fi}% + {true}% + var player\@MXV@currplayer=app.media.openPlayer({% + settings: settings, + events: events + }); + ) + }% + }% + }% + }% draft? + % + %insert link target, if media has been labelled + \ifthenelse{\NOT\equal{\@MXV@@label}{}}{% + \raisebox{\@MXV@height}{% + \ifpdf% + \pdfdest name {@MXV@\@MXV@@label} xyz % + \else% + \hypertarget{@MXV@\@MXV@@label}{}% + \fi% + }% + }{}% + % + \ifthenelse{\boolean{@MXV@@draft}}{% + \makebox[0pt][l]{\usebox{\@MXV@textbox}}% + \@MXV@draftbox{\@MXV@width}{\@MXV@height}{\@MXV@depth}{#4}% + }{% + %insert textbox, obscured by poster + \ifthenelse{\boolean{@MXV@boxopt}\AND\NOT\boolean{@MXV@textoverposter}}{% + \makebox[0pt][l]{\usebox{\@MXV@textbox}}% + }{}% + % + %insert annotation + \ifthenelse{\boolean{@MXV@iiid}}{% + \edef\@MXV@iiidopt{[\@MXV@iiidopt]}% + \expandafter\@MXV@includeiiid\@MXV@iiidopt{\@MXV@width}{\@MXV@height}{\@MXV@depth}{#4}% + }{% + \@MXV@includemovie{\@MXV@width}{\@MXV@height}{\@MXV@depth}{#4}% + }% + % + %insert textbox, overprinting the poster + \ifthenelse{\boolean{@MXV@boxopt}\AND\boolean{@MXV@textoverposter}}{% + \makebox[0pt][r]{\usebox{\@MXV@textbox}}% + }{}% + }% + }% +} + +%for remote control of media +\newcommand\movieref[3][]{% + \ifpdf\else% + \ifthenelse{\isundefined{\pdfmark}\AND\isundefined{\@pdfm@mark}}{\@MXV@missing{hyperref}}{}% + \fi% + \leavevmode% + % save text argument + \savebox{\@MXV@textbox}{\ifHy@colorlinks\color{\@linkcolor}\fi#3}% + % + %find out whether the contents should be hidden or not (for presentations) + \setboolean{@MXV@hide}{false}% +% \ifthenelse{\boolean{@MXV@powerdot}}{% +% \ifthenelse{\boolean{pd@overlay}}{}{% +% \ifthenelse{\pd@method=2}{}{% +% \setboolean{@MXV@hide}{true}% +% }% +% }% +% }{}% + \ifthenelse{\boolean{@MXV@beamer}}{% + \ifthenelse{\boolean{beamer@anotherslide}}{% + \setboolean{@MXV@hide}{true}% + }{}% + }{}% + % + \ifthenelse{\boolean{@MXV@hide}}{% + %put whitespace instead of link annot + \phantom{\usebox{\@MXV@textbox}}% + }{% + \@MXV@reset% + % + \xdef\@MXV@label{#2}% + % + \global\advance\@MXV@links by 1%increment link counter + % + %label this link for later page number determination + \@MXV@labeltoaux{@MXV@link\the\@MXV@links.page}{\noexpand\the\@MXV@page}% + % + \ifthenelse{\boolean{@MXV@presentation}}{% + %in presentation mode the label must be extended by the physical page No. + \xdef\@MXV@@label{\@MXV@label.\@MXV@getlabelvalue{@MXV@link\the\@MXV@links.page}}% + }{% + \xdef\@MXV@@label{\@MXV@label}% + }% + % + %check if label is defined at all + \ifthenelse{\equal{\@MXV@getlabelvalue{@MXV@\@MXV@@label.annotid}}{undefined}}{% + \usebox{\@MXV@textbox}% write out text box + \PackageWarning{movie15}{% + Reference `\@MXV@label' on page \thepage \space undefined% + }% + \ifthenelse{\isundefined{\@MXV@undefwarning}}{% + \gdef\@MXV@undefwarning{}% + \AtEndDocument{% + \PackageWarningNoLine{movie15}{% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\MessageBreak% + @@ There were undefined references! @@\MessageBreak% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}% + }% + }{}% + }{% + \ifthenelse{\equal{\@MXV@getlabelvalue{@MXV@\@MXV@label.draft}}{true}}{% + \setboolean{@MXV@@draft}{true}% if the screen annotation is in draft mode + }{}% + \if@MXV@@draft\else% + \ifthenelse{\equal{\@MXV@getlabelvalue{@MXV@\@MXV@label.externalviewer}}{true}}{% + \setboolean{@MXV@externalviewer}{true}% + }{% + \setboolean{@MXV@externalviewer}{false}% + }% + \if@MXV@externalviewer\else% + %movieref used in 3D context? + \ifthenelse{\equal{\@MXV@getlabelvalue{@MXV@\@MXV@label.3D}}{true}}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \setboolean{@MXV@iiid}{true}% + }{% + \@MXV@neediiiD% + }% + }{}% + % + %actions completely different in 3D & 2D context + \ifthenelse{\boolean{@MXV@iiid}}{% #### 3D #### + %retrieve default lighting scheme + \ifthenelse{\equal{\@MXV@getlabelvalue{@MXV@\@MXV@label.3Dlights}}{undefined}}{% + \edef\@MXV@lights{}% + }{% + \edef\@MXV@lights{\@MXV@getlabelvalue{@MXV@\@MXV@label.3Dlights}}% + }% + %retrieve default render mode + \ifthenelse{\equal{\@MXV@getlabelvalue{@MXV@\@MXV@label.3Drender}}{undefined}}{% + \edef\@MXV@render{}% + }{% + \edef\@MXV@render{\@MXV@getlabelvalue{@MXV@\@MXV@label.3Drender}}% + }% + \setkeys{MXV@user}{#1}% + \if@MXV@defaultviewprovided% define a new view, + %using any of the coo, c2c, roo, caa options + \xdef\@MXV@xname{}% + \edef\@MXV@args{\@MXV@coo\space\@MXV@ctoc\space\@MXV@roo\space\@MXV@roll\space}% + \expandafter\@MXV@ciiwmatrix\@MXV@args% build C2W matrix + \@MXV@viewobj% create pdf object of 3D view + \edef\@MXV@iiidview{\@MXV@@viewobj}% + %else use the indexed view specified by option `3Dviewindex' + \fi% + % + %create JavaScript (options 3Djscript, 3Dcalculate, 3Dgetview) + \ifthenelse{\NOT\equal{\@MXV@jscriptiiidfile}{}% + \OR\NOT\equal{\@MXV@calc}{}% + \OR\boolean{@MXV@iiidgetview}% + }{% + \edef\@MXV@linkjscriptiiid{% + try{% + %fill hash (annot3D) with refs to Annot3D objects + annot3D['\@MXV@label']=getAnnots3D(% + \@MXV@getlabelvalue{% + @MXV@annot\@MXV@getlabelvalue{@MXV@\@MXV@@label.annotid}.page% + }-1% + )[\@MXV@getlabelvalue{@MXV@\@MXV@@label.3Doncurpage}-1];% + annot3D['\@MXV@label'].activated=true;% + }catch(e){% + try{% + annot3D=new Array;% + annot3D['\@MXV@label']=getAnnots3D(% + \@MXV@getlabelvalue{% + @MXV@annot\@MXV@getlabelvalue{@MXV@\@MXV@@label.annotid}.page% + }-1% + )[\@MXV@getlabelvalue{@MXV@\@MXV@@label.3Doncurpage}-1];% + annot3D['\@MXV@label'].activated=true;% + }catch(e){% + var spc=String.fromCharCode(32);% + app.alert('3D' + spc + 'annotation' + spc + 'could' + spc +% + 'not' + spc + 'be' + spc + 'activated!');% + }% + }% + }% + \if@MXV@iiidgetview% + \edef\@MXV@linkjscriptiiid{% + \@MXV@linkjscriptiiid + try{ + %JavaScript to print the camera settings of the current view + var camera=annot3D['\@MXV@label'].context3D.scene.cameras.getByIndex(0);% + var coo=camera.targetPosition;% + var c2c=camera.position.subtract(coo);% + var roo=c2c.length;% + c2c.normalize();% + % + %assemble result string + %{<coo_x> <coo_y> <coo_z>}{<c2c_x> <c2c_y> <c2c_z>}{<roo>}{<aac>} + var spc=String.fromCharCode(32);% + var res='{';% + var x = (Math.abs(coo.x) < 1e-18 ? 0 : coo.x);% + var y = (Math.abs(coo.y) < 1e-18 ? 0 : coo.y);% + var z = (Math.abs(coo.z) < 1e-18 ? 0 : coo.z);% + if(Math.sqrt(x*x + y*y + z*z) > 0){% + res+=util.printf('\%s' + spc + '\%s' + spc + '\%s',% + (Math.abs(x) < 1.001e-6 && Math.abs(x) > 0 ?% + util.printf('\%.18f', x): x),% + (Math.abs(y) < 1.001e-6 && Math.abs(y) > 0 ?% + util.printf('\%.18f', y): y),% + (Math.abs(z) < 1.001e-6 && Math.abs(z) > 0 ?% + util.printf('\%.18f', z): z)% + );% + }% + res+='}{';% + x = (Math.abs(c2c.x) < 1e-18 ? 0 : c2c.x);% + y = (Math.abs(c2c.y) < 1e-18 ? 0 : c2c.y);% + z = (Math.abs(c2c.z) < 1e-18 ? 0 : c2c.z);% + if(!(x==0 && y==-1 && z==0)){% + res+=util.printf('\%s' + spc + '\%s' + spc + '\%s',% + (Math.abs(x) < 1.001e-6 && Math.abs(x) > 0 ?% + util.printf('\%.18f', x): x),% + (Math.abs(y) < 1.001e-6 && Math.abs(y) > 0 ?% + util.printf('\%.18f', y): y),% + (Math.abs(z) < 1.001e-6 && Math.abs(z) > 0 ?% + util.printf('\%.18f', z): z)% + );% + }% + res+='}{';% + if(roo > 0.11e-17){% + res+=util.printf('\%s',% + (roo < 1.001e-6 ? util.printf('\%.18f', roo): roo)% + );% + }% + res+='}{';% + %determine the camera roll (camera.roll is bugged) + %camera up-vector from camera.up, the latter being the positional vector + %of the actual camera up-vector tip + var up = camera.up.subtract(camera.position);% + up.normalize();% + %find the camera up-vector up0, that corresponds to zero roll + %(Gram-Schmitt orthogonalisation) + var worldup=new annot3D['\@MXV@label'].context3D.Vector3();% + worldup.set(0,0,1);% + var out=c2c.scale(-1);% + var up0=worldup.subtract(out.scale(out.dot(worldup)));% + up0.normalize();% + var up0xup=up0.cross(up);% + var roll=0;% + if(up0xup.length>0){% + up0xup.normalize();% + var up0dotup=up.dot(up0);% + up0dotup=(Math.abs(up0dotup) > 1 ? Math.round(up0dotup) : up0dotup);% + %compute the angle between camera up and up0 vectors + roll=Math.acos(up0dotup)*180/Math.PI*out.dot(up0xup);% + }% + if(util.printf('\%.5f', roll)!=0){% + res+=util.printf('\%s', roll);% + }% + res+='}{';% + aac=camera.fov * 180/Math.PI;% + if(util.printf('\%.5f', aac)!=30){% + res+=util.printf('\%s',% + (Math.abs(aac) < 1.001e-6 ? util.printf('\%.18f', aac): aac)% + );% + }% + res+='}';% + %open pop-up displaying the result string + var settings={% + initialize: function(dialog) {% + dialog.load({% + 'text': res% + });% + },% + description: {% + name: 'Current' + spc + '3D' + spc + 'Camera' + spc + 'Settings',% + elements: [% + {% + type: 'static_text',% + name: 'Add' + spc + 'the' + spc + 'following' + spc + 'line' + spc +% + 'to' + spc + 'a' + spc + 'file' + spc + 'of' + spc +% + 'predefined' + spc + 'views.' + spc +% + '(See' + spc + 'option' + spc + '3Dviews!)'% + },% + {% + type: 'edit_text',% + item_id: 'text',% + alignment: 'align_fill',% + readonly: false% + },% + {% + type: 'ok',% + ok_name: 'Close'% + }% + ]% + }% + };% + app.execDialog(settings);% + }catch(e){% + var spc=String.fromCharCode(32);% + app.alert('Error' + spc + 'while' + spc + 'executing' + spc +% + '3Dgetview:' + spc + e);% + }% + }% + \fi% + \ifx\@MXV@calc\@empty\else% + \edef\@MXV@linkjscriptiiid{% + \@MXV@linkjscriptiiid + try{ +% console.show(); +% console.clear(); + %constructor for doubly linked list + function List(){% + this.first_node=null;% + this.last_node=new Node(undefined);% + }% + List.prototype.push_back=function(x){% + var new_node=new Node(x);% + if(this.first_node==null){% + this.first_node=new_node;% + new_node.prev=null;% + }else{% + new_node.prev=this.last_node.prev;% + new_node.prev.next=new_node;% + }% + new_node.next=this.last_node;% + this.last_node.prev=new_node;% + };% + List.prototype.move_to_front=function(it){% + var node=it.get();% + if(node.next!=null && node.prev!=null){% + node.next.prev=node.prev;% + node.prev.next=node.next;% + node.prev=null;% + node.next=this.first_node;% + this.first_node.prev=node;% + this.first_node=node;% + }% + };% + List.prototype.begin=function(){% + var i=new Iterator();% + i.target=this.first_node;% + return(i);% + };% + List.prototype.end=function(){% + var i=new Iterator();% + i.target=this.last_node;% + return(i);% + };% + function Iterator(it){% + if( it!=undefined ){% + this.target=it.target;% + }else {% + this.target=null;% + }% + }% + Iterator.prototype.set=function(it){this.target=it.target;};% + Iterator.prototype.get=function(){return(this.target);};% + Iterator.prototype.deref=function(){return(this.target.data);};% + Iterator.prototype.incr=function(){% + if(this.target.next!=null){this.target=this.target.next;}% + };% + %constructor for node objects that populate the linked list + function Node(x){% + this.prev=null;% + this.next=null;% + this.data=x;% + }% + function sqr(r){return(r*r);}%helper function + %The following code borrows heavily from Bernd Gaertners `Miniball' software, + %originally written in C++, for computing the smallest enclosing ball of a + %set of points; see: http://www.inf.ethz.ch/personal/gaertner/miniball.html + function Basis(){% + this.m=0;% + this.q0=new Array(3);% + this.z=new Array(4);% + this.f=new Array(4);% + this.v=new Array(new Array(3), new Array(3), new Array(3), new Array(3));% + this.a=new Array(new Array(3), new Array(3), new Array(3), new Array(3));% + this.c=new Array(new Array(3), new Array(3), new Array(3), new Array(3));% + this.sqr_r=new Array(4);% + this.current_c=this.c[0];% + this.current_sqr_r=0;% + this.reset();% + }% + Basis.prototype.center=function(){return(this.current_c);};% + Basis.prototype.size=function(){return(this.m);};% + Basis.prototype.pop=function(){--this.m;};% + Basis.prototype.excess=function(p){% + var e=-this.current_sqr_r;% + for(var k=0;k<3;++k){% + e+=sqr(p[k]-this.current_c[k]);% + }% + return(e);% + };% + Basis.prototype.reset=function(){% + this.m=0;% + for(var j=0;j<3;++j){% + this.c[0][j]=0;% + }% + this.current_c=this.c[0];% + this.current_sqr_r=-1;% + };% + Basis.prototype.push=function(p){% + var i, j;% + var eps=1e-32;% + if(this.m==0){% + for(i=0;i<3;++i){% + this.q0[i]=p[i];% + }% + for(i=0;i<3;++i){% + this.c[0][i]=this.q0[i];% + }% + this.sqr_r[0]=0;% + }else {% + for(i=0;i<3;++i){% + this.v[this.m][i]=p[i]-this.q0[i];% + }% + for(i=1;i<this.m;++i){% + this.a[this.m][i]=0;% + for(j=0;j<3;++j){% + this.a[this.m][i]+=this.v[i][j]*this.v[this.m][j];% + }% + this.a[this.m][i]*=(2/this.z[i]);% + }% + for(i=1;i<this.m;++i){% + for(j=0;j<3;++j){% + this.v[this.m][j]-=this.a[this.m][i]*this.v[i][j];% + }% + }% + this.z[this.m]=0;% + for(j=0;j<3;++j){% + this.z[this.m]+=sqr(this.v[this.m][j]);% + }% + this.z[this.m]*=2;% + if(this.z[this.m]<eps*this.current_sqr_r){% + return(false);% + }% + var e=-this.sqr_r[this.m-1];% + for(i=0;i<3;++i){% + e+=sqr(p[i]-this.c[this.m-1][i]);% + }% + this.f[this.m]=e/this.z[this.m];% + for(i=0;i<3;++i){% + this.c[this.m][i]=this.c[this.m-1][i]+this.f[this.m]*this.v[this.m][i];% + }% + this.sqr_r[this.m]=this.sqr_r[this.m-1]+e*this.f[this.m]/2;% + }% + this.current_c=this.c[this.m];% + this.current_sqr_r=this.sqr_r[this.m];% + ++this.m;% + return(true);% + };% + function Miniball(){% + this.L=new List();% + this.B=new Basis();% + this.support_end=new Iterator();% + }% + Miniball.prototype.mtf_mb=function(it){% + var i=new Iterator(it);% + this.support_end.set(this.L.begin());% + if((this.B.size())==4){return;}% + for(var k=new Iterator(this.L.begin());k.get()!=i.get();){% + var j=new Iterator(k);% + k.incr();% + if(this.B.excess(j.deref()) > 0){% + if(this.B.push(j.deref())){% + this.mtf_mb(j);% + this.B.pop();% + if(this.support_end.get()==j.get()){% + this.support_end.incr();% + }% + this.L.move_to_front(j);% + }% + }% + }% + };% + Miniball.prototype.check_in=function(b){% + this.L.push_back(b);% + };% + Miniball.prototype.build=function(){% + this.B.reset();% + this.support_end.set(this.L.begin());% + this.mtf_mb(this.L.end());% + };% + Miniball.prototype.center=function(){% + return(this.B.center());% + };% + Miniball.prototype.radius=function(){% + return(Math.sqrt(this.B.current_sqr_r));% + };% + %create Miniball object + var mb=new Miniball();% + %aperture angle of the virtual camera + var aac=\@MXV@calc;% + %list of mesh nodes + var meshes=annot3D['\@MXV@label'].context3D.scene.meshes;% + %auxiliary vectors + var dir=new annot3D['\@MXV@label'].context3D.Vector3();% + var up=new annot3D['\@MXV@label'].context3D.Vector3();% + var corner=new annot3D['\@MXV@label'].context3D.Vector3();% + %auxiliary 4x4 matrix + var bbox4x4=new annot3D['\@MXV@label'].context3D.Matrix4x4();% + %iterate over all mesh nodes in the scene + for(i=0;i<meshes.count;i++){% + var mesh=meshes.getByIndex(i);% + %get the bbox of the mesh (local coordinates) + var bbox=mesh.computeBoundingBox();% + %local to parent transformation matrix + var trans=mesh.transform.transpose;% + %build local to world transformation matrix by recursively + %multiplying the parent's transf. matrix on the left + var parent=mesh.parent;% + while(parent.transform){% + trans=parent.transform.transpose.multiply(trans);% + parent=parent.parent;% + }% + %transform the local bounding box corner coordinates to + %world coordinates for bounding sphere determination; + %Matrix4x4 method transformDirection(<Vector3>) seems + %to be bugged, therefore we must resort to the + %multiply(<Matrix4x4>) method using an auxiliary matrix + %which contains the local bounding box corner coordinates + % + %auxiliary matrix from bbox.min coordinates + bbox4x4.setView(bbox.min, dir, up);% + %transform to world coordinates + bbox4x4=trans.multiply(bbox4x4.transpose);% + %extract the transformed coordinates + corner.set(bbox4x4.transpose.translation);% + %check-in corner position into Miniball + mb.check_in(new Array(corner.x, corner.y, corner.z));% + %the same procedure with bbox.max + bbox4x4.setView(bbox.max, dir, up);% + bbox4x4=trans.multiply(bbox4x4.transpose);% + corner.set(bbox4x4.transpose.translation);% + mb.check_in(new Array(corner.x, corner.y, corner.z));% + %and with all remaining 6 bbox corners + corner.set(bbox.min.x, bbox.max.y, bbox.max.z);% + bbox4x4.setView(corner, dir, up);% + bbox4x4=trans.multiply(bbox4x4.transpose);% + corner.set(bbox4x4.transpose.translation);% + mb.check_in(new Array(corner.x, corner.y, corner.z));% + corner.set(bbox.min.x, bbox.min.y, bbox.max.z);% + bbox4x4.setView(corner, dir, up);% + bbox4x4=trans.multiply(bbox4x4.transpose);% + corner.set(bbox4x4.transpose.translation);% + mb.check_in(new Array(corner.x, corner.y, corner.z));% + corner.set(bbox.min.x, bbox.max.y, bbox.min.z);% + bbox4x4.setView(corner, dir, up);% + bbox4x4=trans.multiply(bbox4x4.transpose);% + corner.set(bbox4x4.transpose.translation);% + mb.check_in(new Array(corner.x, corner.y, corner.z));% + corner.set(bbox.max.x, bbox.min.y, bbox.min.z);% + bbox4x4.setView(corner, dir, up);% + bbox4x4=trans.multiply(bbox4x4.transpose);% + corner.set(bbox4x4.transpose.translation);% + mb.check_in(new Array(corner.x, corner.y, corner.z));% + corner.set(bbox.max.x, bbox.min.y, bbox.max.z);% + bbox4x4.setView(corner, dir, up);% + bbox4x4=trans.multiply(bbox4x4.transpose);% + corner.set(bbox4x4.transpose.translation);% + mb.check_in(new Array(corner.x, corner.y, corner.z));% + corner.set(bbox.max.x, bbox.max.y, bbox.min.z);% + bbox4x4.setView(corner, dir, up);% + bbox4x4=trans.multiply(bbox4x4.transpose);% + corner.set(bbox4x4.transpose.translation);% + mb.check_in(new Array(corner.x, corner.y, corner.z));% + }% + %compute the smallest enclosing bounding sphere + mb.build();% + %bounding sphere centre + var coo=new annot3D['\@MXV@label'].context3D.Vector3();% + coo.set((mb.center())[0], (mb.center())[1], (mb.center())[2]);% + %radius of orbit + var roo=mb.radius()/ Math.sin(aac * Math.PI/ 360.);% + %result string + var res='';% + var spc=String.fromCharCode(32);% + if(aac!=30){% + res+=util.printf('3Daac=\%s,' + spc,% + (Math.abs(aac) < 1.001e-6 && Math.abs(aac) > 0 ?% + util.printf('\%.18f', aac): aac)% + );% + }% + if(coo.length){% + res+=util.printf( '3Dcoo=\%s' + spc + '\%s' + spc + '\%s,'% + + spc,% + (Math.abs(coo.x) < 1.001e-6 && Math.abs(coo.x) > 0 ?% + util.printf('\%.18f', coo.x): coo.x),% + (Math.abs(coo.y) < 1.001e-6 && Math.abs(coo.y) > 0 ?% + util.printf('\%.18f', coo.y): coo.y),% + (Math.abs(coo.z) < 1.001e-6 && Math.abs(coo.z) > 0 ?% + util.printf('\%.18f', coo.z): coo.z)% + );% + }% + res+=util.printf(% + '3Droo=\%s,' + spc, (roo < 1.001e-6 ? util.printf('\%.18f', roo): roo) + );% + var settings={% + initialize: function(dialog){% + dialog.load({% + 'text': res% + });% + },% + description: {% + name: '3D' + spc + 'Camera' + spc + 'Settings',% + elements: [% + {% + type: 'static_text',% + name: 'Copy' + spc + 'and' + spc + 'paste' + spc +% + 'the' + spc + 'following' + spc + 'to' + spc +% + 'the' + spc + 'option' + spc + 'list' + spc +% + 'of' + spc + spc + '\string\\\string\\includemovie!'% + },% + {% + type: 'edit_text',% + item_id: 'text',% + alignment: 'align_fill',% + readonly: false% + },% + {% + type: 'ok',% + ok_name: 'Close'% + }% + ]% + }% + };% + app.execDialog(settings);% + }catch(e){% + var spc=String.fromCharCode(32);% + app.alert('Error' + spc + 'while' + spc + 'executing' + spc +% + '3Dcalculate:' + spc + e);% + }% + }% + \fi% + %create stream from user provided JavaScript file + \ifx\@MXV@jscriptiiidfile\@empty\else% + \ifthenelse{% create only once + \equal{\@MXV@getlabelvalue{\pdfmdfivesum file {\@MXV@jscriptiiidfile}}}{undefined}% + }{% + \ifpdf% + \pdfobj stream file {\@MXV@jscriptiiidfile}% + \pdfrefobj\pdflastobj% + \edef\@MXV@userjscriptiiidstream{\the\pdflastobj\space 0 R}% + \@MXV@newlabel{\pdfmdfivesum file {\@MXV@jscriptiiidfile}}{\the\pdflastobj}% + \else\if@MXV@dvipdfmx + \special{pdf:fstream @linkuserjscriptiiid\the\@MXV@links\space(\@MXV@jscriptiiidfile)}% + \edef\@MXV@userjscriptiiidstream{@linkuserjscriptiid\the\@MXV@links}% + \@MXV@newlabel{\pdfmdfivesum file {\@MXV@jscriptiiidfile}}{@linkuserjscriptiid\the\@MXV@links}% + \else% + \pdfmark{% + pdfmark=/OBJ,% + Raw={% + /_objdef {linkuserjscriptiiid\the\@MXV@links}% + /type/stream% + }% + }% + \pdfmark{% + pdfmark=/PUT,% + Raw={% + {linkuserjscriptiiid\the\@MXV@links}% + (\@MXV@jscriptiiidfile) (r) file% + }% + }% + \edef\@MXV@userjscriptiiidstream{% + {linkuserjscriptiiid\the\@MXV@links}% + }% + \@MXV@newlabel{\pdfmdfivesum file {\@MXV@jscriptiiidfile}}% + {linkuserjscriptiiid\the\@MXV@links}% + \fi\fi% + }{% + \ifpdf% + \edef\@MXV@userjscriptiiidstream{% + \@MXV@getlabelvalue{\pdfmdfivesum file {\@MXV@jscriptiiidfile}}\space 0 R% + }% + \else% + \edef\@MXV@userjscriptiiidstream{% + {\@MXV@getlabelvalue{\pdfmdfivesum file {\@MXV@jscriptiiidfile}}}% + }% + \fi% + }% + \fi% + \edef\@MXV@jscriptiiidaction{% + /Next <<% + /S/JavaScript% + /JS (\@MXV@linkjscriptiiid)% + \ifx\@MXV@jscriptiiidfile\@empty\else% + /Next <<% + /S/JavaScript% + /JS \@MXV@userjscriptiiidstream% user provided script + >>% + \fi% + >>% + }% + }{\edef\@MXV@jscriptiiidaction{}}% + }{% #### 2D #### + \setkeys{MXV@user}{#1}% + %retrieve original settings + \ifthenelse{\equal{\@MXV@getlabelvalue{@MXV@\@MXV@label.mouse}}{true}}{% + \setboolean{@MXV@mouse}{true}% + }{% + \setboolean{@MXV@mouse}{false}% + }% + \edef\@MXV@ctrls{\@MXV@getlabelvalue{@MXV@\@MXV@label.showUI}}% + \edef\@MXV@palindrome{\@MXV@getlabelvalue{@MXV@\@MXV@label.palindrome}}% + \edef\@MXV@repeat{\@MXV@getlabelvalue{@MXV@\@MXV@label.repeat}}% + \edef\@MXV@rate{\@MXV@getlabelvalue{@MXV@\@MXV@label.rate}}% + \edef\@MXV@startat{\@MXV@getlabelvalue{@MXV@\@MXV@label.startAt}}% + \edef\@MXV@endat{\@MXV@getlabelvalue{@MXV@\@MXV@label.endAt}}% + \edef\@MXV@volume{\@MXV@getlabelvalue{@MXV@\@MXV@label.volume}}% + \if@MXV@linkreset\else% + \setkeys{MXV@user}{#1}%override with new settings + \fi% + % + \edef\@MXV@operation{}% + % + %get the player ID + \edef\@MXV@currplayer{\@MXV@getlabelvalue{@MXV@\@MXV@label.playerid}}% + % + %see whether a sound inclusion is being referenced + \ifthenelse{\equal{\@MXV@getlabelvalue{@MXV@\@MXV@label.issound}}{true}}{% + \setboolean{@MXV@issound}{true}% + }{% + \setboolean{@MXV@issound}{false}% + }% + % + %create /OP and /JS entries + \if@MXV@linkplay% + \edef\@MXV@operation{% + /OP 0% + /JS (% + if(focusonplayer==undefined){% + var focusonplayer=0; %shared by all annots + }% + \@MXV@settings{\@MXV@ctrls}{\@MXV@palindrome}{\@MXV@repeat}% + {\@MXV@rate}{\@MXV@startat}{\@MXV@endat}{\@MXV@volume}% + \@MXV@events{\@MXV@currplayer}% + {\if@MXV@mouse true\else false\fi}% + {true}% + \if@MXV@requirereopen\else + try{% + \ifx\@MXV@@startat\@empty + player\@MXV@currplayer.seek(% + player\@MXV@currplayer.settings.startAt% + ); + \else + player\@MXV@currplayer.seek(\@MXV@@startat); + \fi + player\@MXV@currplayer.play(); + \ifx\@MXV@@startat\@empty + player\@MXV@currplayer.seek(% + player\@MXV@currplayer.settings.startAt% + ); + \else + player\@MXV@currplayer.seek(\@MXV@@startat); + \fi + }% + catch(e)\@charlb% + \fi% + try{% + if(player\@MXV@currplayer.isOpen){% + player\@MXV@currplayer.close(% + app.media.closeReason.general); + player\@MXV@currplayer=null; + }% + }% + catch(e){}% + % + try{% + var player\@MXV@currplayer=app.media.openPlayer({% + settings: settings,% + events: events% + });% + }% + catch (e){}% + \if@MXV@requirereopen\else + \@charrb% + \fi% + )% + }% + \fi% + \if@MXV@linkresume% resume/pause + \edef\@MXV@operation{% + /OP 3% + /JS (% + try{% + \if@MXV@issound\else player\@MXV@currplayer.visible=true;\fi% + if(!player\@MXV@currplayer.isPlaying){% + player\@MXV@currplayer.settings.privateData.paused=false; + player\@MXV@currplayer.play(); + if(!player\@MXV@currplayer.isPlaying){% + %media at end will restart from beginning + if( + player\@MXV@currplayer.settings.startAt.time + || player\@MXV@currplayer.settings.startAt.frame + || player\@MXV@currplayer.settings.startAt.marker + || player\@MXV@currplayer.id == + 'vnd.adobe.swname:AAPL_QuickTime' + ){ + player\@MXV@currplayer.seek( + player\@MXV@currplayer.settings.startAt); + }else{ + player\@MXV@currplayer.stop(); + } + player\@MXV@currplayer.play(); + }% + }% + else{% + player\@MXV@currplayer.pause(); + player\@MXV@currplayer.settings.privateData.paused=true; + }% + }% + catch(e){% open new player if not yet open + if(focusonplayer==undefined){% + var focusonplayer=0; %shared by all annots + }% + \@MXV@settings{\@MXV@ctrls}{\@MXV@palindrome}{\@MXV@repeat}% + {\@MXV@rate}{\@MXV@startat}{\@MXV@endat}{\@MXV@volume}% + \@MXV@events{\@MXV@currplayer}% + {\if@MXV@mouse true\else false\fi}% + {true}% + try{% + var player\@MXV@currplayer=app.media.openPlayer({% + settings: settings,% + events: events% + }); + }% + catch (e){}% + }% + )% + }% + \fi% + \if@MXV@linkstop% + \edef\@MXV@operation{% + /OP 1% + /JS (% + try{% + if(!player\@MXV@currplayer.isPlaying){% + player\@MXV@currplayer.settings.privateData.paused=false; + player\@MXV@currplayer.play(); + }% + player\@MXV@currplayer.stop(); + if( + player\@MXV@currplayer.settings.startAt.time + || player\@MXV@currplayer.settings.startAt.frame + || player\@MXV@currplayer.settings.startAt.marker + || player\@MXV@currplayer.id == + 'vnd.adobe.swname:AAPL_QuickTime' + ){ + player\@MXV@currplayer.seek(% + player\@MXV@currplayer.settings.startAt); + } + }% + catch(e){}% + )% + }% + \fi% + \if@MXV@linkpause% pause/resume + \edef\@MXV@operation{% + /OP 2% + /JS (% + try{% + \if@MXV@issound\else player\@MXV@currplayer.visible=true;\fi% + if(!player\@MXV@currplayer.isPlaying){% + player\@MXV@currplayer.settings.privateData.paused=false; + player\@MXV@currplayer.play(); + if(!player\@MXV@currplayer.isPlaying){% + %media at end will restart from beginning + if( + player\@MXV@currplayer.settings.startAt.time + || player\@MXV@currplayer.settings.startAt.frame + || player\@MXV@currplayer.settings.startAt.marker + || player\@MXV@currplayer.id == + 'vnd.adobe.swname:AAPL_QuickTime' + ){ + player\@MXV@currplayer.seek( + player\@MXV@currplayer.settings.startAt); + }else{ + player\@MXV@currplayer.stop(); + } + player\@MXV@currplayer.play(); + }% + }% + else{% + player\@MXV@currplayer.pause(); + player\@MXV@currplayer.settings.privateData.paused=true; + }% + }% + catch(e){% open new player if not yet open + if(focusonplayer==undefined){% + var focusonplayer=0; %shared by all annots + }% + \@MXV@settings{\@MXV@ctrls}{\@MXV@palindrome}{\@MXV@repeat}% + {\@MXV@rate}{\@MXV@startat}{\@MXV@endat}{\@MXV@volume}% + \@MXV@events{\@MXV@currplayer}% + {\if@MXV@mouse true\else false\fi}% + {true}% + try{% + var player\@MXV@currplayer=app.media.openPlayer({% + settings: settings,% + events: events% + }); + }% + catch (e){}% + }% + )% + }% + \fi% + \if@MXV@linkclose% + \edef\@MXV@operation{% + /OP 1% + /JS (% + try{% + player\@MXV@currplayer.close(% + app.media.closeReason.general); + player\@MXV@currplayer=null; + }% + catch(e){}% + )% + }% + \fi% + }% + \fi% + \fi% + % + \ifpdf% + \ifthenelse{\isundefined{\@pdfborder}}{% + \def\@MXV@linkattr{}% + }{% + \edef\@MXV@linkattr{% + \if@MXV@beamer% + \@MXV@pdfborder% + \else% + /Border [\@pdfborder]% + \fi% + /C [\@linkbordercolor]% + /H \@pdfhighlight% + }% + }% + % + \pdfstartlink% + attr{\@MXV@linkattr}% + user{% + /Subtype /Link% + /A <<% + /S/GoTo% + /D (@MXV@\@MXV@@label)% + \if@MXV@@draft\else% + \if@MXV@externalviewer\else% + \if@MXV@iiid% + \ifx\@MXV@iiidview\@empty\else% + /Next <<% + /S/GoTo3DView% + /TA \@MXV@getlabelvalue{@MXV@\@MXV@@label.annot}\space 0 R% + /V \@MXV@iiidview% + \fi% + \@MXV@jscriptiiidaction% + \ifx\@MXV@iiidview\@empty\else% + >>% + \fi% + \else% + /Next <<% + /S/Rendition% + /R \@MXV@getlabelvalue{@MXV@\@MXV@@label.rendition}\space 0 R% + /AN \@MXV@getlabelvalue{@MXV@\@MXV@@label.annot}\space 0 R% + \@MXV@operation% + >>% + \fi% + \fi% + \fi% + >>% + }% + \usebox{\@MXV@textbox}% write out text box + \pdfendlink% + \else\if@MXV@dvipdfmx + \ifthenelse{\isundefined{\@pdfborder}}{% + \def\@MXV@linkattr{}% + }{% + \edef\@MXV@linkattr{% + \if@MXV@beamer% + \@MXV@pdfborder% + \else% + /Border [\@pdfborder]% + \fi% + /C [\@linkbordercolor]% + /H \@pdfhighlight% + }% + }% + % + \special{pdf:bannot <<% + \@MXV@linkattr% + /Subtype /Link% + /A <<% + /S/GoTo% + /D (@MXV@\@MXV@@label)% + \if@MXV@@draft\else% + \if@MXV@externalviewer\else% + \if@MXV@iiid% + \ifx\@MXV@iiidview\@empty\else% + /Next <<% + /S/GoTo3DView% + /TA \@MXV@getlabelvalue{@MXV@\@MXV@@label.annot}% + /V \@MXV@iiidview% + \fi% + \@MXV@jscriptiiidaction% + \ifx\@MXV@iiidview\@empty\else% + >>% + \fi% + \else% + /Next <<% + /S/Rendition% + /R \@MXV@getlabelvalue{@MXV@\@MXV@@label.rendition}% + /AN \@MXV@getlabelvalue{@MXV@\@MXV@@label.annot}% + \@MXV@operation% + >>% + \fi% + \fi% + \fi% + >>% + >>}% + \usebox{\@MXV@textbox}% write out text box + \special{pdf:eannot}% + \else% + \pdfmark[{\usebox{\@MXV@textbox}}]{% + pdfmark=/ANN,% + Subtype=/Link,% + Color=\@linkbordercolor,% + AcroHighlight=\@pdfhighlight,% + Raw={% + \@MXV@pdfborder% + /_objdef {linkannot\the\@MXV@links}% + /Action <<% + /S/GoTo% + /D/@MXV@\@MXV@@label% + \if@MXV@@draft\else% + \if@MXV@externalviewer\else% + \if@MXV@iiid% + \ifx\@MXV@iiidview\@empty\else% + /Next <<% + /S/GoTo3DView% + /TA \@MXV@getlabelvalue{@MXV@\@MXV@@label.annot}% + /V \@MXV@iiidview% + \fi% + \@MXV@jscriptiiidaction% + \ifx\@MXV@iiidview\@empty\else% + >>% + \fi% + \else% + /Next <<% + /S /Rendition% + /R {mediarendition\@MXV@getlabelvalue{@MXV@\@MXV@@label.annotid}}% + /AN {screenannot\@MXV@getlabelvalue{@MXV@\@MXV@@label.annot}}% + \@MXV@operation% + >>% + \fi% + \fi% + \fi% + >>% + }% + }% + \fi\fi% + }% + }% +} + +%set to true for certain \movieref options, which require the media player to +%be re-opened +\newboolean{@MXV@requirereopen} + +%standard keys to be processed first +%key definitions for options to \includemovie +\define@key{MXV@user}{draft}[true]{% + \setboolean{@MXV@@draft}{#1}% +} +\define@key{MXV@user}{final}[true]{% + \ifthenelse{\equal{#1}{true}}{% + \setboolean{@MXV@@draft}{false}% + }{% + \setboolean{@MXV@@draft}{true}% + }% +} +\define@key{MXV@user}{label}{%for use with movieref + \gdef\@MXV@label{#1}% +} +\define@key{MXV@user}{controls}[true]{% + \setboolean{@MXV@requirereopen}{true}% + \xdef\@MXV@ctrls{, showUI: #1}% + \xdef\@MXV@@ctrls{/C #1}% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \gdef\@MXV@iiidtoolb{/TB #1}% + }{}% +} +\define@key{MXV@user}{toolbar}[true]{% + \xdef\@MXV@ctrls{, showUI: #1}% + \xdef\@MXV@@ctrls{/C #1}% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \gdef\@MXV@iiidtoolb{/TB #1}% + }{}% +} +\define@key{MXV@user}{volume}{% + \def\@MXV@@volume{/V #1}% + \def\@MXV@volume{#1}% + \setboolean{@MXV@requirereopen}{true}% +} +\define@key{MXV@user}{mimetype}{% + \ifthenelse{\equal{#1}{model/u3d}}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \setboolean{@MXV@iiid}{true}% + \xdef\@MXV@iiidsubtype{U3D}% + }{\@MXV@neediiiD}% + }{}% + \def\@MXV@mime{#1}% +} +\define@key{MXV@user}{playerid}{% + \def\@MXV@player{% + /PL<</MU [<</PID<</U (vnd.adobe.swname:#1)>>>>]>>% + }% +} +\define@key{MXV@user}{autoplay}[true]{% + \setboolean{@MXV@autoplay}{#1}% + \if@MXV@autoplay% + \setboolean{@MXV@autoresume}{false}% + \fi% +} +\define@key{MXV@user}{autostop}[true]{% + \setboolean{@MXV@autostop}{#1}% + \if@MXV@autostop% + \setboolean{@MXV@autopause}{false}% + \fi% +} +\define@key{MXV@user}{autoresume}[true]{% + \setboolean{@MXV@autoresume}{#1}% + \if@MXV@autoresume% + \setboolean{@MXV@autoplay}{false}% + \setboolean{@MXV@autoclose}{false}% + \fi% +} +\define@key{MXV@user}{autopause}[true]{% + \setboolean{@MXV@autopause}{#1}% + \if@MXV@autopause% + \setboolean{@MXV@autostop}{false}% + \setboolean{@MXV@autoclose}{false}% + \fi% +} +\define@key{MXV@user}{autoclose}[true]{% + \setboolean{@MXV@autoclose}{#1}% + \if@MXV@autoclose% + \setboolean{@MXV@autostop}{false}% + \setboolean{@MXV@autopause}{false}% + \fi% +} +\define@key{MXV@user}{continue}[true]{% + \setboolean{@MXV@autostop}{false}% + \setboolean{@MXV@autopause}{false}% + \setboolean{@MXV@autoclose}{false}% +} +\define@key{MXV@user}{open}[true]{% + %no longer supported; once open, media remains loaded + %to avoid reloading when media is to be played again +} +\define@key{MXV@user}{mouse}[true]{% + \setboolean{@MXV@mouse}{#1}% + \setboolean{@MXV@requirereopen}{true}% + \ifthenelse{\equal{false}{#1}\AND\boolean{@MXV@iiiDfeat}}{% + \def\@MXV@iiidia{/3DI #1}% + }{}% +} +\define@key{MXV@user}{palindrome}[true]{% + \xdef\@MXV@palindrome{, palindrome: #1}% + \setboolean{@MXV@requirereopen}{true}% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \gdef\@MXV@iiidpalindrome{/Subtype/Oscillating}% + }{}% +} +\define@key{MXV@user}{rate}{% + \setboolean{@MXV@requirereopen}{true}% + \xdef\@MXV@rate{, rate: #1}% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \gdef\@MXV@iiidrate{/TM #1}% + }{}% +} +\define@key{MXV@user}{repeat}[Infinity]{% + \setboolean{@MXV@requirereopen}{true}% + \ifthenelse{% + \equal{#1}{Infinity}\OR% + \equal{#1}{0}% + }{% + \xdef\@MXV@repeat{, repeat: Infinity}% + \xdef\@MXV@@repeat{/RC 0}% + }{% + \xdef\@MXV@repeat{, repeat: #1}% + \xdef\@MXV@@repeat{/RC #1}% + }% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \ifthenelse{\equal{#1}{Infinity}}{% + \global\@MXV@iiidrepeat=-1% + }{% + \global\@MXV@iiidrepeat=#1% + }% + }{}% +} +\define@key{MXV@user}{startat}{% + \xdef\@MXV@startat{, startAt: {#1}}% + \xdef\@MXV@@startat{{#1}}% +} +\define@key{MXV@user}{endat}{% + \setboolean{@MXV@requirereopen}{true}% + \xdef\@MXV@endat{, endAt: {#1}}% +} +\define@key{MXV@user}{poster}[true]{% + \ifthenelse{\equal{#1}{true}}{% option without arg + \setboolean{@MXV@runposter}{true}% + }{% + \def\@MXV@box##1##2##3{% + \ifpdf% + \mbox{\pdfximage width ##1 height ##2 depth ##3 {#1}}% + \pdfrefximage\pdflastximage% + \else% + \ifthenelse{\isundefined{\includegraphics}}{\@MXV@missing{graphics}}{}% + \@MXV@totalheight=##2% + \advance\@MXV@totalheight by ##3% + \raisebox{-##3}[##2][##3]{% + \includegraphics[% + width=##1,height=##2,totalheight=\@MXV@totalheight,clip]{#1}% + }% + \fi% + }% + }% +} +\define@key{MXV@user}{externalviewer}[true]{% + \setboolean{@MXV@externalviewer}{#1}% +} +\define@key{MXV@user}{inline}[true]{% + \if@MXV@url% + \setboolean{@MXV@inline}{false}% + \else% + \setboolean{@MXV@inline}{#1}% + \fi% + \if@MXV@inline\else% + \setboolean{@MXV@attachment}{false}% + \fi% +} +\define@key{MXV@user}{url}[true]{% + \setboolean{@MXV@url}{#1}% + \if@MXV@url% + \setboolean{@MXV@inline}{false}% + \setboolean{@MXV@attachment}{false}% + \def\@MXV@fsentry{/FS /URL}% + \fi% +} +\define@key{MXV@user}{attach}[true]{% + \setboolean{@MXV@attachment}{#1}% + \if@MXV@attachment% + \setboolean{@MXV@inline}{true}% + \fi% +} +\define@key{MXV@user}{text}{% + \setboolean{@MXV@boxopt}{true}% + \savebox{\@MXV@textbox}{#1}% + \@MXV@width=\wd\@MXV@textbox% + \@MXV@height=\ht\@MXV@textbox% + \@MXV@depth=\dp\@MXV@textbox% +} +\define@key{MXV@user}{textoverposter}[true]{% + \setboolean{@MXV@textoverposter}{#1}% +} +\define@key{MXV@user}{depth}{%set depth of display area + \gdef\@MXV@boxdepth{#1}% +} +%3D specific options +\define@key{MXV@user}{3Dbg}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \def\@MXV@background{/BG<</CS/DeviceRGB/C[#1]>>}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Djscript}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \IfFileExists{#1}{% + \def\@MXV@jscriptiiidfile{#1}% + }{% + \PackageError{movie15}{Script file `#1' cannot be opened for embedding% + }{% + Make sure file `#1' exists and is readable!% + }% + }% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Dcoo}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \def\@MXV@coo{#1}% + \setboolean{@MXV@defaultviewprovided}{true}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Dc2c}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \def\@MXV@ctoc{#1}% + \setboolean{@MXV@defaultviewprovided}{true}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Droo}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \def\@MXV@roo{#1}% + \setboolean{@MXV@defaultviewprovided}{true}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Daac}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \def\@MXV@aac{#1}% + \setboolean{@MXV@defaultviewprovided}{true}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Droll}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \def\@MXV@roll{#1}% + \setboolean{@MXV@defaultviewprovided}{true}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Dviews}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \IfFileExists{#1}{% + \def\@MXV@viewsfile{#1}% + }{% + \PackageError{movie15}{3D views file `#1' cannot be opened% + }{% + Make sure file `#1' exists and is readable!% + }% + }% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Dlights}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \gdef\@MXV@lights{/LS <</Subtype/#1>>}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Drender}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \gdef\@MXV@render{/RM <</Subtype/#1>>}% + }{\@MXV@neediiiD}% +} +%options for \movieref command +\define@key{MXV@user}{play}[true]{% + \setboolean{@MXV@linkplay}{#1}% + \if@MXV@linkplay% + \setboolean{@MXV@linkpause}{false}% + \setboolean{@MXV@linkresume}{false}% + \setboolean{@MXV@linkstop}{false}% + \setboolean{@MXV@linkclose}{false}% + \fi% +} +\define@key{MXV@user}{pause}[true]{% + \setboolean{@MXV@linkpause}{#1}% + \if@MXV@linkpause% + \setboolean{@MXV@linkresume}{false}% + \setboolean{@MXV@linkstop}{false}% + \setboolean{@MXV@linkclose}{false}% + \setboolean{@MXV@linkplay}{false}% + \fi% +} +\define@key{MXV@user}{resume}[true]{% + \setboolean{@MXV@linkresume}{#1}% + \if@MXV@linkresume% + \setboolean{@MXV@linkpause}{false}% + \setboolean{@MXV@linkstop}{false}% + \setboolean{@MXV@linkclose}{false}% + \setboolean{@MXV@linkplay}{false}% + \fi% +} +\define@key{MXV@user}{stop}[true]{% + \setboolean{@MXV@linkstop}{#1}% + \if@MXV@linkstop% + \setboolean{@MXV@linkpause}{false}% + \setboolean{@MXV@linkresume}{false}% + \setboolean{@MXV@linkclose}{false}% + \setboolean{@MXV@linkplay}{false}% + \fi% +} +\define@key{MXV@user}{close}[true]{% + \setboolean{@MXV@linkclose}{#1}% + \if@MXV@linkclose% + \setboolean{@MXV@linkpause}{false}% + \setboolean{@MXV@linkresume}{false}% + \setboolean{@MXV@linkstop}{false}% + \setboolean{@MXV@linkplay}{false}% + \fi% +} +\define@key{MXV@user}{reset}[true]{% + \setboolean{@MXV@linkreset}{#1}% + \if@MXV@linkreset% + \setboolean{@MXV@requirereopen}{true}% + \fi% +} +\define@key{MXV@user}{default}[true]{% synonyme for `reset' + \setboolean{@MXV@linkreset}{#1}% + \if@MXV@linkreset% + \setboolean{@MXV@requirereopen}{true}% + \fi% +} +\define@key{MXV@user}{3Dviewindex}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \ifthenelse{% + \equal{#1}{F}% + \OR\equal{#1}{L}% + \OR\equal{#1}{N}% + \OR\equal{#1}{P}% + \OR\equal{#1}{D}% + }{% + \gdef\@MXV@iiidview{/#1}% any of F, L, N, P, D + }{% + \gdef\@MXV@iiidview{#1}% number (index) + }% + \setboolean{@MXV@defaultviewprovided}{false}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Dcalculate}[30]{% + %calculate optimal 3D settings for roo and coo for a given aac + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \gdef\@MXV@calc{#1}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Dgetview}[true]{% + %print current 3D camera settings + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \setboolean{@MXV@iiidgetview}{#1}% + }{\@MXV@neediiiD}% +} +\define@key{MXV@user}{3Dresource}{% + \ifthenelse{\boolean{@MXV@iiiDfeat}}{% + \IfFileExists{#1}{% + \setboolean{@MXV@resource}{true}% + \xdef\@MXV@iiidopt{3Dresource=#1, \@MXV@iiidopt}% + }{% + \PackageError{movie15}{3D resource file `#1' cannot be opened% + }{% + Make sure file `#1' exists and is readable!% + }% + }% + }{\@MXV@neediiiD}% +} + +%compatibility options for \movie and \hyperlinkmovie commands +\define@key{MXV@user}{borderwidth}{% + %ignored; acroread doesn't draw borders around screen annots anyway +} +\define@key{MXV@user}{height}{%set height of display area + \gdef\@MXV@boxheight{#1}% +} +\define@key{MXV@user}{width}{%set width of display area + \gdef\@MXV@boxwidth{#1}% +} +\define@key{MXV@user}{autostart}[true]{% + \xdef\@MXV@autostart{, autoplay=#1}% +} +\define@key{MXV@user}{loop}[Infinity]{% + \xdef\@MXV@loop{, repeat=#1}% +} +\define@key{MXV@user}{once}[]{% + \xdef\@MXV@loop{, repeat=1}% +} +\define@key{MXV@user}{showcontrols}[true]{% + \xdef\@MXV@showcontrols{, controls=#1}% +} +\define@key{MXV@user}{start}{% + \gdef\@MXV@starttime##1s{% + \global\@MXV@start=##1pt% + }% + \@MXV@starttime #1% +} +\define@key{MXV@user}{duration}{% + \gdef\@MXV@durationtime##1s{% + \global\@MXV@end=##1pt% + }% + \@MXV@durationtime #1% +} + +%options to be passed to internal macro \@MXV@includeiiid +\define@key{MXV@iiid}{3Dresource}{% + \@MXV@addresource{#1}% +} + +%compatibility macros +\providecommand\movie[3][]{% + \ifpdf\else% + \ifthenelse{\isundefined{\pdfmark}\AND\isundefined{\@pdfm@mark}}{\@MXV@missing{hyperref}}{}% + \fi% + \leavevmode% + \@MXV@reset% + \def\@MXV@autostart{}\def\@MXV@loop{}\def\@MXV@showcontrols{}% + \def\@MXV@starttime{}\def\@MXV@durationtime{}% + \setkeys{MXV@user}{#1}% + % + %sanity checks + \if@MXV@boxopt% + \PackageError{movie15}{% + Option `text' cannot be used with command `\string\movie'.\MessageBreak + Instead, put text into the 1st argument of `\string\movie' + }{}% + \fi% + % + \ifx\@MXV@durationtime\@empty\else\ifx\@MXV@startat\@empty\else% + \PackageError{movie15}{% + Options `startat' and `duration' cannot be used\MessageBreak + together.\MessageBreak + Possible combinations are `startat'/`endat',\MessageBreak + `start'/`endat' or `start'/`duration' + }{}% + \fi\fi% + % + %option list + \edef\@MXV@movieoptions{#1\@MXV@autostart\@MXV@loop\@MXV@showcontrols}% + % + %determine playback section + \ifx\@MXV@starttime\@empty\else% + \edef\@MXV@movieoptions{\@MXV@movieoptions, % + startat=time:\strip@pt\@MXV@start}% + \fi% + \ifx\@MXV@durationtime\@empty\else% + \advance\@MXV@end by \@MXV@start% + \edef\@MXV@movieoptions{\@MXV@movieoptions, % + endat=time:\strip@pt\@MXV@end}% + \fi% + % + %text option from 2nd argument + \savebox{\@MXV@textbox}{#2}% + \edef\@MXV@movieoptions{[\@MXV@movieoptions, text={\noexpand\usebox{% + \noexpand\@MXV@textbox}}]}% + \expandafter% + \includemovie\@MXV@movieoptions{\@MXV@boxwidth}{\@MXV@boxheight}{#3}% +} + +\newcommand\hyperlinkmovie[3][]{% + \ifpdf\else% + \ifthenelse{\isundefined{\pdfmark}\AND\isundefined{\@pdfm@mark}}{\@MXV@missing{hyperref}}{}% + \fi% + \leavevmode% + \@MXV@reset% + \def\@MXV@autostart{}\def\@MXV@loop{}\def\@MXV@showcontrols{}% + \def\@MXV@starttime{}\def\@MXV@durationtime{}% + \setkeys{MXV@user}{#1}% + % + %sanity check + \ifx\@MXV@durationtime\@empty\else\ifx\@MXV@startat\@empty\else% + \PackageError{movie15}{% + Options `startat' and `duration' cannot be used\MessageBreak + together.\MessageBreak + Possible combinations are `startat'/`endat',\MessageBreak + `start'/`endat' or `start'/`duration' + }{}% + \fi\fi% + % + %option list + \edef\@MXV@movieoptions{#1\@MXV@autostart\@MXV@loop\@MXV@showcontrols}% + % + %determine playback section + \ifx\@MXV@starttime\@empty\else% + \edef\@MXV@movieoptions{\@MXV@movieoptions, % + startat=time:\strip@pt\@MXV@start}% + \fi% + \ifx\@MXV@durationtime\@empty\else% + \advance\@MXV@end by \@MXV@start% + \edef\@MXV@movieoptions{\@MXV@movieoptions, % + endat=time:\strip@pt\@MXV@end}% + \fi% + % + \edef\@MXV@movieoptions{[\@MXV@movieoptions]}% + \expandafter\movieref\@MXV@movieoptions{#2}{#3}% +} diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/recplot.asy b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/recplot.asy new file mode 100644 index 00000000000..2c3ddca9f31 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/recplot.asy @@ -0,0 +1,61 @@ +// 使用自适应方法产生 y = f(x) 的图象 guide
+guide plot(real f(real), real min, real max, int nplotpoints=10, int maxrec=7)
+{
+ if (nplotpoints < 2)
+ nplotpoints = 2;
+ // 描初始的 nplotpoints 个点,并估计函数变化幅度
+ pair[] fpoints;
+ real fmax = -infinity, fmin = infinity;
+ for (int i = 0; i <= nplotpoints; ++i) {
+ real x = min + i/nplotpoints * (max-min);
+ pair z = (x, f(x));
+ fmax = max(fmax, z.y);
+ fmin = min(fmin, z.y);
+ fpoints.push(z);
+ }
+ // 定义辅助的递归函数:在规定的递归次数之内,在两个样本点之间描新点
+ // 误差 fuzz 达到函数变化幅度估计值的 1/500 为止
+ // 这个误差值在一般屏幕显示上只有一两个像素
+ real fuzz = max(0.002(fmax-fmin), realEpsilon);
+ guide helper(int nrec, pair a, pair b)
+ {
+ if (nrec == 0)
+ return b;
+ pair mid = (a+b)/2;
+ pair z = (mid.x, f(mid.x));
+ if (abs(z.y-mid.y) < fuzz)
+ return z -- b;
+ else
+ return helper(nrec-1, a, z) -- helper(nrec-1, z, b);
+ }
+ // 递归构造 guide
+ guide g = fpoints[0];
+ for (int i = 0; i < nplotpoints; ++i)
+ g = g -- helper(maxrec, fpoints[i], fpoints[i+1]);
+ return g;
+}
+
+
+
+//////////////////////////////////////////
+
+real f(real x) {return 2sin(x^3);}
+real min = -5.0, max = 5.0;
+
+// 用自适应方法绘制函数 f(x)
+guide g = scale(1cm)*plot(f, min, max);
+draw(g, red+1pt);
+for (int i = 0; i < size(g); ++i) {
+ draw(point(g,i), blue+2pt);
+}
+write(size(g));
+
+
+// 用 graph 模块的默认方法(均匀取点)绘制函数 f(x)
+import graph;
+guide h = shift(-5cm*I)*scale(1cm)*graph(f, min, max);
+draw(h, orange+1pt);
+for (int i = 0; i < size(h); ++i) {
+ draw(point(h,i), blue+2pt);
+}
+write(size(h));
diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/stars.asy b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/stars.asy new file mode 100644 index 00000000000..3d4fd93ef75 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/stars.asy @@ -0,0 +1,70 @@ +settings.tex = "xelatex";
+
+srand(seconds());
+
+usepackage("xeCJK");
+texpreamble(
+"\setCJKmainfont{FZSongHeiTi_GB18030}");
+
+Label L =
+"\fontsize{16bp}{20bp}\selectfont
+\begin{minipage}{3em}
+天上星\par
+亮晶晶\par
+永燦爛\par
+長安寧
+\end{minipage}";
+
+path unitstar(int n = 5, real r = 0, real angle = 90)
+{
+ guide g;
+ if (n < 2) return nullpath;
+ real rot = 180/n;
+ if (r == 0) {
+ if (n < 5)
+ r = 1/4;
+ else
+ r = Cos(2rot) / Cos(rot);
+ }
+ for (int k = 0; k < n; ++k)
+ g = g -- dir(angle+2k*rot) -- r * dir(angle+(2k+1)*rot);
+ g = g -- cycle;
+ return g;
+}
+
+pen operator %(pen p, real x) {return interp(white, p, x/100);}
+pen[] colors = {blue%50, yellow%50, red%50, orange%50};
+for (int i = 0; i < 100; ++i)
+{
+ pair pos = (unitrand() * 12cm, unitrand()*9cm);
+ int r = rand();
+ if (r < randMax/3)
+ fill(shift(pos) * scale(2+unitrand()*3) * unitstar(4),
+ colors[rand()%colors.length]);
+ else if (r < 2/3*randMax)
+ fill(shift(pos) * scale(2+unitrand()*3) * unitstar(5),
+ colors[rand()%colors.length]);
+ else
+ draw(pos, white+1bp);
+}
+
+
+fill(circle((2cm,8cm),0.5cm), paleyellow);
+unfill(circle((1.7cm,7.9cm), 0.5cm));
+
+pair orig=(9cm,0.5cm), end=(1cm,4cm);
+path tail = orig{NW} .. {W}end;
+path tailN = orig{NW} .. {W}(end+N);
+path tailS = orig{NW} .. {W}(end+S);
+
+radialshade(circle(orig, 0.5cm), yellow, orig, 0.1cm, darkblue, orig, 0.5cm);
+for (int i = 0; i < 1000; ++i) {
+ real t = unitrand()^3;
+ real r = (0.2 + t)*cm;
+ pair z = point(tail, t) + r*(unitrand()-1/2, unitrand()-1/2);
+ draw(z,interp(yellow,white,unitrand())+1bp);
+}
+
+label(L, (12cm,9cm), align=SW, yellow, Fill(darkblue+opacity(0.5)));
+
+shipout(bbox(Fill(darkblue)));
diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/tiling.asy b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/tiling.asy new file mode 100644 index 00000000000..d13bf6f0d79 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/tiling.asy @@ -0,0 +1,34 @@ +// tiling.asy
+// 铺砌图案
+// by milksea
+import math;
+size(15cm);
+
+void sheephead(pair pos, pen color)
+{
+ path headleft = (0,1.5){SE} .. tension 1.4 .. (0.5,-0.2){dir(-150)} ..
+ {NW}(0,0);
+ path headbottom = (0,0){SE} .. {dir(30)}(0.5,-0.2) ..{SE}(3,0);
+ path head = headleft & headbottom &
+ shift(3,0)*reverse(headleft) & shift(0,1.5)*reverse(headbottom) & cycle;
+
+ path eye = circle((2.6,1.2), 0.1);
+ path[] ear = (2.3,1.3) .. (2.1,1.5) .. (2.2,1.7)
+ & (2.2,1.7) .. (2.4,1.6) .. (2.5,1.4);
+ path muzzle = circle((3.5,0.5), 0.15);
+ path mouth = (3,0.4) .. (3.4,0.1) .. (3.6,0.2);
+
+ filldraw(shift(pos) * head, color, linewidth(2));
+ fill(shift(pos) * (eye ^^ muzzle));
+ draw(shift(pos) * (ear ^^ mouth), linewidth(2));
+}
+
+for (int i = 0; i < 8; ++i) {
+ for (int j = 0; j < 8; ++j) {
+ pair pos = (i*3.0, j*1.5);
+ pen color = (i+j)%2==0 ? cyan : yellow;
+ sheephead(pos, color);
+ }
+}
+
+clip(ellipse((12,6), 10, 5));
diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/xiantu.asy b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/xiantu.asy new file mode 100644 index 00000000000..dbd186448dd --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/figure-src/xiantu.asy @@ -0,0 +1,63 @@ +//pen operator %(pen p, real x) {return interp(white, p, x/100);}
+pen operator %(pen p, real x) {return p + opacity(x/100);}
+
+pen helpline = gray + 0.4;
+pen zhu = red + 0.8;
+pen huang = yellow + 0.8;
+
+path[] grid(pair z1, pair z2, real xstep = 1, real ystep = xstep)
+{
+ path[] g;
+ pair lb = minbound(z1, z2);
+ pair rt = maxbound(z1, z2);
+ for (real x = ceil(lb.x/xstep)*xstep; x <= rt.x; x += xstep)
+ g.push((x, lb.y) -- (x, rt.y));
+ for (real y = ceil(lb.y/ystep)*ystep; y <= rt.y; y += ystep)
+ g.push((lb.x, y) -- (rt.x, y));
+ return g;
+}
+
+unitsize(1cm);
+settings.tex = "xelatex";
+
+usepackage("xeCJK");
+usepackage("CJKmove");
+texpreamble(
+"\setCJKmainfont[RawFeature={script=hani:language=CHN:vertical:+valt}]
+{FZSongHeiTi_GB18030}
+%\XeTeXuseglyphmetrics=0
+\setCJKmove{-0.45}{0.5}
+\CJKmove
+");
+defaultpen(fontsize(10.5)); // 五号
+
+Label vert(Label L)
+{
+ return rotate(-90) * L;
+}
+
+draw(grid((0,0), (7,7)), helpline);
+draw(shift(4)*rotate(degrees((3,4)))*grid((0,0), (5,5)), helpline);
+
+path huangshi = box((3,3), (4,4));
+path[] zhushi = (0,3)--(4,0)--(7,4)--(3,7)--cycle ^^ reverse(huangshi);
+filldraw(zhushi, zhu%10, zhu);
+fill(huangshi, huang%50);
+draw((0,3)--(4,3) ^^ (4,0)--(4,4) ^^ (7,4)--(3,4) ^^ (3,7)--(3,3), zhu);
+
+label(vert("中黃實"), (3.5,3.5), 0.5huang);
+label(vert("朱實"), (2,4), right, 0.5zhu);
+label(vert("弦實"), (5,4), left, interp(0.5huang,0.5zhu,0.5));
+label(Label("句三",MidPoint,Rotate(down)), (4,0)--(4,3), LeftSide);
+label(Label("股四",MidPoint,Rotate(left)), (0,3)--(4,3), RightSide);
+label(Label("弦五",MidPoint,Rotate((4,-3))), (0,3)--(4,0), LeftSide);
+
+label(vert("朱實六黃實\ 一"), (0,3.5), left, fontsize(14)); // 四号字
+label(vert("弦實二十五朱及黃"), (7,3.5), right, fontsize(14));
+
+label(vert("弦圖"), (3.5,7), 4up, fontsize(16)); // 三号字
+
+label(vert(minipage("句股各自乘,併之為弦實,開方除之即弦。
+案:弦圖又可以句股相乘為朱實二,倍之為朱實四,
+以句股之差自相乘為中黃實,加差實亦成弦實。", 64)), (3.5,0), 4down);
+
diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/main.tex b/Master/texmf-dist/doc/support/asymptote-by-example/src/main.tex new file mode 100644 index 00000000000..fd76bfd0cd5 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/main.tex @@ -0,0 +1,117 @@ +%# -*- coding: utf-8 -*- +\documentclass[cs4size,oneside,openany,nofonts,UTF8,CJKnormalspaces] + {ctexbook}[2009/05/20] +\linespread{1.0} + +%\includeonly{tiling} + +\usepackage{amsmath} + +\usepackage{makeidx} +\makeindex + +\usepackage{geometry} +\geometry{screen,left=0.5cm,right=0.5cm,top=2cm,bottom=1cm} + +\usepackage{fancyhdr} +\renewcommand{\headrulewidth}{0pt} +\pagestyle{fancy} +\fancyhf{} +\lhead{\normalfont\rightmark} +\rhead{\normalfont\thepage} +\fancypagestyle{plain}{\fancyhf{}} + +\usepackage{float} +\floatplacement{htbp} +\AtBeginDocument{ + \renewcommand{\topfraction}{0.9} % default 0.7 + \renewcommand{\bottomfraction}{0.5} % default 0.3 + \renewcommand{\textfraction}{0.1} % default 0.2 + \renewcommand{\floatpagefraction}{0.8} % default 0.5 + \setlength{\floatsep}{3pt plus 1pt minus 1pt} % default 12pt plus2pt minus2pt + \setlength{\textfloatsep}{6pt plus 1pt minus 1pt} % default 20pt plus2pt minus4pt + \setlength{\intextsep}{3pt plus 1pt minus 1pt} % default 12pt plus2pt minus2pt +} + +\usepackage{caption} +\captionsetup{skip=6pt} % default 10pt + +\usepackage{xltxtra} +\usepackage{myfonts} + +\usepackage{multicol} + +\usepackage{xcolor} +\pagecolor{lightgray!50} + +\usepackage{asymptote} +\usepackage{graphicx} +\usepackage{hyperref} +\hypersetup{ + bookmarksopen=false, + pdfpagemode=FullScreen, + colorlinks=false, + pdfborder=0 0 0 +} +\renewcommand\figureautorefname{图} + +\usepackage{asysyntex} +\usepackage{listings} +\lstloadlanguages{[LaTeX]TeX} +\newcommand*\texcode{\expandafter\lstinline[language={[LaTeX]TeX}]} + + +\newcommand*\prgname[1]{\textsf{#1}} +\newcommand*\Asy{\textsf{Asymptote}} +\newcommand*\asyversion{1.70} +\begin{document} + +\frontmatter + +% 标题页 +\begin{titlepage} +\vspace*{\stretch{1}} +\begin{center} + {\zihao{2}\bfseries + \Asy\ 范例教程} +\bigskip + + {\zihao{3}\sffamily + milksea} +\bigskip + + {\today} +\end{center} +\vspace*{\stretch{3}} +\end{titlepage} + +% 版权页 +\begingroup +\setlength{\parindent}{0pt} +\vspace*{\stretch{1}} +本文是基于 \Asy\ \asyversion{} 的一组教程。 + +\url{http://asy4cn.googlecode.com/} +\medskip + +版权所有\copyright\ 2009 milksea, milksea@163.com + +{\setlength{\leftskip}{2em} +在 GNU General Public License(GNU 通用公共许可证)的条款下授予复制、发布和/或修改此文档的许可。许可证条款见附录 \ref{chap:license}。\par} +\endgroup +\newpage + +\tableofcontents + +\mainmatter +\include{xiantu} +\include{tiling} + +\appendix +\include{gpl-3.0} + +\printindex + +\bibliographystyle{plain} +\bibliography{asy} +\end{document} diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/makepdf b/Master/texmf-dist/doc/support/asymptote-by-example/src/makepdf new file mode 100644 index 00000000000..7c172040044 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/makepdf @@ -0,0 +1,9 @@ +#!/bin/sh +xelatex main +asy main +xelatex main +makeindex main +bibtex main +xelatex main +xelatex main +mv main.pdf AsymptoteByExample.pdf diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/myfonts.sty b/Master/texmf-dist/doc/support/asymptote-by-example/src/myfonts.sty new file mode 100644 index 00000000000..d67ddcf6b3d --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/myfonts.sty @@ -0,0 +1,18 @@ +\ProvidesPackage{myfonts} + +% Lucida 系列字体设置 +\setmainfont[Mapping=tex-text,Scale=0.95]{Lucida Bright} +\setsansfont[Mapping=tex-text,Scale=0.95]{Lucida Sans} +\setmonofont[Scale=0.95]{Lucida Sans Typewriter Std} + +% 方正系列字体设置 +\setCJKmainfont[BoldFont={FZXiaoBiaoSong-B05}, ItalicFont={FZKai-Z03}]{FZShuSong_GB18030-Z01} +\setCJKsansfont[BoldFont={FZHei-B01}]{FZXiHei I-Z08} +\setCJKmonofont[BoldFont={FZCuYuan-M03}]{FZZhunYuan-M02} + +\setCJKfamilyfont{rm}[BoldFont={FZXiaoBiaoSong-B05}, ItalicFont={FZKai-Z03}]{FZShuSong_GB18030-Z01} +\setCJKfamilyfont{sf}[BoldFont={FZHei-B01}]{FZXiHei I-Z08} +\setCJKfamilyfont{tt}[BoldFont={FZCuYuan-M03}]{FZZhunYuan-M02} + +\endinput + diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/tiling.pdf b/Master/texmf-dist/doc/support/asymptote-by-example/src/tiling.pdf Binary files differnew file mode 100644 index 00000000000..c4dc61a6a8f --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/tiling.pdf diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/tiling.tex b/Master/texmf-dist/doc/support/asymptote-by-example/src/tiling.tex new file mode 100644 index 00000000000..47cfc74cf14 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/tiling.tex @@ -0,0 +1,306 @@ +%# -*- coding: utf-8 -*- +% tiling.tex +% asymptotebyexample 的一章,曲线绘制和编程入门 + +\chapter{André Deledicq 的铺砌插画} +\nocite{pstricks} + +André 是一名兴趣广泛的法国数学教师,在他的新著《Le monde des pavages》(《铺 +砌世界》)中,打算画一幅有关羊的铺砌插画: +\begin{figure}[H] + \centering + \includegraphics{tiling.pdf} + \caption{André 理想中的铺砌图} + \label{fig:tiling} +\end{figure} + +André 很清楚他要画的图形的数学理论,但 André 的朋友 Timothy 告诉他要画这样 +的图形多少是需要一些编程的知识的,对于他这样一位往日对计算机并不通晓的人来说 +可能会有困难。不过 André 并不以为意:这世上还有什么比数学更难的呢?于是他兴 +致勃勃的开始了。 + +\section{从矩形到铺砌} +\label{sec:rect2tiling} + +铺砌图,顾名思义,就是像铺地板砖一样,把许多相同样式的图形平铺开来。不过,并 +不是什么图形都可以平铺填满整个平面的——比如圆形就不行。把许多圆形一个挨一个 +排列起来,也只能得到 +\begin{figure}[H] +\centering +\begin{asy} +size(0,2cm); +for (int i = 0; i < 3; ++i) + for (int j = 0; j < 10; ++j) + filldraw(circle((j,i), 0.5), lightblue); +\end{asy} +\end{figure} +\noindent 或者是 +\begin{figure}[H] +\centering +\begin{asy} +size(0,2cm); +for (int i = 0; i < 3; ++i) + for (int j = 0; j < 10; ++j) + filldraw(circle((j+0.5(i%2),sqrt(3)/2*i), 0.5), lightblue); +\end{asy} +\end{figure} +\noindent 都会留下许多空隙。而矩形、平行四边形、六边形等等都可以不留空隙地把平面铺满。 + +但问题是,如何设计出 André 理想中的那种看起来形状不规则的铺砌图案呢? + +身为数学教师的 André 当然有办法。其实不规则铺砌图案还是规则图案的变形。 +André 要画的羊形铺砌图,其实就是从矩形铺砌变化而来的。只要把一个矩形图案的上 +下两边、左右两边分别变形,使得变形后的上边与下边、左边与右边还对应重合,就依 +然可以完美地拼合起来。这正是铺砌图案最基本的构成方式: +\begin{figure}[H] +\centering +\begin{asy} +size(0,5cm); +defaultpen(linewidth(1mm)); +path rec = box((0,0), (2,1)); +draw(rec); + +draw(shift(3,0)*rec, gray+0.5mm); +guide left = (0,1) -- (-0.2,0.8) -- (0,0.6) -- (0.1,0.1) -- (0,0); +guide bot = (0,0) -- (0.2,0.1) -- (1.6,-0.1) -- (2,0); +draw(shift(3,0) * (left ^^ shift(2,0)*left), heavyblue); +draw(shift(3,0) * (bot ^^ shift(0,1)*bot), heavygreen); + +guide shape = left & bot & shift(2,0)*reverse(left) + & shift(0,1)*reverse(bot) & cycle; +for (int i = 0 ; i < 2; ++i) + for (int j = 0; j < 4; ++j) + filldraw(shift(0.5+j,-1.5+0.5i)*scale(0.5)*shape, lightblue); +\end{asy} +\end{figure} + +有了这个方法,对复杂的铺砌图,也只要从一个基本形状(比如矩形、正六边形)开始 +变形,就等到铺砌所需要的一块“砖”。 + +因此,要画出羊头形状铺砌图,只要把一个矩形按照上面的要求变形为一个羊头形状, +在不同的位置重复画出就可以了。 + +\section{变量与曲线} + +下面的问题就是,怎么画一个羊头呢?更具体地说,怎么画出羊头的曲线呢? + +那么,首先要了解如何在 \Asy{} 中描述曲线。\ref{sec:linedraw} 节中提到 |--| 连 +结一组坐标就成为直(折)线段;类似地,用 |..| 连结坐标就得到经过这些坐标点的 +曲线: +\begin{lstlisting} +size(5cm,0); +pair z1 = (0,1), z2 = (1,1), z3 = (2,1), + z4 = (0,0), z5 = (1,0), z6 = (2,0); +path p = z4 .. z1 .. z2 .. z6; +draw(p, gray+2mm); +\end{lstlisting} +\begin{figure}[H] + \centering +\begin{asy} +size(5cm,0); +pair z1 = (0,1), z2 = (1,1), z3 = (2,1), + z4 = (0,0), z5 = (1,0), z6 = (2,0); +path p = z4 .. z1 .. z2 .. z6; +draw(p, gray+2mm); +dot(Label("1", align=NW), z1); +dot(Label("2", align=NE), z2); +dot("3", z3); +dot("4", z4); +dot("5", z5); +dot("6", z6); +\end{asy} +\end{figure} + +在这里,我们定义了一些变量\index{变量}以使代码清晰(这里略去了画点和标签的代 +码)。|pair|\index{pair@\lstinline=pair=} 类型的变量 |z1|, \ldots, |z6| 保存 +六个坐标\index{坐标},|path|\index{path@\lstinline=path=} 类型的变量 |p| 保存 +一条曲线路径\index{路径}。因而上面 |size| 之后的绘图代码就相当于 +\begin{lstlisting} +draw( (0,0) .. (0,1) .. (1,1) .. (2,0), gray+2mm ); +\end{lstlisting} +其中前面的一句 |size(5cm,0)|\index{size@\lstinline=size=} 表示代码中的坐标只 +是相对位置,最后将整个图形按比例放缩为 $5$\,cm 宽\footnote{注意坐标、图形会被 +放缩,但画笔的宽度不会放缩。}。类似地,也可以使用 |size(0,4cm)| 把图形放缩到 +$4$\,cm 高。 + +最重要的当然还是曲线的表示。以 |..| 连结的坐标会以一种尽量接近圆弧的方式连为 +经过这些点的光滑曲线。与画直线类似,|cycle|\index{cycle@\lstinline=cycle=} 可 +以作为一个特殊的坐标产生闭合曲线,即一条闭路径\index{路径!闭路径}: +\begin{lstlisting} +path q = z4 .. z1 .. z2 .. z6 .. cycle; +draw(q, gray+2mm); +\end{lstlisting} +\begin{figure}[H] + \centering +\begin{asy} +size(5cm,0); +pair z1 = (0,1), z2 = (1,1), z3 = (2,1), + z4 = (0,0), z5 = (1,0), z6 = (2,0); +path q = z4 .. z1 .. z2 .. z6 .. cycle; +draw(q, gray+2mm); +dot(Label("1", align=NW), z1); +dot(Label("2", align=NE), z2); +dot("3", z3); +dot("4", z4); +dot("5", z5); +dot("6", z6); +\end{asy} +\end{figure} + +变量不仅仅是给了坐标、路径等对象一个简洁的名字,它也使得对同一个对象重复使用 +并进行不同的操作变得十分方便: +\begin{lstlisting} +fill(q, lightblue); +draw(q, gray+2mm); +\end{lstlisting} +\begin{figure}[H] + \centering +\begin{asy} +size(5cm,0); +pair z1 = (0,1), z2 = (1,1), z3 = (2,1), + z4 = (0,0), z5 = (1,0), z6 = (2,0); +path q = z4 .. z1 .. z2 .. z6 .. cycle; +fill(q, lightblue); +draw(q, gray+2mm); +dot(Label("1", align=NW), z1); +dot(Label("2", align=NE), z2); +dot("3", z3); +dot("4", z4); +dot("5", z5); +dot("6", z6); +\end{asy} +\end{figure} + +就像使用 |box| 可以直接得到矩形一样,最常用的曲线:圆、椭圆和圆弧,也可以使用 +现成的命令得到: +\begin{table}[H] +\noindent +\begin{tabular}{ll} +|circle(c, r)| & 圆心 |c|,半径 |r| 的圆,这是逆时针方向的闭曲线; \\ +|ellipse(c, a, b)| & 中心为 |c|,长半轴 |a|,短半轴 |b| 的椭圆,这也是逆时针 +方向的闭曲线; \\ +|arc(c, r, angle1, angle2)| & 圆心 |c|,半径 |r|,角度从 |angle1| 到 |angle2| +的圆弧。 +\end{tabular} +\end{table} + +例如: +\begin{lstlisting} +filldraw( circle((0,0), 1cm), lightblue, gray+2mm ); +draw( arc((5cm,0), 1cm, 45, 135), gray+2mm ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +filldraw( circle((0,0), 1cm), lightblue, gray+2mm ); +draw( arc((5cm,0), 1cm, 45, 135), gray+2mm ); +\end{asy} +\end{figure} + +一条用 |cycle| 产生的闭路径和简单地把首尾结点重合的路径是非常不同的。首先,只 +有闭路径可以填充颜色;其次,使用 |cycle| 连结的曲线在起点处是光滑连接的,而如 +果只是首尾结点重合则不会光滑连接。试将下面的曲线 |q2| 与上面的曲线 |q| 比较: +\begin{lstlisting} +path q2 = z4 .. z1 .. z2 .. z6 .. z4; +draw(q2, gray+2mm); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +size(5cm,0); +pair z1 = (0,1), z2 = (1,1), z3 = (2,1), + z4 = (0,0), z5 = (1,0), z6 = (2,0); +path q2 = z4 .. z1 .. z2 .. z6 .. z4; +draw(q2, gray+2mm); +dot(Label("1", align=NW), z1); +dot(Label("2", align=NE), z2); +dot("3", z3); +dot("4", z4); +dot("5", z5); +dot("6", z6); +\end{asy} +\end{figure} + +现在有了绘制曲线的方法,画出一个羊头就只是把草稿上的坐标连接起来而已。André +有一个纸上的草图,于是在描出几个点以后,他很快得到这样的结果(这里给图形增加 +了辅助网格): +\begin{lstlisting} +size(0,4cm); +pen outline = black+1mm; +// `\color{comment}头` +path head = (0.5,-0.2) .. (0.6,0.5) .. (0.2,1.3) .. (0,1.5) .. (0,1.5) + .. (0.4,1.3) .. (0.8,1.5) .. (2.2,1.9) .. (3,1.5) .. (3.2,1.3) + .. (3.6,0.5) .. (3.4,-0.3) .. (3,0) .. (2.2,0.4) .. (0.5,-0.2) .. cycle; +filldraw(head, cyan, outline); +dot(head, red+1mm); // `\color{comment}画出羊头路径上的结点` +// `\color{comment}五官` +fill( circle((2.65,1.25), 0.12), outline ); +fill( (3.5,0.3) .. (3.35,0.45) .. (3.5,0.6) .. (3.6,0.4) .. cycle, outline ); +draw( (3,0.35) .. (3.3,0.1) .. (3.6,0.05), outline ); +draw( (2.3,1.3) .. (2.1, 1.5) .. (2.15,1.7), outline ); +draw( (2.1,1.7) .. (2.35,1.6) .. (2.45,1.4), outline ); +\end{lstlisting} +\begin{figure}[H] + \centering +\begin{asy} +size(0,4cm); +import math; +add(scale(1/2)*shift(0,-1)*grid(8,5,gray)); +dot(Label("$O$",align=left), 0); +label("$1$", (0,1), align=W); label("$2$", (0,2), align=W); +label("$1$", (1,-0.5), align=S); label("$2$", (2,-0.5), align=S); +label("$3$", (3,-0.5), align=S); label("$4$", (4,-0.5), align=S); +pen outline = black+1mm; +path head = (0.5,-0.2) .. (0.6,0.5) .. (0.2,1.3) .. (0,1.5) .. (0,1.5) + .. (0.4,1.3) .. (0.8,1.5) .. (2.2,1.9) .. (3,1.5) .. (3.2,1.3) + .. (3.6,0.5) .. (3.4,-0.3) .. (3,0) .. (2.2,0.4) .. (0.5,-0.2) .. cycle; +filldraw(head, cyan, outline); +dot(head, red+1mm); +fill( circle((2.65,1.25), 0.12), outline ); +fill( (3.5,0.3) .. (3.35,0.45) .. (3.5,0.6) .. (3.6,0.4) .. cycle, outline ); +draw( (3,0.35) .. (3.3,0.1) .. (3.6,0.05), outline ); +draw( (2.3,1.3) .. (2.1, 1.5) .. (2.15,1.7), outline ); +draw( (2.1,1.7) .. (2.35,1.6) .. (2.45,1.4), outline ); +\end{asy} +\end{figure} + +在一开始,André 使用 +\begin{lstlisting} +pen outline = black+1mm; +\end{lstlisting} +定义一个 |pen|\index{pen@\lstinline=pen=} 类型的变量 |outline| 表示用来画羊头 +轮廓的画笔\index{画笔},以备使用。 + +然后,André 直接用 |..| 连结一组坐标来定义羊的头部轮廓: +\begin{lstlisting} +path head = (0.5,-0.2) .. (0.6,0.5) .. (0.2,1.3) .. (0,1.5) .. (0,1.5) + .. (0.4,1.3) .. (0.8,1.5) .. (2.2,1.9) .. (3,1.5) .. (3.2,1.3) + .. (3.6,0.5) .. (3.4,-0.3) .. (3,0) .. (2.2,0.4) .. (0.5,-0.2) .. cycle; +\end{lstlisting} +需要尖角的时候,就使用重复的相同点(如这里的起点);曲线变化大的地方,取的点 +也比较密集。 + +最后五官的绘制。眼睛是填充的小黑圆,鼻子是黑色的卵形,耳朵和嘴都是简单的曲线。 + +于是,只要把这样一个图形一个挨一个地重复画许多遍,就可以得到 André 想要的铺 +砌效果了。设计羊头形状的工作无疑是最关键也最复杂的,因此 André 的任务现在就 +已经完成了一半。 + +不过继承了法国完美主义风气的 André 老师,很快挑出了毛病:这只羊头部的轮廓, +并不完全是按照 \ref{sec:rect2tiling} 节对矩形变形得到的——他的手稿基本上是这 +样设计的,但在使用 \Asy{} 上绘图时则只是在手稿上相当随意地取了一些结点连结得 +到曲线,这个轮廓想必也并不能严丝合缝地一个个拼起来。还有一件很令他恼火的事情 +则是:要画出羊头的轮廓,他要画的点太多了,一个尖角用两个结点表示,也太不符合 +他的简洁美学了。因此,这个看上去相当不错的羊头一号,就被 André 老师无情地否 +决掉了。他决定发扬数学教师严谨简洁的作风,再做出更完美的羊头二号来。 + +\section{细致的曲线调整与曲线操作} + +\section{子图和循环} + +\section{路径剪裁} + +\endinput + +% vim:tw=77: + diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/xiantu-ancient.pdf b/Master/texmf-dist/doc/support/asymptote-by-example/src/xiantu-ancient.pdf Binary files differnew file mode 100644 index 00000000000..ba9153bb789 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/xiantu-ancient.pdf diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/xiantu.pdf b/Master/texmf-dist/doc/support/asymptote-by-example/src/xiantu.pdf Binary files differnew file mode 100644 index 00000000000..a01d3546e64 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/xiantu.pdf diff --git a/Master/texmf-dist/doc/support/asymptote-by-example/src/xiantu.tex b/Master/texmf-dist/doc/support/asymptote-by-example/src/xiantu.tex new file mode 100644 index 00000000000..568d7184f91 --- /dev/null +++ b/Master/texmf-dist/doc/support/asymptote-by-example/src/xiantu.tex @@ -0,0 +1,717 @@ +%# -*- coding: utf-8 -*- +% xiantu.tex +% asymptotebyexample 的一章,最基础的画图知识 + +\chapter{赵爽的弦图} +\label{chap:xiantu} +\nocite{quanjing} + +赵爽博士是位老知识分子,研究兴趣是天文历法与算学,一生精研《周髀算经》。不过 +赵老爷子年轻的时候书籍都是手写,最近才紧跟时代潮流用上了电脑。现在他要修订他 +研究《周髀算经》的札记,决定使用 \LaTeX{} 来排版。 + +现在他遇到一个难题,就是他要画出笔记中讲解勾股定理的一幅弦图。听人介绍,几经 +比较之后,他决定使用现在炒得火热的 \Asy{}。 + +赵博士的原图是手画的,线框多有不直不准的,\autoref{fig:xiantuancient} 就是旧 +年据手稿做的雕版图,赵博士并不满意。赵爽博士理想中的图,线条要平整美观,文字 +要清楚整齐,图形还要上色:朱实自然得用红色,黄实也该用黄色,以与注文一致—— +就是\autoref{fig:xiantu} 的样子。 + +\begin{figure} + \centering + \includegraphics[height=\textheight-2\baselineskip]{xiantu-ancient.pdf} + \caption{旧年做的雕版} + \label{fig:xiantuancient} +\end{figure} +\begin{figure} + \centering + \includegraphics{xiantu.pdf} + \caption{理想中的新版本} + \label{fig:xiantu} +\end{figure} + +计议已定,赵博士要开始正式的绘图了。 + +\section{绘图环境} + +\Asy{} 的安装并不复杂,在 Windows 下面就是下载运行那个安装包,在 Linux 下面一 +般也只需要下载对应的压缩包,解压就可以使用了。哦,赵博士用的就是 Windows。 + +点图标运行 \Asy{},就出现了交互式\index{交互式}的命令行,提示符是一个 +\verb=>=。输入命令: +\begin{lstlisting} +draw((0,0) -- (3cm,4cm)); // `\color{comment}一条直线` +\end{lstlisting} +赵博士装的 GSView 立即弹了出来,里面已经画出一条倾斜的直线。再输入 +|quit|\index{quit@\lstinline=quit=},程序退出,并留下了一个叫做 +\verb=out.eps= 的图形文件, +小菜一碟。 + +这里稍稍解释一下上面的一句代码。|draw|\index{draw@\lstinline=draw=} 是画线的 +命令,更准确地说,是 \Asy{} 中的函数\index{函数}:它带有一个参数\index{参数} +|(0,0) -- (3cm,4cm)|,参数外面是圆括号,整个命令以分号结束。里面的 +|(0,0) -- (3cm,4cm)| 是由两个坐标\index{坐标}连接而成的直线,坐标是在直角坐标 +系下的,可以带单位 |mm|, |cm|, |pt|, |bp|, |inch|, |inches|,% +\index{mm@\lstinline=mm=}\index{cm@\lstinline=cm=}\index{pt@\lstinline=pt=}% +\index{bp@\lstinline=bp=}\index{inch@\lstinline=inch=}% +\index{inches@\lstinline=inches=}% +其意义与在\TeX{} 中的一样,如果不带单位,则默认为 |bp|。行末以 |//| 开头的是 +注释,另有一种在 |/* */| 之间的注释\index{注释},与 C 语言相同。 + +\index{编译} +不过赵博士写书讲求胸有成竹方才下笔,因此他更愿意使用更一种方式:打开一个文本 +编辑器,把上面的绘图命令都录入完毕,保存为一个名为 \verb=line.asy= 的文件,最 +后把这个文件拖动到 \Asy{} 的图标上面,就完成了整个作图。 + +赵博士的小侄子不屑于这种快捷图标的编译方式,他直接进入命令行,输入 +\verb=asy=,就进入了 \Asy{} 的交互环境;要是输入 \verb=asy line=,就画出了刚 +才的保存的直线。 + + +\section{直线与绘图命令} +\label{sec:linedraw} + +弦图的图形其实很简单,都是直线、方块、三角形这些,而且为了计算的简便,所有长 +度也都是整数值。那么,首先就是在 \Asy{} 中来画直线。 + +\index{画线} +正如前面试验的时候做的那样,一条直线就是用 |--|\index{--@\lstinline=--=} 把坐 +标连起来,再使用 |draw| 命令,直线就画出来了。事实上,可以用 |--| 把坐标点连 +成折线: +\begin{lstlisting} +draw( (0,0) -- (1cm,0) -- (2cm,0.5cm) -- (1cm,1cm) -- (0,1cm) ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +draw( (0,0) -- (1cm,0) -- (2cm,0.5cm) -- (1cm,1cm) -- (0,1cm) ); +\end{asy} +\end{figure} + +像这样把坐标用 |--| 连结起来的,就成为一条路径\index{路径}。把直线而稍做修改 +,在后面连上一个特殊的坐标 |cycle|\index{cycle@\lstinline=cycle=},就可以得到 +一条首尾相接的闭路径\index{路径!闭路径}。如: +\begin{lstlisting} +draw( (0,0) -- (1cm,0) -- (2cm,0.5cm) -- (1cm,1cm) -- (0,1cm) -- cycle ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +draw( (0,0) -- (1cm,0) -- (2cm,0.5cm) -- (1cm,1cm) -- (0,1cm) -- cycle ); +\end{asy} +\end{figure} + +画一条路径可以使用不同的颜色、粗细的笔,这只要给 |draw| 命令多加一个画笔 +\index{画笔}参数(多个参数用逗号分开): +\begin{lstlisting} +draw((0,0) -- (1cm,0) -- (2cm,0.5cm) -- (1cm,1cm) -- (0,1cm), darkblue+1mm); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +draw((0,0) -- (1cm,0) -- (2cm,0.5cm) -- (1cm,1cm) -- (0,1cm), darkblue+1mm); +\end{asy} +\end{figure} +这里 |darkblue| 是颜色,|1mm| 是线的粗细。|darkblue+1mm| 即指一毫米宽的深 +蓝色粗线。(可用的颜色\index{颜色}名称可以参考 \cite{asyman}) + +赵博士画的是“勾三股四弦五”的红色三角形,这很容易: +\begin{lstlisting} +draw( (0,0) -- (4cm,0) -- (0,3cm) -- cycle, red+0.5mm ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +draw( (0,0) -- (4cm,0) -- (0,3cm) -- cycle, red+0.5mm ); +\end{asy} +\end{figure} + +\index{填充} +不过现在还需要的是实心的三角形,因此就需要一个新的绘图命令 +|fill|\index{fill@\lstinline=fill=},即填充。于是,红色三角形就成为 +\begin{lstlisting} +fill( (0,0) -- (4cm,0) -- (0,3cm) -- cycle, red ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +fill( (0,0) -- (4cm,0) -- (0,3cm) -- cycle, red ); +\end{asy} +\end{figure} + +但这样一来三角形的颜色就太重了,而且边界也不清楚。因此似乎应该先用浅红色填充 +一遍,然后再用深红色勾边。好在可以使用一个命令 +|filldraw|\index{filldraw@\lstinline=filldraw=} 同时完成这两件事情,这样就不 +需要把一条路径写两遍了。即有: +\begin{lstlisting} +filldraw((0,0) -- (4cm,0) -- (0,3cm) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +filldraw((0,0) -- (4cm,0) -- (0,3cm) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +\end{asy} +\end{figure} +这里可以简单地直接写两个参数 |palered, red+0.5mm|,不过为了清晰起见还是使用 +“$\text{键}=\text{值}$”的写法,明确表示出填充的画笔和描线的画笔。 + +现在,赵博士的整个弦图的框架就呼之欲出了,就是画出四个三角形 +(\autoref{fig:xiantuskeleton}): +\begin{lstlisting} +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +filldraw( (7cm,4cm) -- (4cm,4cm) -- (4cm,0) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +filldraw( (3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +filldraw( (0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +\end{lstlisting} +\begin{figure} +\centering +\begin{asy} +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +filldraw( (7cm,4cm) -- (4cm,4cm) -- (4cm,0) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +filldraw( (3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +filldraw( (0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle, + fillpen=palered, drawpen=red+0.5mm); +\end{asy} +\caption{弦图的初步框架}\label{fig:xiantuskeleton} +\end{figure} + +还应该画出弦图的中间的“黄实”,用黄色填充。这部分是一个正方形,可以使用现成 +的 \lstinline[mathescape]|box($\text{角点}$, $\text{角点}$)| +\index{box@\lstinline=box=} 命令来产生矩形的路径,因而填充正中间的正方形就可 +以用: +\begin{lstlisting} +fill( box((3cm,3cm), (4cm,4cm)), yellow ); +\end{lstlisting} +这个填充的命令应该放在画线之前(以免覆盖描的红线)。 + +回顾前面的代码,赵博士觉得连续地写四个 |filldraw| 命令太重复了。他读了 \Asy{} +的文档 \cite{asyman},才知道多条路径可以用符号 |^^|\index{^@\lstinline=^^=} +连起来,一起使用,于是立即着手改进原来的代码。 + +而且,由于还打算在图的后面画出参考网格,图形的颜色还应该设置为半透明\index{透 +明}的。好在这并不难实现,只要稍稍改动一下填充的画笔,使用 +\lstinline[mathescape]|opacity($\text{数值}$)| +\index{opacity@\lstinline=opacity=} +来设定有一定不透明度(取值为 $0\sim1$)的画笔,并把它加在原来的画笔上。于是赵 +博士最后写出了这样的代码: +\begin{lstlisting} +fill( box((3cm,3cm), (4cm,4cm)), opacity(0.5)+yellow ); +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle + ^^ (7cm,4cm) -- (4cm,4cm) -- (4cm,0) -- cycle + ^^ (3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle + ^^ (0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle, + fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); +\end{lstlisting} +至此,弦图的主要框架(\autoref{fig:xiantuskeleton2})就此完成。 +\begin{figure}[H] +\centering +\begin{asy} +fill( box((3cm,3cm), (4cm,4cm)), opacity(0.5)+yellow ); +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle + ^^ (7cm,4cm) -- (4cm,4cm) -- (4cm,0) -- cycle + ^^ (3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle + ^^ (0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle, + fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); +\end{asy} +\caption{弦图的进一步优化的框架}\label{fig:xiantuskeleton2} +\end{figure} + + +\section{图形变换与功能模块的使用} + +然后是画作为长度参考的网格。其实网格一开始就该在图中画出来,这样后面画图准确 +与否才能看得清楚。不过现在赵博士是重作旧图,图样已定,网格就搁在弦图的主要图 +形后面才画了。 + +按说这个网格是十分简单的,无非就是画一些灰色的纵横细线。比如这个 $3\times3$ +的网格: +\begin{lstlisting} +draw( (0,0) -- (3cm,0) + ^^ (0,1cm) -- (3cm,1cm) + ^^ (0,2cm) -- (3cm,2cm) + ^^ (0,3cm) -- (3cm,3cm), + gray ); +draw( (0,0) -- (0,3cm) + ^^ (1cm,0) -- (1cm,3cm) + ^^ (2cm,0) -- (2cm,3cm) + ^^ (3cm,0) -- (3cm,3cm), + gray ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +draw( (0,0) -- (3cm,0) + ^^ (0,1cm) -- (3cm,1cm) + ^^ (0,2cm) -- (3cm,2cm) + ^^ (0,3cm) -- (3cm,3cm), + gray ); +draw( (0,0) -- (0,3cm) + ^^ (1cm,0) -- (1cm,3cm) + ^^ (2cm,0) -- (2cm,3cm) + ^^ (3cm,0) -- (3cm,3cm), + gray ); +\end{asy} +\end{figure} + +可无疑这个办法显得太麻烦了,赵博士要画的是 $7\times7$ 的网格,就要分别画出 +$16$ 条直线。这样的代码不仅不好写,而且容易出错,修改一下也很麻烦。 + +赵博士看到了手册 \cite{asyman} 中讲循环语句的用法,似乎可以完成这件事。可是以 +赵博士的年龄,再去看什么编程什么变量的,命令不能一条一条执行下来,很不习惯, +头脑就往往转不清楚。 + +\index{模块!math@\prgname{math}} +于是赵博士就去论坛上咨询,一些人劝他去用几行循环语句,甚至有人已经把完整的函 +数做好了。但有一个结果特别引人注目,有人指出,在 \prgname{math} 模块中已经定 +义好了一个 |grid| 函数,只要拿来用就可以了。赵博士立即精神大振,来看这个 +|grid| 函数:\index{grid@\lstinline=grid=} +\begin{lstlisting} +picture grid(int Nx, int Ny, pen p=currentpen) +\end{lstlisting} +这个是在 \prgname{math} 模块中 |grid| 函数的原型。\index{原型}它说明 |grid| +函数有 |Nx|, |Ny| 两个整数类型的必需参数,一个可选的画笔,并且返回一个 +|picture|(图)\index{picture@\lstinline=picture=}类型的对象。 + +\index{导入}\index{模块!导入} +要使用模块的功能,需要在绘图之前导入这个模块,这只要使用 +\index{import@\lstinline=import=} +\begin{lstlisting} +import `模块名`; +\end{lstlisting} +因此,要使用 \prgname{math} 模块中的 |grid| 函数,只要在代码中写 +\begin{lstlisting} +import math; +\end{lstlisting} +就可以了。 + +|grid| 函数的行为看起来很奇怪,调用它会在一个单独的图上画出一个 +|Nx|${}\times{}$|Ny| 的网格,网格的左下角在原点,间距为 $1$。要使用 |grid| 函 +数画的图形,要使用 \lstinline[mathescape]|add($\text{图}$)| +\index{add@\lstinline=add=} 命令,把这个图形加在当前的图上: +\begin{lstlisting} +import math; +add(grid(10,10,gray)); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +import math; +add(grid(10,10,gray)); +\end{asy} +\end{figure} +不过直接这样做的结果是只能得到一个小得已经看不清的网格。因此,必须对图形进行放缩。 + +\index{变换}\index{仿射变换} +\index{变换!平移}\index{变换!旋转}\index{变换!放缩} +\index{变换!错切}\index{变换!反射} +\Asy{} 提供了平移、旋转、放缩、倾斜、反射等各种的仿射变换,来对坐标、路径、图 +形等元素进行变换(严格的函数原型参考 \cite{asyman}): +\index{shift@\lstinline=shift=} +\index{scale@\lstinline=scale=} +\index{xscale@\lstinline=xscale=} +\index{yscale@\lstinline=yscale=} +\index{rotate@\lstinline=rotate=} +\index{slant@\lstinline=slant=} +\index{reflect@\lstinline=reflect=} +\begin{lstlisting} +shift(`坐标`) // `\color{comment}按坐标平移` +shift(x, y) // `\color{comment}按` (x, y) `\color{comment}平移` +scale(`倍数`) // `\color{comment}按倍数放缩` +xscale(`倍数`) // `\color{comment}$x$ 轴方向按倍数放缩` +yscale(`倍数`) // `\color{comment}$y$ 轴方向按倍数放缩` +scale(x, y) // `\color{comment}在 $x$ 轴、$y$ 轴方向分别按倍数` x, y `\color{comment}放缩` +rotate(`角度`, z=(0,0)) // `\color{comment}按角度绕中心` z`\color{comment}(默认为原点,逆时针)旋转` +slant(`因子`) // `\color{comment}按一定因子向右倾斜` +reflect(a, b) // `\color{comment}相对直线` a--b `\color{comment}反射` +\end{lstlisting} +使用一个变换就是把这个变换乘在被变换对象的左边。例如一个放缩一个单位正方形: +\begin{lstlisting} +draw( scale(2cm) * box((0,0), (1,1)) ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +draw( scale(2cm) * box((0,0), (1,1)) ); +\end{asy} +\end{figure} +这样的变换可以连续地做下去,例如 +\begin{lstlisting} +draw( rotate(90) * slant(0.3) * scale(1cm) * box((0,0), (1,1)) ); +\end{lstlisting} +就是把一个单位正方形先放大,再倾斜,再旋转 $90^\circ$: +\begin{figure}[H] +\centering +\begin{asy} +draw( rotate(90) * slant(0.3) * scale(1cm) * box((0,0), (1,1)) ); +\end{asy} +\end{figure} + +有了这些变换,画出一个合适大小的网格就不再是什么难事了: +\begin{lstlisting} +import math; +add( scale(5mm) * grid(4, 4, gray) ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +import math; +add( scale(5mm) * grid(4, 4, gray) ); +\end{asy} +\end{figure} + +赵博士的弦图有两个网格,不仅要大小合适,而且其中一个需要进行旋转和平移。平移 +的位置很明显,但旋转仍然需要一些计算。当然这难不倒精研天文算学多年的赵博士, +这里弦实($5\times5$ 的正方形)可以看作是顺时针旋转得到的,从朱实的三角形容易 +看出旋转的角度正好是 $\arctan(3/4)$。\Asy{} 中也可以方便地调用返回角度的反三 +角函数 |aTan|\index{aTan@\lstinline=aTan=} 来计算这个角度。更详细的数学函数列 +表,参看 \cite{asyman}。 + +于是,赵博士弦图中的网格,就可以这样方便地画出来了 +(\autoref{fig:xiantugrid}): +\begin{lstlisting} +// `\color{comment}网格` +import math; +add( scale(1cm) * grid(7, 7, gray) ); +add( shift(0,3cm) * rotate(-aTan(3/4)) * scale(1cm) * grid(5, 5, gray) ); +// `\color{comment}弦图主体` +fill( box((3cm,3cm), (4cm,4cm)), opacity(0.5)+yellow ); +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle + ^^ (7cm,4cm) -- (4cm,4cm) -- (4cm,0) -- cycle + ^^ (3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle + ^^ (0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle, + fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); +\end{lstlisting} +\begin{figure}[htbp] +\centering +\begin{asy} +// 网格 +import math; +add( scale(1cm) * grid(7, 7, gray) ); +add( shift(0,3cm) * rotate(-aTan(3/4)) * scale(1cm) * grid(5, 5, gray) ); +// 弦图主体 +fill( box((3cm,3cm), (4cm,4cm)), opacity(0.5)+yellow ); +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle + ^^ (7cm,4cm) -- (4cm,4cm) -- (4cm,0) -- cycle + ^^ (3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle + ^^ (0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle, + fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); +\end{asy} +\caption{带网格的弦图草图} +\label{fig:xiantugrid} +\end{figure} + + +\section{标注文字} + +\index{标注}\index{标签} +现在要进行的是文字的标注。按照勾股定理的约定,赵博士打算在一个红色三角形内标 +注“朱实”,在黄色矩形处标注“黄实”,并为拼得的整个大矩形标注“弦实”;在另 +一红色三角形的三边标注“勾三”、“股四”、“弦五”的尺寸;最后在图形两侧加上 +说明的文字。 + +在标注文字之前,对于中文标签\index{标签!中文标签},应该先定义好中文环境和字体 +。\Asy{} 会调用 \LaTeX{} 来进行标签的处理,因而需要设置的就是 \LaTeX{} 的编译 +引擎\index{LaTeX@\LaTeX!引擎}与一般的中文 \LaTeX{} 文件导言区。在这里,赵博士决定使 +用 \XeTeX{}\index{XeTeX@\XeTeX} 引擎与 +\prgname{xeCJK}\index{xeCJK@\prgname{xeCJK}} 宏包来处理中文。为此,在 \Asy{} +源文件中,他使用了下面的设置代码: +\begin{lstlisting} +settings.tex = "xelatex"; +usepackage("xeCJK"); +texpreamble("\setCJKmainfont{SimSun}"); +\end{lstlisting} +这里第一行是设置编译时所用的 \TeX{} 引擎。后面 +|usepackage|\index{usepackage@\lstinline=usepackage=} 命令就是 \LaTeX{} 中的 +\texcode|\usepackage| 命令的一个包装形式,里面的字符串参数就是宏包名;而 +|texpreamble|\index{texpreamble@\lstinline=texpreamble=} 命令则把接收的参数直 +接放进 \LaTeX{} 的导言区。 + +进行上述设置后,就可以正确使用中文标签了。标注的命令很简单,就是 +|label|\index{label@\lstinline=label=},参数正是标签文字和标签的位置。例如: +\begin{lstlisting} +draw( (0,0) -- (1cm,1cm) -- (2cm,0) ); +label( "`\color{string}中间`", (1cm,0cm) ); +\end{lstlisting} +就得到 +\begin{figure}[H] +\centering +\begin{asy} +settings.tex = "xelatex"; +usepackage("xeCJK"); +texpreamble("\setCJKmainfont{SimSun}"); +draw( (0,0) -- (1cm,1cm) -- (2cm,0) ); +label( "中间", (1cm,0cm) ); +\end{asy} +\end{figure} + +可以在标签中使用任意的 \LaTeX{} 代码,包括数学公式,例如: +\begin{lstlisting} +label("$x = \sin\alpha$", (0,0)); +\end{lstlisting} +就会正确地得到 $x = \sin\alpha$ 的标签。 + +现在,我们可以给弦图加上“朱实”、“黄实”和“弦实”的标签了。在前面的框架代 +码后面加上 +\begin{lstlisting} +label("`\color{string}朱实`", (2cm,4cm)); +label("`\color{string}黄实`", (3.5cm,3.5cm)); +label("`\color{string}弦实`", (5cm,4cm)); +\end{lstlisting} +以及设置字体的代码,就得到\autoref{fig:xiantupartlabel} 的结果。 +\begin{figure} +\centering +\begin{asy} +settings.tex = "xelatex"; +usepackage("xeCJK"); +texpreamble("\setCJKmainfont{SimSun}"); +import math; +add( scale(1cm) * grid(7, 7, gray) ); +add( shift(0,3cm) * rotate(-aTan(3/4)) * scale(1cm) * grid(5, 5, gray) ); +fill( box((3cm,3cm), (4cm,4cm)), opacity(0.5)+yellow ); +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle + ^^ (7cm,4cm) -- (4cm,4cm) -- (4cm,0) -- cycle + ^^ (3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle + ^^ (0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle, + fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); +label("朱实", (2cm,4cm)); +label("黄实", (3.5cm,3.5cm)); +label("弦实", (5cm,4cm)); +\end{asy} +\caption{带部分标注的弦图}\label{fig:xiantupartlabel} +\end{figure} + +下面则是要给三角形的三边进行标注。 + +\index{标签!路径上的标签} +与前面在一个点处标注不同,这里实际是给一条路径(直线)标注标签。因此,想要得 +到的是距离这条路径的中点一定方向距离加一个标签,而不是简单地取路径上的一点作 +为标签的位置。好在 \Asy{} 确实也提供了这样的功能,仍然使用 |label| 命令,基本 +语法是:\index{label@\lstinline=label=} +\begin{lstlisting} +label(`标签`, `路径`) +\end{lstlisting} +这里默认会在路径中间的右侧(沿着路径行进方向)加标签。例如: +\begin{lstlisting} +draw( (0,0) -- (4cm,2cm), linewidth(0.5mm) ); +label("粗线条", (0,0) -- (4cm,2cm)); +\end{lstlisting} +(其中的 |linewidth|\index{linewidth@\lstinline=linewidth=} 函数用来表示具有 +一定线宽\index{线宽}的画笔)这段代码将得到 +\begin{figure}[H] +\centering +\begin{asy} +settings.tex = "xelatex"; +usepackage("xeCJK"); +texpreamble("\setCJKmainfont{SimSun}"); +draw( (0,0) -- (4cm,2cm), linewidth(0.5mm) ); +label("粗线条", (0,0) -- (4cm,2cm)); +\end{asy} +\end{figure} + +现在,赵博士就可以给三角形的三边加上“勾三”、“股四”、“弦五”的标签了,只 +要稍稍注意一下标签摆放的默认方向: +\begin{lstlisting} +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle, + fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); +label( "勾三", (4cm,3cm) -- (4cm,0) ); +label( "股四", (0,3cm) -- (4cm,3cm) ); +label( "弦五", (4cm,0) -- (0,3cm) ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +settings.tex = "xelatex"; +usepackage("xeCJK"); +texpreamble("\setCJKmainfont{SimSun}"); +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle, + fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); +label( "勾三", (4cm,3cm) -- (4cm,0) ); +label( "股四", (0,3cm) -- (4cm,3cm) ); +label( "弦五", (4cm,0) -- (0,3cm) ); +\end{asy} +\end{figure} + +不过,为了得到正确的标签位置,不得不把原来逆时针画的线用顺时针方向重写,这多 +少让赵博士有些恼火:为什么不能在路径的左边标注标签呢?确实可以,很简单,只要 +给 |label| 命令再加上 |align=LeftSide|\index{align@\lstinline=align=} +\index{LeftSide@\lstinline=LeftSide=} 选项(或者简单地只用 |LeftSide|)就指定 +了在左边放置对齐。同理,还有向右对齐的 +|RightSide|\index{RightSide@\lstinline=RightSide=},在中间对齐的 +|Center|\index{Center@\lstinline=Center=} 以及一般意义的相对方向 +\lstinline[mathescape]|Relative($\text{方向}$)|。% +\index{Relative@\lstinline=Relative=}% +例如: +\begin{lstlisting} +draw( (0,0) -- (4cm,2cm), blue, Arrow ); +label( "LeftSide", (0,0) -- (4cm,2cm), align=LeftSide ); +label( "RightSide", (0,0) -- (4cm,2cm), align=RightSide ); +label( "Center", (0,0) -- (4cm,2cm), align=Center ); + +draw( (6cm,0)--(8cm,2cm), blue, Arrow ); +label( "E", (6cm,0)--(8cm,2cm), Relative(E) ); +label( "S", (6cm,0)--(8cm,2cm), Relative(S) ); +label( "W", (6cm,0)--(8cm,2cm), Relative(W) ); +label( "N", (6cm,0)--(8cm,2cm), Relative(N) ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +draw( (0,0) -- (4cm,2cm), blue, Arrow ); +label( "LeftSide", (0,0) -- (4cm,2cm), align=LeftSide ); +label( "RightSide", (0,0) -- (4cm,2cm), align=RightSide ); +label( "Center", (0,0) -- (4cm,2cm), align=Center ); + +draw( (6cm,0)--(8cm,2cm), blue, Arrow ); +label( "E", (6cm,0)--(8cm,2cm), Relative(E) ); +label( "S", (6cm,0)--(8cm,2cm), Relative(S) ); +label( "W", (6cm,0)--(8cm,2cm), Relative(W) ); +label( "N", (6cm,0)--(8cm,2cm), Relative(N) ); +\end{asy} +\end{figure} +|E|, |S|, |W|, |N|\index{E@\lstinline=E=}\index{S@\lstinline=S=} +\index{W@\lstinline=W=}\index{N@\lstinline=N=} 分别是东南西北四个罗盘方向,% +\index{罗盘方向}用在 |Relative| 函数里面就表示相对于路径方向的四个方向。为明 +确,这里用 |Arrow|\index{Arrow@\lstinline=Arrow=} 选项在画线时加了箭头。 +\index{箭头} + +不过,这样的标签还是不能令赵博士满意。赵博士给三角形加标签,还希望标签随着三 +角形的边作旋转,使标签沿着边排列。为此,赵博士不得不又仔细查看了 +\cite{asyman},在讲标注文字一节(label)他找到了一个构造标签的更高级的办法, +即不仅仅是使用一个简单的字符串,而是使用\index{Label@\lstinline=Label=} +\begin{lstlisting} +Label(`标签`) +\end{lstlisting} +函数进行构造。里面的“标签”参数仍然可以是原来的字符串,或是通过这个函数构造 +出来的高级的标签。这个函数可以带许多可选的其他参数,如 +\lstinline[mathescape]|position=$\text{位置}$| +\index{position@\lstinline=position=} 的参数就可以指定标签放在路径中点之外的 +其他地方;而 \lstinline[mathescape]|embed=$\text{嵌入变换方式}$| +\index{embed@\lstinline=embed=} 的参数则可以解决标签自动旋转的问题。 + +这里暂且放下 |position| 参数。只来看 |embed| 参数的一个特例:% +\lstinline[mathescape]|Rotate($\text{方向}$)|% +\index{Rotate@\lstinline=Rotate=}。这个参数会让标签向着给定的方向旋转,如: +\begin{lstlisting} +draw( (0,0)--(4cm,2cm), blue, Arrow ); +label( Label("Rotate", Rotate((4,2))), + (0,0)--(4cm,2cm) ); +\end{lstlisting} +\begin{figure}[H] +\centering +\begin{asy} +draw( (0,0)--(4cm,2cm), blue, Arrow ); +label( Label("Rotate", Rotate((4,2))), + (0,0)--(4cm,2cm) ); +\end{asy} +\end{figure} +这里坐标 $(4,2)$ 正是这条直线的绘制方向。 + +终于,使用了上面的全部功能,赵博士完成了全部的图形标注工作 +(\autoref{fig:xiantulabel}): +\begin{lstlisting} +settings.tex = "xelatex"; +usepackage("xeCJK"); +texpreamble("\setCJKmainfont{SimSun}"); + +import math; +add( scale(1cm) * grid(7, 7, gray) ); +add( shift(0,3cm) * rotate(-aTan(3/4)) * scale(1cm) * grid(5, 5, gray) ); + +fill( box((3cm,3cm), (4cm,4cm)), opacity(0.5)+yellow ); +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle + ^^ (7cm,4cm) -- (4cm,4cm) -- (4cm,0) -- cycle + ^^ (3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle + ^^ (0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle, + fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); + +label("朱实", (2cm,4cm)); +label("黄实", (3.5cm,3.5cm)); +label("弦实", (5cm,4cm)); +label( Label("勾三",Rotate(S)), (4cm,0)--(4cm,3cm), LeftSide ); +label( Label("股四",Rotate(E)), (4cm,3cm)--(0,3cm), LeftSide ); +label( Label("弦五",Rotate((4,-3))), (0,3cm)--(4cm,0), LeftSide ); +\end{lstlisting} +\begin{figure}[htbp] +\centering +\begin{asy} +settings.tex = "xelatex"; +usepackage("xeCJK"); +texpreamble("\setCJKmainfont{SimSun}"); + +import math; +add( scale(1cm) * grid(7, 7, gray) ); +add( shift(0,3cm) * rotate(-aTan(3/4)) * scale(1cm) * grid(5, 5, gray) ); + +fill( box((3cm,3cm), (4cm,4cm)), opacity(0.5)+yellow ); +filldraw( (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle + ^^ (7cm,4cm) -- (4cm,4cm) -- (4cm,0) -- cycle + ^^ (3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle + ^^ (0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle, + fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); + +label("朱实", (2cm,4cm)); +label("黄实", (3.5cm,3.5cm)); +label("弦实", (5cm,4cm)); +label( Label("勾三",Rotate(S)), (4cm,0)--(4cm,3cm), LeftSide ); +label( Label("股四",Rotate(E)), (4cm,3cm)--(0,3cm), LeftSide ); +label( Label("弦五",Rotate((4,-3))), (0,3cm)--(4cm,0), LeftSide ); +\end{asy} +\caption{带标注的完整弦图} +\label{fig:xiantulabel} +\end{figure} + + +\section*{习题} + +\begin{enumerate} + \item 查阅参考手册 \cite{asyman},看看都有哪些颜色可用。看看你的系统中安装 + 了哪些中文字体。然后修改\autoref{fig:xiantulabel},使用另一种你喜欢的字体 + 进行标注;并且将“朱实”、“黄实”和“弦实”分别用红、黄、橙色标注。 + + \item 查阅参考手册 \cite{asyman},看看 |draw|、|fill|、|label| 等命令都可以 + 带哪些可选的参数,并自己举例子试验一下效果。 + + \item 代码 +\begin{lstlisting} +path zhushi = (4cm,0) -- (4cm,3cm) -- (0,3cm) -- cycle; +\end{lstlisting} + 可以把一个三角形的路径保存在变量 |zhushi| 中,以后就可以使用 + |draw(zhushi)| 这样的命令对此路径进行操作了\footnote{关于变量定义和使用的 + 详细内容,参考后面的章节或手册 \cite{asyman}。}。 + + 考虑如何利用平移和旋转变换,只定义一个三角形的路径,就把弦图中的四个红色 + 三角形都画出来。 + + \item 查阅手册 \cite{asyman} 和 \Asy{} 自带的例子,研究模块 + \prgname{roundedpath} 的用法。并利用它尝试画出下面的图形: +\begin{figure}[H] +\centering +\begin{asy} +import roundedpath; +pen thick = linewidth(0.8pt); +path p = (0,0) -- (0,2cm) -- (1cm,3.25cm) -- (2cm,2cm) -- (2cm,0) + -- (0,2cm) -- (2cm, 2cm) -- (0,0) -- (2cm,0); +draw(roundedpath(p, 8pt), thick); +\end{asy} +\end{figure} + + 看看 \Asy{} 中还有什么用法简单而又有趣的模块。 + + \item (较难)研究在 \LaTeX{} 里中文直排的方法,尽量精确地复现出赵博士理想 + 中的弦图效果(\autoref{fig:xiantu})。 +\end{enumerate} + +\endinput + +% vim:tw=77: + |