{"id":1964,"date":"2019-07-10T13:29:20","date_gmt":"2019-07-10T11:29:20","guid":{"rendered":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/?page_id=1964"},"modified":"2019-08-17T13:54:25","modified_gmt":"2019-08-17T11:54:25","slug":"2-3-4-ejercicio-un-reloj","status":"publish","type":"page","link":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/es\/2-3-4-ejercicio-un-reloj\/","title":{"rendered":"2.3.4. Ejercicio &#8211; Un reloj"},"content":{"rendered":"<p>\u00bfQu\u00e9 hace este c\u00f3digo?<\/p>\n<div class=\"featured featured-blue\"><p><strong>Pista<\/strong>: en las variables horas, minutos y segundos se guarda la hora, los minutos y los segundos de la hora actual (la que tiene el reloj del ordenador). Intentad entender todo lo que hace el programa. Si ten\u00e9is alguna duda pod\u00e9is mirar al final de esta gu\u00eda.<\/p>\n<\/div>\n<pre>function setup() {\r\n  createCanvas(200, 200);\r\n  strokeWeight(2);\r\n}\r\nfunction draw() {\r\n  var fechaHora = new Date();\r\n  var horas = fechaHora.getHours();\r\n  var minutos = fechaHora.getMinutes();\r\n  var segundos = fechaHora.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 == (horas % 12 * 5)) {\r\n      stroke(255,0,0);\r\n      line(0, -40, 0, -70);\r\n    }\r\n    if (i == minutos) {\r\n      stroke(0,0,255);\r\n      line(0, -40, 0, -70);\r\n    }\r\n    if (i == segundos) {\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>\u00bfQu\u00e9 hace este c\u00f3digo? function setup() { createCanvas(200, 200); strokeWeight(2); } function draw() { var fechaHora = new Date(); var horas = fechaHora.getHours(); var minutos = fechaHora.getMinutes(); var segundos = fechaHora.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 == (horas % 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\/es\/wp-json\/wp\/v2\/pages\/1964"}],"collection":[{"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/es\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/es\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/es\/wp-json\/wp\/v2\/comments?post=1964"}],"version-history":[{"count":12,"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/es\/wp-json\/wp\/v2\/pages\/1964\/revisions"}],"predecessor-version":[{"id":3747,"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/es\/wp-json\/wp\/v2\/pages\/1964\/revisions\/3747"}],"wp:attachment":[{"href":"http:\/\/disseny-test.uoc.edu\/materials\/programacio\/es\/wp-json\/wp\/v2\/media?parent=1964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}