{"id":24838,"date":"2017-09-08T18:32:34","date_gmt":"2017-09-08T13:02:34","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=24838"},"modified":"2017-09-08T18:32:34","modified_gmt":"2017-09-08T13:02:34","slug":"setviewport-function-c","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/setviewport-function-c\/","title":{"rendered":"setviewport function in c"},"content":{"rendered":"<p>setviewport function sets the current viewport for graphics output.<\/p>\n<p>Declaration :- void setviewport(int left, int top, int right, int bottom, int clip);<\/p>\n<p>setviewport function is used to restrict drawing to a particular portion on the screen. For example setviewport(100 , 100, 200, 200, 1);<br \/>\nwill restrict our drawing activity inside the rectangle(100,100, 200, 200).<br \/>\nleft, top, right, bottom are the coordinates of main diagonal of rectangle in which we wish to restrict our drawing. Also note that the point (left, top) becomes the new origin.<\/p>\n<h2 id=\"c-programming-source-code-for-setviewport\">C programming source code for setviewport<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-c code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-c code-embed-code\">#include&lt;graphics.h&gt;<br\/>#include&lt;conio.h&gt;<br\/> <br\/>main()<br\/>{<br\/>   int gd = DETECT, gm, midx, midy;<br\/> <br\/>   initgraph(&amp;gd, &amp;gm, &quot;C:\\\\TC\\\\BGI&quot;);<br\/> <br\/>   midx = getmaxx()\/2;<br\/>   midy = getmaxy()\/2;<br\/> <br\/>   setviewport(midx - 50, midy - 50, midx + 50, midy + 50, 1);<br\/>   circle(50, 50, 55);<br\/> <br\/>   getch();<br\/>   closegraph();<br\/>   return 0;<br\/>}<\/code><\/pre> <\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>setviewport function in c &#8211; c programming &#8211; setviewport function is used to restrict drawing to a particular portion on the screen. For example setviewport<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[82977,83095,75068,82980,82979,82976,82978,83096,83097,83098,76930,82975],"class_list":["post-24838","post","type-post","status-publish","format-standard","hentry","category-coding","tag-callback-function-in-c","tag-clearviewport-function-in-c","tag-function-program-in-c","tag-functions-in-c-language","tag-functions-in-c-pdf","tag-library-functions-in-c","tag-scanf-function-in-c","tag-setviewport-function-in-computer-graphics","tag-setviewport-qt","tag-setviewport-vtk","tag-string-functions-in-c","tag-types-of-functions-in-c"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/24838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=24838"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/24838\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=24838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=24838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=24838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}