File:Transformation example in MetaPost.svg
Summary
| Description |
Русский: Пример использования линейных преобразований в MetaPost. Сначала создаётся простой рисунок, затем он масштабируется и наклоняется для имитации трёхмерии.
Исходный код для создания SVG-рисунка: |
| Date | |
| Source | Own work |
| Author | Evgeny Baldin |
| SVG development | |
| Source code | PostScript codedefaultfont := "cmr12";
defaultscale := 12pt /fontsize defaultfont;
prologues := 3;
outputformat := "svg";
%пример использования slanted
beginfig(1) ;
numeric u;
u = 0.8mm;
cutdraw (0u,0u)--(20u,0u)--(20u,30u){dir 90}..
{dir -90}(17u,30u)--(17u,3u)--(0u,3u)
withpen pencircle scaled 0.5u;
drawdblarrow (23u,10u)--(23u,1u);
label.rt("h",1/2[(23u,10u),(23u,1u)]);
drawdblarrow (30u,30u)--(30u,1u);
label.lft("H",1/2[(30u,30u),(30u,1u)]);
picture Base;
Base:=currentpicture;
clearit;
fill (15u,0u)--(20u,0u)--(20u,20u)--(17u,20u)--(17u,3u)--(15u,3u)--cycle
withcolor 0.7white;
draw Base;
draw ((12u,20u)--(20u,20u));
draw ((12u,10u)--(20u,10u));
drawdblarrow ((14u,20u)--(14u,10u));
label.lft("d",(14u,16u));
picture Slant;
Slant=currentpicture;
clearit;
fill (5u,0u)--(20u,0u)--(20u,10u)--(17u,10u)--(17u,3u)--(5u,3u)--cycle
withcolor 0.7white;
draw Base;
% Собственно говоря, приер линейных преобразований здесь.
draw Slant yscaled 2/3 slanted 1/2 shifted (40u,0u);
endfig;
Affine transformations example usage in MetaPost codedefaultfont := "cmr12";
defaultscale := 12pt /fontsize defaultfont;
prologues := 3;
outputformat := "svg";
beginfig(1) ;
numeric u;
u = 0.8mm;
cutdraw (0u,0u)--(20u,0u)--(20u,30u){dir 90}..
{dir -90}(17u,30u)--(17u,3u)--(0u,3u)
withpen pencircle scaled 0.5u;
drawdblarrow (23u,10u)--(23u,1u);
label.rt("h",1/2[(23u,10u),(23u,1u)]);
drawdblarrow (30u,30u)--(30u,1u);
label.lft("H",1/2[(30u,30u),(30u,1u)]);
picture Base;
Base:=currentpicture;
clearit;
fill (15u,0u)--(20u,0u)--(20u,20u)--(17u,20u)--(17u,3u)--(15u,3u)--cycle
withcolor 0.7white;
draw Base;
draw ((12u,20u)--(20u,20u));
draw ((12u,10u)--(20u,10u));
drawdblarrow ((14u,20u)--(14u,10u));
label.lft("d",(14u,16u));
picture Slant;
Slant=currentpicture;
clearit;
fill (5u,0u)--(20u,0u)--(20u,10u)--(17u,10u)--(17u,3u)--(5u,3u)--cycle
withcolor 0.7white;
draw Base;
% here it is transformation example
draw Slant yscaled 2/3 slanted 1/2 shifted (40u,0u);
endfig ;
|
Licensing
I, the copyright holder of this work, hereby publish it under the following licenses:
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
| Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License. |
You may select the license of your choice.