Source

cappuccino-docs / cappuccino docs / cappuccino.org / learn / documentation / _c_g_affine_transform_8j_source.html

Full commit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!-- Mirrored from cappuccino.org/learn/documentation/_c_g_affine_transform_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:42 GMT -->
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Cappuccino API: AppKit/CoreGraphics/CGAffineTransform.j Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>AppKit/CoreGraphics/CGAffineTransform.j</h1><a href="_c_g_affine_transform_8j.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * CGAffineTransform.j</span>
<a name="l00003"></a>00003 <span class="comment"> * AppKit</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Created by Francisco Tolmasky.</span>
<a name="l00006"></a>00006 <span class="comment"> * Copyright 2008, 280 North, Inc.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
<a name="l00009"></a>00009 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
<a name="l00010"></a>00010 <span class="comment"> * License as published by the Free Software Foundation; either</span>
<a name="l00011"></a>00011 <span class="comment"> * version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
<a name="l00016"></a>00016 <span class="comment"> * Lesser General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
<a name="l00019"></a>00019 <span class="comment"> * License along with this library; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="_c_g_geometry_8h.html">CGGeometry.h</a>&quot;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="_c_g_affine_transform_8h.html">CGAffineTransform.h</a>&quot;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#define _function(inline) function inline { return _##inline; }</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span>
<a name="l00028"></a>00028 @<span class="keyword">import</span> <span class="stringliteral">&quot;CGGeometry.j&quot;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 
<a name="l00031"></a><a class="code" href="_c_g_affine_transform_8j.html#a80ac67b0044fbb2cf3c9d5f47298986f">00031</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#a80ac67b0044fbb2cf3c9d5f47298986f">CGAffineTransformMake</a>(a, b, c, d, tx, ty))
<a name="l00032"></a><a class="code" href="_c_g_affine_transform_8j.html#a072cf7a76d169af4182cf37674381d04">00032</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#a072cf7a76d169af4182cf37674381d04">CGAffineTransformMakeIdentity</a>())
<a name="l00033"></a><a class="code" href="_c_g_affine_transform_8j.html#a4f908246abad43458ed79e2003f26505">00033</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#a4f908246abad43458ed79e2003f26505">CGAffineTransformMakeCopy</a>(anAffineTransform))
<a name="l00034"></a>00034 
<a name="l00035"></a><a class="code" href="_c_g_affine_transform_8j.html#a613dd61d0401317ab39a35ac0c431d23">00035</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#a613dd61d0401317ab39a35ac0c431d23">CGAffineTransformMakeScale</a>(sx, sy))
<a name="l00036"></a><a class="code" href="_c_g_affine_transform_8j.html#af409e88c81cd51e67ad1b9c36ac8a3a1">00036</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#af409e88c81cd51e67ad1b9c36ac8a3a1">CGAffineTransformMakeTranslation</a>(tx, ty))
<a name="l00037"></a><a class="code" href="_c_g_affine_transform_8j.html#aabc191bccf01f696ad71380b39fcec64">00037</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#aabc191bccf01f696ad71380b39fcec64">CGAffineTransformTranslate</a>(aTransform, tx, ty))
<a name="l00038"></a><a class="code" href="_c_g_affine_transform_8j.html#a995d6ae50fed55662512762af1311b00">00038</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#a995d6ae50fed55662512762af1311b00">CGAffineTransformScale</a>(aTransform, sx, sy))
<a name="l00039"></a>00039 
<a name="l00040"></a><a class="code" href="_c_g_affine_transform_8j.html#af365049e43d927195c26bd0352a1116f">00040</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#af365049e43d927195c26bd0352a1116f">CGAffineTransformConcat</a>(lhs, rhs))
<a name="l00041"></a><a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">00041</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">CGPointApplyAffineTransform</a>(aPoint, aTransform))
<a name="l00042"></a><a class="code" href="_c_g_affine_transform_8j.html#a6dd16c2d67bd72ecf53ddd040a81e367">00042</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#a6dd16c2d67bd72ecf53ddd040a81e367">CGSizeApplyAffineTransform</a>(aSize, aTransform))
<a name="l00043"></a>00043 
<a name="l00044"></a><a class="code" href="_c_g_affine_transform_8j.html#afe7f88803109c83bff67ce0249bf3550">00044</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#afe7f88803109c83bff67ce0249bf3550">CGAffineTransformIsIdentity</a>(aTransform))
<a name="l00045"></a><a class="code" href="_c_g_affine_transform_8j.html#a13fc4eb44a96f08f758b22b47be24224">00045</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#a13fc4eb44a96f08f758b22b47be24224">CGAffineTransformEqualToTransform</a>(lhs, rhs))
<a name="l00046"></a>00046 
<a name="l00047"></a><a class="code" href="_c_g_affine_transform_8j.html#a73aeb748a264076f9a332a2e67330749">00047</a> _function(<a class="code" href="_c_g_affine_transform_8j.html#a73aeb748a264076f9a332a2e67330749">CGStringCreateWithCGAffineTransform</a>(aTransform))
<a name="l00048"></a>00048 
<a name="l00049"></a>00049 <span class="comment">/*</span>
<a name="l00050"></a>00050 <span class="comment">    FIXME: !!!!</span>
<a name="l00051"></a>00051 <span class="comment">    @return void</span>
<a name="l00052"></a>00052 <span class="comment">    @group CGAffineTransform</span>
<a name="l00053"></a>00053 <span class="comment">*/</span>
<a name="l00054"></a><a class="code" href="_c_g_affine_transform_8j.html#a399809ab2a88b23c3709e36a473f3860">00054</a> function <a class="code" href="_c_g_affine_transform_8j.html#a399809ab2a88b23c3709e36a473f3860">CGAffineTransformCreateCopy</a>(aTransform)
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056     <span class="keywordflow">return</span> _CGAffineTransformMakeCopy(aTransform);
<a name="l00057"></a>00057 }
<a name="l00058"></a>00058 
<a name="l00067"></a><a class="code" href="_c_g_affine_transform_8j.html#ad2a46b999df28a4cabc4fd59c5a083a9">00067</a> function <a class="code" href="_c_g_affine_transform_8j.html#ad2a46b999df28a4cabc4fd59c5a083a9">CGAffineTransformMakeRotation</a>(anAngle)
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069     var sin = SIN(anAngle),
<a name="l00070"></a>00070         cos = COS(anAngle);
<a name="l00071"></a>00071         
<a name="l00072"></a>00072     <span class="keywordflow">return</span> _CGAffineTransformMake(cos, sin, -sin, cos, 0.0, 0.0);
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 
<a name="l00082"></a><a class="code" href="_c_g_affine_transform_8j.html#a49a88e45ec9dfbb6761a0c25c5fda7b7">00082</a> function <a class="code" href="_c_g_affine_transform_8j.html#a49a88e45ec9dfbb6761a0c25c5fda7b7">CGAffineTransformRotate</a>(aTransform, anAngle)
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084     var sin = SIN(anAngle),
<a name="l00085"></a>00085         cos = COS(anAngle);
<a name="l00086"></a>00086 
<a name="l00087"></a>00087     <span class="keywordflow">return</span> {
<a name="l00088"></a>00088             a:aTransform.a * cos + aTransform.c * sin,
<a name="l00089"></a>00089             b:aTransform.b * cos + aTransform.d * sin,
<a name="l00090"></a>00090             c:aTransform.c * cos - aTransform.a * sin,
<a name="l00091"></a>00091             d:aTransform.d * cos - aTransform.b * sin,
<a name="l00092"></a>00092             tx:aTransform.tx,
<a name="l00093"></a>00093             ty:aTransform.ty
<a name="l00094"></a>00094         };
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 
<a name="l00103"></a><a class="code" href="_c_g_affine_transform_8j.html#a7fbeeee49fbad301876a71a146f7995a">00103</a> function <a class="code" href="_c_g_affine_transform_8j.html#a7fbeeee49fbad301876a71a146f7995a">CGAffineTransformInvert</a>(aTransform)
<a name="l00104"></a>00104 {
<a name="l00105"></a>00105     var determinant = 1 / (aTransform.a * aTransform.d - aTransform.b * aTransform.c);
<a name="l00106"></a>00106 
<a name="l00107"></a>00107     <span class="keywordflow">return</span> {
<a name="l00108"></a>00108         a:determinant * aTransform.d,
<a name="l00109"></a>00109         b:-determinant * aTransform.b,
<a name="l00110"></a>00110         c:-determinant * aTransform.c,
<a name="l00111"></a>00111         d:determinant * aTransform.a,
<a name="l00112"></a>00112         tx:determinant * (aTransform.c * aTransform.ty - aTransform.d * aTransform.tx),
<a name="l00113"></a>00113         ty:determinant * (aTransform.b * aTransform.tx - aTransform.a * aTransform.ty)
<a name="l00114"></a>00114     };
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116 
<a name="l00125"></a><a class="code" href="_c_g_affine_transform_8j.html#aa2cac55239f169c578848a871f67fcb2">00125</a> function <a class="code" href="_c_g_affine_transform_8j.html#aa2cac55239f169c578848a871f67fcb2">CGRectApplyAffineTransform</a>(aRect, anAffineTransform)
<a name="l00126"></a>00126 {
<a name="l00127"></a>00127     var top = _CGRectGetMinY(aRect),
<a name="l00128"></a>00128         left = _CGRectGetMinX(aRect),
<a name="l00129"></a>00129         right = _CGRectGetMaxX(aRect),
<a name="l00130"></a>00130         bottom = _CGRectGetMaxY(aRect),
<a name="l00131"></a>00131         topLeft = <a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">CGPointApplyAffineTransform</a>(_CGPointMake(left, top), anAffineTransform),
<a name="l00132"></a>00132         topRight = <a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">CGPointApplyAffineTransform</a>(_CGPointMake(right, top), anAffineTransform),
<a name="l00133"></a>00133         bottomLeft = <a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">CGPointApplyAffineTransform</a>(_CGPointMake(left, bottom), anAffineTransform),
<a name="l00134"></a>00134         bottomRight = <a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">CGPointApplyAffineTransform</a>(_CGPointMake(right, bottom), anAffineTransform),
<a name="l00135"></a>00135         minX = <a class="code" href="_c_p_obj_j_runtime_8j.html#a4fca277171215842609dc38a6f0c19fb">MIN</a>(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x),
<a name="l00136"></a>00136         maxX = <a class="code" href="_c_p_obj_j_runtime_8j.html#a45f5f88d061da0c18bcb6b6a854fe898">MAX</a>(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x),
<a name="l00137"></a>00137         minY = <a class="code" href="_c_p_obj_j_runtime_8j.html#a4fca277171215842609dc38a6f0c19fb">MIN</a>(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y),
<a name="l00138"></a>00138         maxY = <a class="code" href="_c_p_obj_j_runtime_8j.html#a45f5f88d061da0c18bcb6b6a854fe898">MAX</a>(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
<a name="l00139"></a>00139         
<a name="l00140"></a>00140     <span class="keywordflow">return</span> _CGRectMake(minX, minY, (maxX - minX), (maxY - minY));
<a name="l00141"></a>00141 }
<a name="l00142"></a>00142 
<a name="l00149"></a><a class="code" href="_c_g_affine_transform_8j.html#ab073ac1dea17b0d2fcaf32b7cd3a26c8">00149</a> function <a class="code" href="_c_g_affine_transform_8j.html#ab073ac1dea17b0d2fcaf32b7cd3a26c8">CPStringFromCGAffineTransform</a>(anAffineTransform)
<a name="l00150"></a>00150 {
<a name="l00151"></a>00151     <span class="keywordflow">return</span> <span class="charliteral">&apos;{&apos;</span> + anAffineTransform.a + <span class="stringliteral">&quot;, &quot;</span> + anAffineTransform.b + <span class="stringliteral">&quot;, &quot;</span> + anAffineTransform.c + <span class="stringliteral">&quot;, &quot;</span> + anAffineTransform.d + <span class="stringliteral">&quot;, &quot;</span> + anAffineTransform.tx + <span class="stringliteral">&quot;, &quot;</span> + anAffineTransform.ty + <span class="charliteral">&apos;}&apos;</span>;
<a name="l00152"></a>00152 }
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Tue Apr 6 10:32:54 2010 for Cappuccino API by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>

<!-- Mirrored from cappuccino.org/learn/documentation/_c_g_affine_transform_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:42 GMT -->
</html>