{"id":1316,"date":"2023-04-06T17:15:35","date_gmt":"2023-04-06T16:15:35","guid":{"rendered":"https:\/\/blog.univ-angers.fr\/mathsinfo\/?page_id=1316"},"modified":"2023-04-18T18:20:16","modified_gmt":"2023-04-18T17:20:16","slug":"motifs-de-remplissage","status":"publish","type":"page","link":"https:\/\/blog.univ-angers.fr\/mathsinfo\/motifs-de-remplissage\/","title":{"rendered":"Motifs de remplissage"},"content":{"rendered":"\n<p>Vous connaissez probablement les <strong>motifs de remplissage<\/strong> du <strong>pack Office<\/strong> :<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-19.png\"><img loading=\"lazy\" decoding=\"async\" width=\"251\" height=\"235\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-19.png\" alt=\"\" class=\"wp-image-1318\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>L&rsquo;id\u00e9e est de <strong>recr\u00e9er<\/strong> exactement <strong>ces motifs<\/strong> en <strong>Python<\/strong> pour obtenir par exemple :<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-21.png\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-21.png\" alt=\"\" class=\"wp-image-1320\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-21.png 320w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-21-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><figcaption class=\"wp-element-caption\">Grille treillis en pointill\u00e9s<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Partie 1 &#8211; De PowerPoint \u00e0 Gimp<\/h2>\n\n\n\n<p><span style=\"text-decoration: underline\">Dessinez un rectangle<\/span> dans PowerPoint, <span style=\"text-decoration: underline\">supprimez la bordure<\/span> et utilisez un <span style=\"text-decoration: underline\">remplissage<\/span> de type <span style=\"text-decoration: underline\">motif<\/span> de votre choix avec du <strong>noir<\/strong> en couleur de <strong>premier plan<\/strong> et du <strong>blanc<\/strong> en <strong>arri\u00e8re-plan<\/strong> :<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-23.png\"><img loading=\"lazy\" decoding=\"async\" width=\"540\" height=\"216\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-23.png\" alt=\"\" class=\"wp-image-1322\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-23.png 540w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-23-300x120.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-23-500x200.png 500w\" sizes=\"auto, (max-width: 540px) 100vw, 540px\" \/><\/a><figcaption class=\"wp-element-caption\">Un rectangle Noir\/Blanc sans bord avec ici le motif \u00ab\u00a0briques diagonales\u00a0\u00bb<\/figcaption><\/figure>\n<\/div>\n\n\n<p><span style=\"text-decoration: underline\">Collez ce rectangle<\/span> dans <span style=\"text-decoration: underline\">Gimp<\/span> et choisir l&rsquo;outil de <span style=\"text-decoration: underline\">s\u00e9lection rectangulaire<\/span> avec comme <span style=\"text-decoration: underline\">dimensions<\/span> fixes <span style=\"text-decoration: underline\">8&#215;8 pixels<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-24.png\"><img loading=\"lazy\" decoding=\"async\" width=\"394\" height=\"529\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-24.png\" alt=\"\" class=\"wp-image-1323\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-24.png 394w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-24-223x300.png 223w\" sizes=\"auto, (max-width: 394px) 100vw, 394px\" \/><\/a><figcaption class=\"wp-element-caption\">S\u00e9lection 8&#215;8 pixels du coin sup\u00e9rieur gauche<\/figcaption><\/figure>\n<\/div>\n\n\n<p><strong>Image &#8211; Rogner suivant la s\u00e9lection<\/strong>. Vous devez obtenir une image de 8&#215;8 pixels.<\/p>\n\n\n\n<p><strong>Filtres &#8211; Python-Fu &#8211; Console<\/strong> puis <span style=\"text-decoration: underline\">coller ce script<\/span> :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def nw():\n im = gimp.image_list()&#091;0]\n layer = im.layers&#091;0]\n s = &#091;]\n for i in range(64):\n   v = list(pdb.gimp_image_pick_color(im, layer, i%8, i\/\/8, 1, 0, 0))&#091;0]\n   if v != 255: s.append(i)\n return s<\/code><\/pre>\n\n\n\n<p>Tapez plusieurs fois sur <strong>Entr\u00e9e<\/strong> pour revenir au prompt puis lancez le programme par <strong>nw()<\/strong>. Voici un exemple de r\u00e9sultat :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt;&gt;&gt; nw()\n&#091;0, 1, 10, 15, 19, 22, 28, 29, 36, 43, 50, 57]<\/code><\/pre>\n\n\n\n<p>Le programme pr\u00e9c\u00e9dent parcourt les 64 pixels, pour chacun il r\u00e9cup\u00e8re la premi\u00e8re composante de la couleur, si elle n&rsquo;est pas \u00e9gale \u00e0 255 (blanc) c&rsquo;est que l&rsquo;on a du noir (on pouvait aussi faire le test v == 0).<\/p>\n\n\n\n<p>Si vous voulez recommencer avec un autre motif, fermez l&rsquo;image dans Gimp, changez de motif dans PowerPoint, copiez-collez le nouveau rectangle dans Gimp puis s\u00e9lection 8&#215;8, rognage et lancez le script nw().<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Partie 2 &#8211; Script Python pour la NUMWORKS<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>from kandinsky import *\n\nbriquesdiag = 0, 1, 10, 15, 19, 22, 28, 29, 36, 43, 50, 57\n\ndef fond(motif):\n for c in range(0, 320, 8):\n  for l in range(0, 222, 8):\n   for i in motif:\n    set_pixel(c + (i % 8), l + (i \/\/ 8), (0, 0, 0))\n\nfond(briquesdiag)<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-26.png\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-26.png\" alt=\"\" class=\"wp-image-1326\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-26.png 320w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-26-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Voici d&rsquo;autres codes de motifs extraits de PowerPoint :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pointilles5 = 0,36\npointilles10 = 7,11,22,25,36,40,53,58\npointilles20 = 0,4,18,22,32,36,50,54\ndiag1 = 3,7,10,14,17,21,24,28,35,39,42,46,49,53,56,60\nconfettis = 0,4,5,7,12,13,16,17,24,25,27,28,35,36,38,39,46,47,50,51,56,58,59,63\ntresse = 0,4,9,15,18,22,27,29,31,32,36,41,45,47,50,54,57,59,61\ngrtreillis = 0,18,22,36,50,54\n<\/code><\/pre>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/my.numworks.com\/python\/schraf\/remplissage\" target=\"_blank\">Lien vers le script final<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vous connaissez probablement les motifs de remplissage du pack Office : L&rsquo;id\u00e9e est de recr\u00e9er exactement ces motifs en Python pour obtenir par exemple : Partie 1 &#8211; De PowerPoint \u00e0 Gimp Dessinez un rectangle dans PowerPoint, supprimez la bordure &hellip; <a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/motifs-de-remplissage\/\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4913,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1316","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/pages\/1316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/users\/4913"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/comments?post=1316"}],"version-history":[{"count":8,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/pages\/1316\/revisions"}],"predecessor-version":[{"id":1374,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/pages\/1316\/revisions\/1374"}],"wp:attachment":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/media?parent=1316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}