{"id":324,"date":"2019-06-13T09:21:27","date_gmt":"2019-06-13T09:21:27","guid":{"rendered":"http:\/\/ifdesignelseart.com\/?p=324"},"modified":"2019-06-14T05:17:49","modified_gmt":"2019-06-14T05:17:49","slug":"outil-de-diffusion-dimages","status":"publish","type":"post","link":"https:\/\/ifdesignelseart.com\/?p=324","title":{"rendered":"Outil de diffusion d&rsquo;images"},"content":{"rendered":"\n<p>Le programme qui suit sert \u00e0 diffuser au hasard les images contenues dans le dossier \u00ab\u00a0data\u00a0\u00bb. Les images affich\u00e9es voient leur format s&rsquo;adapter \u00e0 l&rsquo;\u00e9cran lorsqu&rsquo;elles exc\u00e8dent ses dimensions.<\/p>\n\n\n\n<pre class=\"brush:java\">String[] images;\nIntList ordre;\nint vitesse=1500; \/\/ une nouvelle image s'affiche toutes les 1,5 secondes (1500 millisecondes)\nint next=0;\ncolor fond=#000000;\n\nvoid setup(){\n  fullScreen();\n  imageMode(CENTER);\n  ordre=new IntList();\n  images = listFileNames(dataPath(\"\")); \n  background(fond);\n}\n\nvoid draw(){\n  if(ordre.size()==0){\n    for(int a=0;a<images.length;a++){\n      ordre.append(a);\n    } \n    ordre.shuffle();\n  }\n  if(millis()>next){\n    affiche(images[ordre.get(0)]);\n    ordre.remove(0);\n    next=millis()+vitesse;\n  }\n}\n\nString[] listFileNames(String dir) {\n  File file = new File(dir);\n  if (file.isDirectory()) {\n    String names[] = file.list();\n    String newNames[] = new String[0];\n    for(String n:names){\n      if(match(n, \".*\\\\.|jpg|jpeg|png|bmp|gif|JPG|JPEG|PNG|BMP|GIF\")!=null){\n        newNames = (String[]) append(newNames, n);\n      }\n    } \n    return newNames ;\n  } else { \n    return null;\n  }\n}\n\nvoid affiche(String im){\n  background(fond);\n  PImage fichier = loadImage(im);\n  int largeur=fichier.width;\n  int hauteur=fichier.height;\n  if(largeur>width){\n    float pc = float(width)\/largeur;\n    hauteur = round(pc*hauteur);\n    largeur=width;\n  }\n  if(hauteur>height){\n    float pc = float(height)\/hauteur;\n    largeur = round(pc*largeur);\n    hauteur=height;\n  }\n  \n  if(largeur>width||hauteur>height){\n    largeur=width;hauteur=height;\n  } \n  image(fichier, width\/2, height\/2, largeur, hauteur);\n  \n}<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Le programme qui suit sert \u00e0 diffuser au hasard les images contenues dans le dossier \u00ab\u00a0data\u00a0\u00bb. Les images affich\u00e9es voient leur format s&rsquo;adapter \u00e0 l&rsquo;\u00e9cran lorsqu&rsquo;elles exc\u00e8dent ses dimensions. String[] images; IntList ordre; int vitesse=1500; \/\/ une nouvelle image s&rsquo;affiche toutes les 1,5 secondes (1500 millisecondes) int next=0; color fond=#000000; void setup(){ fullScreen(); imageMode(CENTER); ordre=new [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-324","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=\/wp\/v2\/posts\/324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=324"}],"version-history":[{"count":3,"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=\/wp\/v2\/posts\/324\/revisions"}],"predecessor-version":[{"id":327,"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=\/wp\/v2\/posts\/324\/revisions\/327"}],"wp:attachment":[{"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ifdesignelseart.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}