{"id":80,"date":"2012-10-27T23:42:55","date_gmt":"2012-10-27T23:42:55","guid":{"rendered":"https:\/\/www.taumeta.org\/?p=80"},"modified":"2012-10-28T01:02:15","modified_gmt":"2012-10-28T01:02:15","slug":"basics-variables-in-tmtp","status":"publish","type":"post","link":"https:\/\/www.taumeta.org\/?p=80","title":{"rendered":"Basics: Variables in TMTP"},"content":{"rendered":"<p style=\"text-align: center;\"><a href=\"https:\/\/www.taumeta.org\/wp-content\/uploads\/2012\/10\/Points.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"88\" data-permalink=\"https:\/\/www.taumeta.org\/?attachment_id=88\" data-orig-file=\"https:\/\/www.taumeta.org\/wp-content\/uploads\/2012\/10\/Points.png\" data-orig-size=\"634,518\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Points\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.taumeta.org\/wp-content\/uploads\/2012\/10\/Points-300x245.png\" data-large-file=\"https:\/\/www.taumeta.org\/wp-content\/uploads\/2012\/10\/Points.png\" class=\" wp-image-88 aligncenter\" title=\"Points\" src=\"https:\/\/www.taumeta.org\/wp-content\/uploads\/2012\/10\/Points.png\" alt=\"\" width=\"507\" height=\"414\" srcset=\"https:\/\/www.taumeta.org\/wp-content\/uploads\/2012\/10\/Points.png 634w, https:\/\/www.taumeta.org\/wp-content\/uploads\/2012\/10\/Points-300x245.png 300w, https:\/\/www.taumeta.org\/wp-content\/uploads\/2012\/10\/Points-210x171.png 210w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/a>The basic data object in TMTP is the point.<\/p>\n<p style=\"text-align: left;\">A point is a python object with these three attributes:<br \/>\n<strong>x<\/strong> \u00a0 \u00a0 \u00a0 : the x coordinate of the point<br \/>\n<strong>y<\/strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : the y coordinate of the point<br \/>\n<strong>name<\/strong>: the name of the point<\/p>\n<p>The names are very simplified, because there can be over 100 points in a complex pattern piece. Points are named using it&#8217;s pattern piece letter. The first point to be drawn on\u00a0 pattern piece<strong> D<\/strong> should be named &#8216;<strong>da<\/strong>&#8216;.<\/p>\n<p>There are two types of drawn points in TMTP:<br \/>\npattern points\u00a0\u00a0\u00a0\u00a0 : solid red circles, created with <strong>rPointP()<\/strong> or <strong>rPoint()<\/strong> functions.<br \/>\ncontrol points\u00a0\u00a0\u00a0\u00a0 : gray outlined circles, created with <strong>cPointP()<\/strong> or <strong>cPoint()<\/strong> functions.<br \/>\nPattern points mark normal pattern points.<br \/>\nControl points mark the handles of pattern curves.<\/p>\n<p>Here is TMTP code to create points <strong>da<\/strong> at the origin and<strong> db <\/strong>at 3 inches right and 4 inches down from <strong>da<\/strong> on pattern piece <strong>D<\/strong>:<br \/>\n<strong>da = rPoint(D, &#8216;da&#8217;, 0.0, 0.0)<\/strong><br \/>\n<strong>db = rPoint(D, &#8216;db&#8217;, da.x + 3.0*IN, da.y + 4*IN)<\/strong><\/p>\n<p>To calculate control points for a curve from da to db:<br \/>\n<strong>db.c1 = cPointP(D, &#8216;db.c1&#8217;, &lt;point at angle and length from da<strong><\/strong>&gt;)<\/strong><br \/>\n<strong>db.c2 = cPointP(D, &#8216;db.c2&#8217;, &lt;point at angle and length from db<strong><\/strong>&gt;)<\/strong><em><br \/>\nmore on how to calculate control points in another tutorial<\/em>\u00a0 &#8211;\u00a0 <em>they&#8217;re usually created at an angle from one of the two endpoints.<\/em><br \/>\n<strong><\/strong><\/p>\n<p><strong><\/strong> <strong>IN<\/strong> converts inches to pixels, and <strong>CM<\/strong> converts centimeters to pixels. TMTP uses Inkscape&#8217;s base measurement ratio, <strong><em>90 pixels per inch<\/em><\/strong>. Look in the tmtp\/standalone\/tmtpl\/constants.py file to see all the TMTP global variables.<\/p>\n<p><em>Python Programming Notes:<br \/>\nThe numbers used with IN and CM can be integers or have decimal values. The result will be the same. When using fractions, ratios, or dividing, as in (5\/8.0)*IN, the divisor *must* have a decimal or python may round down to the nearest integer.<\/em>\u00a0<em><\/em><\/p>\n<p>Some points do not need to create an SVG circle.\u00a0 You might need to create a point to help calculate a pattern or control point:<br \/>\n<strong> temp_pnt = Pnt(db.x, da.y)<br \/>\n<\/strong><strong><\/strong>The Pnt() function creates a python object of the Pnt <em>base<\/em><em> class<\/em>. Pattern and control points are created with the Point() base class<strong>\u00a0<\/strong>which has attributes and methods to enable the point to be drawn to the SVG canvas, transformed, etc.<\/p>\n<p>Here&#8217;s an example of some of pattern point <strong>da&#8217;s\u00a0<\/strong>attributes, on pattern piece <strong>D, <\/strong>with coordinates (15, 20):<br \/>\n<strong>da.x<\/strong>\u00a0\u00a0 = 15.0<br \/>\n<strong> da.y<\/strong>\u00a0\u00a0 = 20.0<br \/>\n<strong>da.name<\/strong> = &#8216;da&#8217;<br \/>\n<strong>da.id<\/strong> = &#8216;D.da&#8217;<br \/>\n<strong>da.coords<\/strong> = &#8216;15.0, 20.0&#8217;<br \/>\n<em><\/em><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The basic data object in TMTP is the point. A point is a python object with these three attributes: x \u00a0 \u00a0 \u00a0 : the x coordinate of the point y\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : the y coordinate of the point name: the name of the point The names are very simplified, because there can be over 100 [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":88,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[14],"tags":[15],"class_list":["post-80","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-code"],"jetpack_featured_media_url":"https:\/\/www.taumeta.org\/wp-content\/uploads\/2012\/10\/Points.png","jetpack_shortlink":"https:\/\/wp.me\/p3clcA-1i","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.taumeta.org\/index.php?rest_route=\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.taumeta.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.taumeta.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.taumeta.org\/index.php?rest_route=\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.taumeta.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=80"}],"version-history":[{"count":10,"href":"https:\/\/www.taumeta.org\/index.php?rest_route=\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/www.taumeta.org\/index.php?rest_route=\/wp\/v2\/posts\/80\/revisions\/102"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.taumeta.org\/index.php?rest_route=\/wp\/v2\/media\/88"}],"wp:attachment":[{"href":"https:\/\/www.taumeta.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.taumeta.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.taumeta.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}