{"id":18748,"date":"2016-11-19T19:48:40","date_gmt":"2016-11-19T19:48:40","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=18748"},"modified":"2018-07-10T14:47:30","modified_gmt":"2018-07-10T14:47:30","slug":"web-design-ysinx-from-jsdraw2dx","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/web-design-ysinx-from-jsdraw2dx\/","title":{"rendered":"Web design:  y=sinx from jsDraw2DX"},"content":{"rendered":"<h1>The tutor shows how to produce a graph of sinx on a web page using jsDraw2DX.<\/h1>\n<p>I&#8217;ve mentioned jsDraw2DX in a couple of posts (<a href=\"?p=18235\">here<\/a> and <a href=\"?p=16258\">here<\/a>).<\/p>\n<p>For producing a graph of sinx, the basic construct is<\/p>\n<div style=\"font-family:monospace;font-size:150%;color:#aa33aa\">\nvar singraph = new jxFunctionGraph(&#8216;Asin(b(x-c)) + d&#8217;, x_start, x_end, thePen);<br \/>\nsingraph.draw(graphics_div);\n<\/div>\n<p style=\"white-space:pre-wrap\"><\/p>\n<p>Above, A,b,c,and d are numbers to customize the sin graph.  x_start and x_end are the start and end x-coordinates of the graph. thePen is an instance of jxPen, used to draw curves and outlines.  graphics_div is the &#60;div&#62; element in which the graphics will be displayed.<\/p>\n<p>Since webpage coordinates often start from the upper corner, then go across and down (rather than up), you may find you need the parameter A to be negative for the graph to look as expected.  For instance, y=-sinx might be needed to produce a graph that looks like y=sinx should.<\/p>\n<p>Here&#8217;s an example:<\/p>\n<div style=\"display:block;margin:auto;width:291.33px;height:175px\">\n<div id=\"graphics\" style=\"position:relative;width:291.33px;height:175px;background-color:yellow\"><\/div>\n<\/div>\n<p><script src=\"\/..\/jsDraw2DX\/jsDraw2DX.js\"><\/script><br \/>\n<script src=\"\/..\/jsDraw2DX_projects\/sinx_nov19.js\"><\/script><\/p>\n<p>The actual function to produce the graph above in jsDraw2DX:<\/p>\n<div style=\"font-family:monospace;font-size:150%;color:#aa33aa\">\n-45sin((x-20)\/20)+60\n<\/div>\n<p style=\"white-space:pre-wrap\"><\/p>\n<p>Source:<\/p>\n<p><a href=\"http:\/\/jsdraw2dx.jsfiction.com\/\">jsDraw2DX<\/a><\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor shows how to produce a graph of sinx on a web page using jsDraw2DX. I&#8217;ve mentioned jsDraw2DX in a couple of posts (here and here). For producing a graph of sinx, the basic construct is var singraph = &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/web-design-ysinx-from-jsdraw2dx\/\"> <span class=\"screen-reader-text\">Web design:  y=sinx from jsDraw2DX<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1965,1855],"tags":[2033,838],"class_list":["post-18748","post","type-post","status-publish","format-standard","hentry","category-jsdraw2dx-web-design","category-web-programming","tag-sin-graph-on-web-page","tag-web-graphics"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/18748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=18748"}],"version-history":[{"count":29,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/18748\/revisions"}],"predecessor-version":[{"id":35337,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/18748\/revisions\/35337"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=18748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=18748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=18748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}