{"id":604,"date":"2013-07-18T09:25:43","date_gmt":"2013-07-18T09:25:43","guid":{"rendered":"https:\/\/empty3.one\/blogs\/demoniakmachine.com\/?p=604"},"modified":"2013-07-18T09:25:43","modified_gmt":"2013-07-18T09:25:43","slug":"horloge","status":"publish","type":"post","link":"https:\/\/empty3.app\/blog1\/2013\/07\/18\/horloge\/","title":{"rendered":"Horloge"},"content":{"rendered":"<blockquote><p>package horloge;<\/p>\n<p>import be.ibiiztera.md.pmatrix.pushmatrix.Camera;<br \/>\nimport be.ibiiztera.md.pmatrix.pushmatrix.Point3D;<br \/>\nimport java.awt.Color;<br \/>\nimport java.awt.Dimension;<br \/>\nimport java.awt.image.BufferedImage;<\/p>\n<p>import be.ibiiztera.md.pmatrix.pushmatrix.Scene;<br \/>\nimport be.ibiiztera.md.pmatrix.pushmatrix.TColor;<br \/>\nimport be.ibiiztera.md.pmatrix.pushmatrix.ZBuffer;<br \/>\nimport be.ibiiztera.md.pmatrix.pushmatrix.ZBufferFactory;<br \/>\nimport be.ibiiztera.md.pmatrix.pushmatrix.ZBufferImpl;<br \/>\nimport be.ibiiztera.md.pmatrix.pushmatrix.generator.TRISphere;<br \/>\nimport java.awt.Container;<br \/>\nimport java.awt.Graphics;<br \/>\nimport java.awt.Image;<br \/>\nimport java.util.Date;<br \/>\nimport javax.swing.JButton;<br \/>\nimport javax.swing.JFrame;<br \/>\nimport javax.swing.JLabel;<\/p>\n<p>public class Horloge {<br \/>\nColor h;<br \/>\nColor m;<br \/>\nColor s;<br \/>\nDimension res;<br \/>\nprivate boolean montre = true;<br \/>\npublic Horloge(Color h, Color m, Color s, Dimension res) {<br \/>\nsuper();<br \/>\nthis.h = h;<br \/>\nthis.m = m;<br \/>\nthis.s = s;<br \/>\nthis.res = res;<br \/>\n}<br \/>\npublic Scene time()<br \/>\n{<br \/>\ndouble f = 2*Math.PI;<\/p>\n<p>Date d = new Date();<\/p>\n<p>Scene s = new Scene();<\/p>\n<p>TRISphere s0 = new TRISphere(Point3D.O0, 10);<br \/>\nTRISphere sH = new TRISphere(position(f*d.getHours()\/12)<br \/>\n.mult(60), 12);<br \/>\nTRISphere sM = new TRISphere(position(f*d.getMinutes()\/60)<br \/>\n.mult(80), 8);<br \/>\nTRISphere sS = new TRISphere(position(f*d.getSeconds()\/60)<br \/>\n.mult(100), 6);<\/p>\n<p>s0.couleur(new TColor(Color.WHITE));<br \/>\nsH.couleur(new TColor(Color.GREEN));<br \/>\nsM.couleur(new TColor(Color.BLUE));<br \/>\nsS.couleur(new TColor(Color.RED));<\/p>\n<p>s.add(s0);<br \/>\ns.add(sH);<br \/>\ns.add(sM);<br \/>\ns.add(sS);<\/p>\n<p>s.cameraActive(new Camera(Point3D.Z.mult(-200), Point3D.O0));<\/p>\n<p>return s;<br \/>\n}<br \/>\npublic Point3D position(double angle)<br \/>\n{<\/p>\n<p>Point3D p0 =<br \/>\nnew Point3D(<br \/>\n-Math.sin(angle),<br \/>\n-Math.cos(angle),<br \/>\n0<br \/>\n);<\/p>\n<p>return p0;<br \/>\n}<br \/>\npublic void montrer(Container c)<br \/>\n{<br \/>\nZBuffer z = ZBufferFactory.instance(<br \/>\n(int)res.getWidth(),<br \/>\n(int)res.getHeight());<\/p>\n<p>while(montre)<br \/>\n{<br \/>\ntry {<br \/>\nThread.sleep(100);<br \/>\n} catch (InterruptedException e) {<br \/>\n\/\/ TODO Auto-generated catch block<br \/>\ne.printStackTrace();<br \/>\n}<br \/>\nz.couleurDeFond(new TColor(Color.BLACK));<\/p>\n<p>z.suivante();<\/p>\n<p>z.scene(time());<\/p>\n<p>z.dessinerSilhouette3D();<\/p>\n<p>Image bi = ((ZBufferImpl)z).image2();<\/p>\n<p>c.getGraphics().drawImage(bi, 0, 0,(int) res.getWidth(), (int)res.getHeight(), null);<br \/>\n}<br \/>\n}<\/p>\n<p>public static void main(String [] args)<br \/>\n{<br \/>\nJFrame f = new JFrame(\u00ab\u00a0Horloge 3D\u00a0\u00bb);<\/p>\n<p>f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<\/p>\n<p>JLabel b = new JLabel(\u00ab\u00a0Horloge\u00a0\u00bb);<\/p>\n<p>f.setContentPane(b);<\/p>\n<p>f.setSize(1024, 768);<\/p>\n<p>f.setVisible(true);<\/p>\n<p>Horloge h = new Horloge(null, null, null, b.getSize());<\/p>\n<p>h.montrer(b);<br \/>\n}<br \/>\n}<\/p>\n<p>&nbsp;<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>package horloge; import be.ibiiztera.md.pmatrix.pushmatrix.Camera; import be.ibiiztera.md.pmatrix.pushmatrix.Point3D; import java.awt.Color; import java.awt.Dimension; import java.awt.image.BufferedImage; import be.ibiiztera.md.pmatrix.pushmatrix.Scene; import be.ibiiztera.md.pmatrix.pushmatrix.TColor; import be.ibiiztera.md.pmatrix.pushmatrix.ZBuffer; import be.ibiiztera.md.pmatrix.pushmatrix.ZBufferFactory; import be.ibiiztera.md.pmatrix.pushmatrix.ZBufferImpl; import be.ibiiztera.md.pmatrix.pushmatrix.generator.TRISphere; import java.awt.Container; import java.awt.Graphics; import java.awt.Image; import java.util.Date; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; public class Horloge { Color h; Color m; Color s; Dimension res; private boolean montre = true; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-604","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/empty3.app\/blog1\/wp-json\/wp\/v2\/posts\/604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/empty3.app\/blog1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/empty3.app\/blog1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/empty3.app\/blog1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/empty3.app\/blog1\/wp-json\/wp\/v2\/comments?post=604"}],"version-history":[{"count":0,"href":"https:\/\/empty3.app\/blog1\/wp-json\/wp\/v2\/posts\/604\/revisions"}],"wp:attachment":[{"href":"https:\/\/empty3.app\/blog1\/wp-json\/wp\/v2\/media?parent=604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/empty3.app\/blog1\/wp-json\/wp\/v2\/categories?post=604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/empty3.app\/blog1\/wp-json\/wp\/v2\/tags?post=604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}