{"id":2117,"date":"2012-11-23T20:04:30","date_gmt":"2012-11-24T03:04:30","guid":{"rendered":"http:\/\/sanuja.com\/blog\/?p=2117"},"modified":"2020-09-13T11:29:02","modified_gmt":"2020-09-13T17:29:02","slug":"moving-multiple-objects-using-python-and-java","status":"publish","type":"post","link":"https:\/\/sanuja.com\/blog\/moving-multiple-objects-using-python-and-java","title":{"rendered":"Moving multiple objects using Python and Java"},"content":{"rendered":"<p><strong>Introduction to Python 3<\/strong><\/p>\n<p>Python is a high level object oriented programming language that closely related to languages such as Java and C #. While it is a useful coding system, it is also one of the easiest to learn. The basic Python functions such as print statements are same or similar to other languages. This language is currently (as of November 2012) being used by banks, industrial automation, video games and many more. However, if you are<!--more--> planing to learn a programming language, I recommend C++ over Python 3.<\/p>\n<p><strong>User driven data for objects movement<\/strong><\/p>\n<p>The following program will draw a face with several parameters (triangle, circles, ellipses, etc) on a black background in quickdraw.jar.<\/p>\n<p>You must download the quickdraw program and install Java in the run time environment. You can download Java <a href=\"http:\/\/www.java.com\/en\/download\/index.jsp\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>. If you are on 64-bit OS, you may want to download the 64-bit version at <a href=\"http:\/\/www.java.com\/en\/download\/faq\/java_win64bit.xml\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>. The quickdraw program is written in Java and can be downloaded <a href=\"http:\/\/pages.cpsc.ucalgary.ca\/QuickDraw\/\" target=\"_blank\" rel=\"noopener noreferrer\">here (original author Dr. Ben Stephenson)<\/a> or <a href=\"http:\/\/sanuja.com\/quickdraw.jar\">here (sanuja.com)<\/a>.<\/p>\n<div class=\"alert alert-warning\" role=\"alert\"><p class=\"printonly\"><strong>Warning!<\/strong><\/p>Do not copy my code as per copyright and plagiarism regulations. This code is provided as it is for demonstration purposes. This program require the quickdraw application and if you want to run this, copy and paste the following code to a .py file.<\/div>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# Written by by: M. Sanuja Senanayake\r\n# SourceCode.py - Java pipe function is used to input the output of this Python 3 code\r\n# The input will be displayed in quickdraw window with default black background.\r\n# The objective of this program is to create a &quot;face&quot; that can move around the quickdraw \r\n# window according to user driven inputs.\r\n#\r\n# To run this program, enter: phython3 SourceCode.py | java -jar quickdraw.jar\r\n#\r\n# Prompt for user input for left and right positions and importing the standard error for text input\r\n#\r\nimport sys\r\nsys.stderr.write(&quot;Position with respect to left\/right please: &quot;)\r\nx_pos = int(float(input()))\r\nsys.stderr.write(&quot;Position with respect to up\/down please: &quot;)\r\ny_pos = int(float(input()))\r\n#\r\n# face configuration\r\n#\r\nprint (&quot;colour 131 111 255&quot;) # face colour\r\nprint (&quot;fillcircle&quot; ,x_pos, y_pos,&quot;251 face&quot;) # face\r\n#\r\n# the right eye configuration\r\n#\r\nprint (&quot;colour 51 0 51&quot;)\r\nprint (&quot;fillellipse&quot; ,x_pos+100, y_pos-110,&quot;145 50 right_eye&quot;)\r\nprint (&quot;colour 92 172 255&quot;)#inside right eye\r\nprint (&quot;fillcircle&quot; ,x_pos+100, y_pos-110,&quot;20 right_eye_inside&quot;)\r\n#\r\n# the left eye configuration\r\n#\r\nprint (&quot;colour 51 0 51&quot;)\r\nprint (&quot;fillellipse&quot; ,x_pos-100, y_pos-110,&quot;145 50 left_eye&quot;)\r\nprint (&quot;colour 92 172 255&quot;)#inside left eye\r\nprint (&quot;fillcircle&quot; ,x_pos-100, y_pos-110,&quot;20 left_eye_inside&quot;)\r\n#\r\n# mouth configuration\r\n#\r\nprint (&quot;colour 186 85 211&quot;)\r\nprint (&quot;fillarc&quot; ,x_pos-100, y_pos+75,&quot;200 100 180 180 chord mouth&quot;)\r\n#\r\n# tongue configuration\r\n#\r\nprint (&quot;color 128 0 0&quot;)\r\nprint (&quot;fillellipse&quot; ,x_pos-0, y_pos+160,&quot;30 61 ellipse&quot;)\r\n#\r\n# nose configuration\r\n#\r\nprint (&quot;colour 0 00 225&quot;)\r\nprint(&quot;fillpolygon&quot; ,x_pos-50, y_pos+60, x_pos+50, y_pos+60, x_pos-0, y_pos-0, &quot;nose&quot;)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to Python 3 Python is a high level object oriented programming language that closely related to languages such as Java and C #. While it is a useful coding system, it is also one of the easiest to learn. The basic Python functions such as print statements are same or similar to other languages. &hellip; <a href=\"https:\/\/sanuja.com\/blog\/moving-multiple-objects-using-python-and-java\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Moving multiple objects using Python and Java<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","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":[3],"tags":[8,48,22],"class_list":["post-2117","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-academic","tag-java","tag-python"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/posts\/2117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/comments?post=2117"}],"version-history":[{"count":0,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/posts\/2117\/revisions"}],"wp:attachment":[{"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/media?parent=2117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/categories?post=2117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/tags?post=2117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}