{"id":424,"date":"2019-07-05T14:09:21","date_gmt":"2019-07-05T12:09:21","guid":{"rendered":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/?page_id=424"},"modified":"2019-08-17T13:40:01","modified_gmt":"2019-08-17T11:40:01","slug":"2-3-4-exercici-un-rellotge","status":"publish","type":"page","link":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/2-3-4-exercici-un-rellotge\/","title":{"rendered":"2.3.4. Exercici &#8211; Un rellotge"},"content":{"rendered":"<p>Qu\u00e8 fa aquest codi?<\/p>\n<div class=\"featured featured-blue\"><p><strong>Pista<\/strong>: a les variables hores, minuts i segons es guarda l\u2019hora, els minuts i els segons de l\u2019hora actual (la que t\u00e9 el rellotge de l\u2019ordinador). Intenta entendre tot el que fa el programa. Si tens algun dubte, pots mirar-ho al final d\u2019aquesta guia.<\/p>\n<\/div>\n<pre>function setup() {\r\n  createCanvas(200, 200);\r\n  strokeWeight(2);\r\n}\r\nfunction draw() {\r\n  var dataHora = new Date();\r\n  var hores = dataHora.getHours();\r\n  var minuts = dataHora.getMinutes();\r\n  var segons = dataHora.getSeconds();\r\n  background(220);\r\n  translate(100,100)\r\n  for (var i=0;i&lt;60;i++){\r\n    if (i % 5 == 0) {\r\n      stroke(0);\r\n      line(0, -40, 0, -60);\r\n    }\r\n    if (i == (hores % 12 * 5)) {\r\n      stroke(255,0,0);\r\n      line(0, -40, 0, -70);\r\n    }\r\n    if (i == minuts) {\r\n      stroke(0,0,255);\r\n      line(0, -40, 0, -70);\r\n    }\r\n    if (i == segons) {\r\n      stroke(255);\r\n      line(0, -40, 0, -60);\r\n    }\r\n    rotate(PI \/ 30.0);\r\n  }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Qu\u00e8 fa aquest codi? function setup() { createCanvas(200, 200); strokeWeight(2); } function draw() { var dataHora = new Date(); var hores = dataHora.getHours(); var minuts = dataHora.getMinutes(); var segons = dataHora.getSeconds(); background(220); translate(100,100) for (var i=0;i&lt;60;i++){ if (i % 5 == 0) { stroke(0); line(0, -40, 0, -60); } if (i == (hores % 12 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false},"acf":[],"_links":{"self":[{"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/wp-json\/wp\/v2\/pages\/424"}],"collection":[{"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/wp-json\/wp\/v2\/comments?post=424"}],"version-history":[{"count":12,"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/wp-json\/wp\/v2\/pages\/424\/revisions"}],"predecessor-version":[{"id":3743,"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/wp-json\/wp\/v2\/pages\/424\/revisions\/3743"}],"wp:attachment":[{"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/wp-json\/wp\/v2\/media?parent=424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}