æåã«
ããã®è¨äºã¯ã2012å¹´ã«çºå£²ãããNintendo 3DSã§çºå£²ããããã¨ã³ã ãã©ãã¶ã¤ã®æ£®ãã®ããã«æ¸ããè¨äºã§ããSwitchçã®ããã¤ã¾ãã©ãã¶ã¤ã®æ£®ãã®ãã¤ãã¶ã¤ã³ã«é¢ãã¦ã¯ãæ°ãã«è¨äºæ¸ãã¾ããã®ã§èå³ããæ¹ã¯ä»¥ä¸åç §ãã ããã
Processing Advent Calendar 2012 åå ãã¾ã
ãProcessing Advent Calendar 2012ã¨ããProcessingã«é¢ããè¨äºãæ¯æ¥æã¡åãã§æ稿ããä¼ç»ã«ãçºèµ·äººã®@reona396ãããããèªããåãåå ãã¦ãã¾ãã
ãã¡ãªã¿ã«Processingã¯ä½ãã¨ããã¨ããã°ã©ãã³ã°è¨èªãªã®ã§ãããããã®ã¯ã¾ããã«ããã©ãããã©ã¼ã ã§ãããããªOSã§åããã¨ã¨ãæ軽ã«ä½ãã¤ããããç¹ã«çµµãç°¡åã«ãããã®ãç´ æ´ãããã§ããä»ã®ããã°ã©ãã³ã°è¨èªã ã¨ãæ®éçµµãæãã®ã«è²ã
ç´æäºãããã®ã§ãããProcessingã ã¨ã»ãã¨ä¸è¡ã§çµµãããã¦ãã¾ãã¾ãããã¨ã¯ãArduinoã¨ããæè¿èå
ãæµ´ã³ã¦ããå®ä¾¡ãªã¤ã¿ãªã¢è£½ãã¤ã³ã³ã®éçºè¨èªã®ãã¼ã¹ã«ãªã£ã¦ããããKinectãèªå¨ã«æããã¨ãã§ãããã¨æ¡å¼µæ§ã大ããã§ãã
ããããªããã§ãèªåã¿ããã«ããã°ã©ã ã®æ£ããã¨ããä¿å®æ§ã¨ãèå³ç¡ãã¦ãã¼ã«ã¨ãã¦ä½¿ãããã¨ãã人ã«ã¯ãã£ã¦ã¤ãã®è¨èªã§ã¯ãªãããªã¨æãã¾ãã
Processingã§ãã©ãã¶ã¤ã®æ£®ã®ãã¤ãã¶ã¤ã³è£å©ãã¼ã«ããä½ã
ããããªProcessingã使ã£ã¦ãããªãã¨ãã§ãããã¨ããä¾ã¨ãã¦ãä»åã¯ã©ãã¶ã¤ã®æ£®ã®ãã¤ãã¶ã¤ã³è£å©ãã¼ã«ãä½ã£ã¦ã¿ããã¨æãã¾ãããããªãã¨ã¾ã§ã§ãããã ãï¼åããProcessingï¼
ããã¨ãã¨ã¯twitterä¸ã§ã¨ããæ¹ã«ãæã¤ãã£ããProcessingで写真や画像をドット絵に変換するソフトãã«é¢ãã¦è³ªååããä¼è©±ã®æµãã§ããã®ãã¼ã«ãå®ã¯ã©ãã¶ã¤ã®æ£®ã®ãã¤ãã¶ã¤ã³ã®éã®è£å©ãã¼ã«ã¨ãã¦ä½¿ã£ã¦ããã¨èããã®ããã£ããã§ãã
@karaage0703 å®ã¯ã¨ã³ã ããã©ãã¶ã¤ã®æ£®ã®ãã¤ãã¶ã¤ã³ã¨ãããã®ã§ãããçµµãæ¸ãæ©ä¼ãããã¾ãã¦ãç»åããããå¤æãããã¼ã«ãæ¢ãã¦ãã®ã§ãããã©ãããã£ããæ¥ããã®ããªãæ©ãã§ããã¨ããããããããã®ããã°ãè¦ã¤ããã¨ããæµãã§ããã
— kupa (@kupa_mentos) 2012å¹´11æ14æ¥
ããããªä½¿ãæ¹ããããªãã¦æ³å®ããã¦ããªãã£ãã®ã§ãã³ã£ãããã¾ããããªãã§ãã¨ã³ã ãã©ãã¶ã¤ã®æ£®ã®ãã¤ãã¶ã¤ã³ã¨ããæ©è½ã§ã¯ã32Ã32ã®ãããã«159è²ã®ãã¬ãããã15è²ãé¸ãã§ãããçµµãã¤ããã¨ã®ãã¨ããã®æ¹ã¯ãã©ããç§ã®ã½ããã§çµµãåçãããããçµµã«ããå¾ãæ¸è²å¦çãå¥ã®ã½ããã§è¡ã£ã¦ããããã®çµµãåèã«ãããçµµãæ¸ãã¨ãã使ãæ¹ããã¦ããããã§ããã
ãéè¦ããã¨ç¥ã£ã¦ãã¾ã£ãããããã¡ãã便å©ãªãã®ã«ãã¦ã¿ããã¨æãã®ã人æ
ãã©ãã¶ã¤ã®æ£®å°ç¨ã«ã«ã¹ã¿ãã¤ãºãã¦32Ã32ã®ãããçµµçæããå¾ãã©ãã¶ã¤ã®æ£®ã®ãã¬ããã®è²ã«å¯¾å¿ãã159è²ã¾ã§æ¸è²ãããå¾ãããã«åæ使ç¨å¯è½è²æ°ã§ãã15è²ã¾ã§æ¸è²ãã¦ãã©ã®ãã¬ããã®è²ã使ãã°ãããããã表ã並ã¹ã¦è¡¨ç¤ºãããããªã½ãããä½ã£ã¦ã¿ã¾ããã
ããã¡ãããã®ããã«ã¨ã³ã ãã©ãã¶ã¤ã®æ£®ããã¦ã³ãã¼ãè³¼å
¥ãããï¼ãã¬ãã¡ã®é¦¬é¹¿ééï¼
ãã¤ãã¶ã¤ã³è£å©ãã¼ã«çµæ
ãè¨èã§èª¬æããã¨ãããã«ããã®ã§å®ä¾ã示ãã¾ãã
ãå³å´ã®æ°åã¯ãã©ã®ããããã©ã®ãã¬ããè²ã«å¯¾å¿ãã¦ãããã示ãã¦ãã¾ããè²ã¨æ°åã®é¢ä¿ã¯ãとびだせどうぶつの森 マイデザインのパレット 全カラーコード公開ããåç §ãã¦ä¸ãããã¨ã³ã ãã©ãã¶ã¤ã®æ£®ãæã£ã¦ãã人ã¯ããã®æå³ããããã¯ãï¼ãã£ã¨ï¼
ãããçµµå¤æã®ããã¿
ããããçµµã«ããã¨ããã¯ããProcessingで写真や画像をドット絵に変換するソフトを作ってみましたãã§ã¤ãã£ãã½ããããã®ã¾ã¾ä½¿ç¨ãç»åã32Ã32ã«åå²ããå¾ã«ãããããã®åå²ãããã¨ãªã¢ã®è²æ
å ±ï¼RGBå¤ï¼ãå¹³ååãã¦ããã ãã§ãã
ããã®å¾ã¯æ¸è²å¦çããããªããã£ã¨æ¢ãã°ãã¾ãããæ¹æ²¢å±±ã§ã¦ããã ãã¨æã£ã¦ããã®ã§ãããäºæ³å¤ã«å¥¥ãæ·±ãåéã¿ããã§ãªããªãç°¡åã«ã§ããæ¹æ³ãç¡ãã£ãã§ããç§ãã¨ã£ãæ¹æ³ã¯ãã¾ããããçµµã®å
¨ã¦ã®ãããã«å¯¾ãã¦ããã¤ãã¶ã¤ã³ã®ãã¬ããã®ä¸çªè¿ãè²ã«å¤æãã¦ããã¾ããå¤æã«é¢ãã¦ã¯ãä¸çªããã¥ã©ãªè²è·é¢ã使ã£ãæ¹æ³ãã¨ã£ã¦ãã¾ããå
·ä½çã«ã¯ããããçµµã®ãããããã®è²æ
å ±ã(Rx,Gx,Bx)ãã©ãã¶ã¤ã®æ£®ã®ãã¤ãã¶ã¤ã³ã®ãã¬ãã159è²ã(R1,G1,B1)ã(R159,G159,B159)ã¨å®ç¾©ããã¨ããããããã®ãã¬ããã®è²ã¨ãããã®è²è·é¢ã¯ (Rx-R1)^2+(Gx-G1)^2+(Bx-B1)^2ã(Rx-R159)^2+(Gx-G159)^2+(Bx-B159)^2ã§è¡¨ããã¨ãã§ãã¦ããããä¸çªå°ãããã®ãä¸çªè¿ãè²ã¨è¦ãªãã¨ããèãæ¹ã§ãã
ã159è²ãã15è²ã®æ¸è²ã«é¢ãã¦ã¯ãã159è²ã®ä¸ã§ä¸çªä½¿ã£ã¦ãªãè²ãæ¢ãâãã®è²ã¨æãè¿ãè²ãæ¢ãâä¸çªä½¿ã£ã¦ãªãè²ããã®è²ã¨æãè¿ãè²ã¨åãè²ã«ãã¦ãããã¨ããããã»ã¹ãè²ã15è²ã«ãªãã¾ã§ç¹°ãè¿ããã¨ã§å®ç¾ãã¾ããã
ãåãããããéä¸çµéã示ãã¨ãããªæãã§ãã
ãã¾ãã¯ãã«ã«ã©ã¼ã§ãããçµµå
ã次ã«ã«ã©ã¼ãã¬ãã159è²ã«é©ç¨ããã®æç¹ã§å®ã¯50è²ç¨åº¦ã«ãªã£ã¦ãã¾ããä½è²ã«ãªããã¯å
ã®çµµã«ãã£ã¦ç°ãªãã¨æãã¾ãã
ãããã«15è²ã¾ã§è½ã¨ããçµµ
ããããçµµã®æ¸è²ã®å¹æã£ã¦æå¤ã«é¢ç½ããã®ã§ããã
ä»å¾ã®äºå®
ãå®ã¯ã¨ã³ã ãã©ãã¶ã¤ã®æ£®ããã®ãã¤ãã¶ã¤ã³ãQRã³ã¼ãã«æ¸ãåºãæ©è½ãããã¾ããQRã³ã¼ãã解æã§ããã°ããã¡ãã¡æåã§æã¡è¾¼ãã ããããçµµãåçãããããçµµã®ãã¼ã¿ãQRã³ã¼ãã§æ¸ãåºããNintendo 3DSã®ã«ã¡ã©ã§èªã¿åãã¨ããç´ æ´ãããæ©è½ãå®ç¾ã§ããã®ã§ããæéåãã§ããï¼ããã¿ããã¨ä»²è¯ããªããã¾ã§æ©è½ã使ããªãããï¼ãQRã³ã¼ã調ã¹ããçµæ§é¢ç½ãã£ãã®ã§ãè²ã
試ãã¦ã¿ãããªã¨ã
ãiPhoneã¢ããªã§ãåçæ®å½±ãããã©ãã¶ã¤ã®æ£®ç¨ã®QRã³ã¼ãæ¸ãåºãã¦ãã¢ããªåºãã°çµæ§ãããããããªãããªã¨æãã®ã§ãã¢ã¤ãã£ã¢ãããã«ç½®ãã¦ããã¾ããã好ãã«ã¢ã¤ãã£ã¢ä½¿ã£ã¦ããã®ã§ãå®æããããã£ã¨ç§ã«éã£ã¦ä¸ããã
ããã¤ãã¶ã¤ã³è£å©ãã¼ã«ã使ãæ¹
ãä¸ç®è³ªå¥ããåããããæ¬ãã¼ã«ã®ä½¿ãæ¹ã詳細ã«èª¬æãã¦ä¸ãã£ã¦ãã¾ããã画像や写真からマイデザインãï¼とびだせ どうぶつの森日記。ï¼ãããããããã®ã§ã使ãæ¹ãåãããªããã¨ãã人ã¯åç §ãã¦ä¸ãããèªåã§ãã¼ã«ä½ã£ã¦ããã¦å®ã¯ä¸åº¦ã試ãã¦ããªãã£ãã®ã§ãã»ãã¨ã«ä½¿ãã人ããã¦ä¸å®å¿ãã¦ãã¾ãï¼ç¬ï¼ãæ£ç´Windowsã§åãã®ããèªä¿¡ç¡ãã£ãã®ã§ä¸å®å¿ã
â»12/12/17 ä»ã«ããã¼ã«ä½ã£ã¦ãã人ãããã®ã§ãªã³ã¯ãã¦ããã¾ããçµæ§QRã³ã¼ãå®ç¾ãã¦ãã人沢山ãããã§ããã
ãとび森のマイデザインツールについてãï¼N氏のメモ帳ï¼
ã以ä¸ã¯ã½ã¼ã¹ã³ã¼ãã§ãã
ã½ã¼ã¹ã³ã¼ã
ãã½ã¼ã¹ã³ã¼ãå
¬éãã¾ããããã°ã©ã èªä½ã¯æ±ãã§ãããProcessingããã¦ã³ãã¼ããã¦ã³ããããã ãã§èª°ã§ãèªåãªå¥½ããªçµµãåçããï¼æéããããã°ï¼ãã¤ãã¶ã¤ã³ã¤ãããã¨ãã§ããã¯ããªã®ã§è©¦ãã¦ã¿ãã®ãããã¨æãã¾ããã¡ãªã¿ã«Processingã®ãã¼ã¸ã§ã³ã¯1.5.1ã«å¯¾å¿ãã¦ãã¾ãã®ã§æ°ãã¤ãã¦ä¸ããï¼2.0ç³»ã§ã¯åãã¾ããï¼ãã¡ãã£ã¨å¤ããã°åãã®ã§ãããµãã£ã¦ã¾ããèå³ãã人ã¯æ¹é ãã¦ã¿ã¦ä¸ããã
ã使ãæ¹ã¯ãã³ãããã¦å®è¡ããã¨ãã¤ã¢ãã°ãéãã®ã§ã好ããªç»åãã¡ã¤ã«ãé¸ãã§ä¸ãããèªåçã«çµæã表示ããã¾ãããpããæ¼ãã¨ããã°ã©ã ã¨åããã©ã«ãã«çµæã®çµµããscreenshot.jpgãã¨ãããã¡ã¤ã«åã§ä¿åããã¾ãã
â»12/12/17 ãã¬ãããã³ãã1ã¤ããã¦ããã®ãä¿®æ£ãã¾ãã
â»12/12/23 ç»é¢ã大ããããå ´å㯠final int scale = 24; ã®æ°åãå°ãããã¦ã¿ã¦ä¸ãã
PImage img0; PImage writeImg; //Window Size final int size_x = 32; final int size_y = 32; final int dotframe = 1; final int scale = 24; final int n_pallet = 159; final int max_color = 15; final int font_size = int(scale/2); float [] pallet_r = { 255, 255, 239, 255, 255, 189, 206, 156, 82, 255, 255, 222, 255, 255, 206, 189, 189, 140, 222, 255, 222, 255, 255, 189, 222, 189, 99, 255, 255, 255, 255, 255, 222, 189, 156, 140, 255, 239, 206, 189, 206, 156, 140, 82, 49, 255, 255, 222, 255, 255, 140, 189, 140, 82, 222, 206, 115, 173, 156, 115, 82, 49, 33, 255, 255, 222, 255, 255, 206, 156, 140, 82, 222, 189, 99, 156, 99, 82, 66, 33, 33, 189, 140, 49, 49, 0, 49, 0, 16, 0, 156, 99, 33, 66, 0, 82, 33, 16, 0, 222, 206, 140, 173, 140, 173, 99, 82, 49, 189, 115, 49, 99, 16, 66, 33, 0, 0, 173, 82, 0, 82, 0, 66, 0, 0, 0, 206, 173, 49, 82, 0, 115, 0, 0, 0, 173, 115, 99, 0, 33, 82, 0, 0, 33, 255, 239, 222, 206, 189, 173, 156, 140, 115, 99, 82, 66, 49, 33, 0 }; float [] pallet_g = { 239, 154, 85, 101, 0, 69, 0, 0, 32, 186, 117, 48, 85, 0, 101, 69, 0, 32, 207, 207, 101, 170, 101, 138, 69, 69, 48, 239, 223, 207, 186, 170, 138, 101, 85, 69, 207, 138, 101, 138, 0, 101, 0, 0, 0, 186, 154, 32, 85, 0, 85, 0, 0, 0, 186, 170, 69, 117, 48, 48, 32, 16, 16, 255, 255, 223, 255, 223, 170, 154, 117, 85, 186, 154, 48, 85, 0, 69, 0, 0, 16, 186, 154, 48, 85, 0, 48, 0, 16, 0, 239, 207, 101, 170, 138, 117, 85, 48, 32, 255, 255, 170, 223, 255, 186, 186, 154, 101, 223, 207, 85, 154, 117, 117, 69, 32, 16, 255, 255, 138, 186, 207, 154, 101, 69, 32, 255, 239, 207, 239, 255, 170, 170, 138, 69, 255, 255, 223, 255, 223, 186, 186, 138, 69, 255, 239, 223, 207, 186, 170, 154, 138, 117, 101, 85, 69, 48, 32, 0 }; float [] pallet_b = { 255, 173, 156, 173, 99, 115, 82, 49, 49, 206, 115, 16, 66, 0, 99, 66, 0, 33, 189, 99, 33, 33, 0, 82, 0, 0, 16, 222, 206, 173, 140, 140, 99, 66, 49, 33, 255, 255, 222, 206, 255, 156, 173, 115, 66, 255, 255, 189, 239, 206, 115, 156, 99, 66, 156, 115, 49, 66, 0, 33, 0, 0, 0, 206, 115, 33, 0, 0, 0, 0, 0, 0, 255, 239, 206, 255, 255, 140, 156, 99, 49, 255, 255, 173, 239, 255, 140, 173, 99, 33, 189, 115, 16, 49, 49, 82, 0, 33, 16, 189, 140, 82, 140, 0, 156, 0, 0, 0, 255, 255, 156, 255, 255, 173, 115, 115, 66, 255, 255, 189, 206, 255, 173, 140, 82, 49, 239, 222, 173, 189, 206, 173, 156, 115, 49, 173, 115, 66, 0, 33, 82, 0, 0, 33, 255, 239, 222, 206, 189, 173, 156, 140, 115, 99, 82, 66, 49, 33, 0 }; void setup() { size(size_x*scale*2+dotframe, size_y*scale); println("select photo."); String imgPath = selectInput(); img0 = loadImage(imgPath); textSize(font_size); background(0,0,0); writeImg = createGraphics(size_x*scale, size_y*scale, P2D); } int CountColor(int[] pallet, int n) { int cont = 0; int []pallet_cnt = new int[n]; for (int i=0; i < n; i++) { pallet_cnt[i] = 0; for (int j= 0; j < size_x*size_y; j++) { if (pallet[j] == i) { pallet_cnt[i]++; } } } for (int i=0; i < n; i++) { if (pallet_cnt[i] > 0) { cont++; } } return cont; } void draw() { img0.loadPixels(); // Making Image----- float[] img_r = new float[img0.width*img0.height]; float[] img_g = new float[img0.width*img0.height]; float[] img_b = new float[img0.width*img0.height]; float[] img16_r = new float[size_x*size_y]; float[] img16_g = new float[size_x*size_y]; float[] img16_b = new float[size_x*size_y]; int[] img16_pallet = new int[size_x*size_y]; for (int i = 0; i < img0.width*img0.height; i++) { color tmp_color = img0.pixels[i]; img_r[i] = red(tmp_color); img_g[i] = green(tmp_color); img_b[i] = blue(tmp_color); } int div_x = int(img0.width / size_x); int div_y = int(img0.height / size_y); float tmp_r; float tmp_g; float tmp_b; // make dot image for (int i = 0; i < size_x*size_y; i++) { tmp_r = 0; tmp_g = 0; tmp_b = 0; int tmp_y = int(i / size_x); int tmp_x = i - size_x*tmp_y; for (int j = 0; j < div_x; j++) { for (int k = 0; k < div_y; k++) { tmp_r += img_r[tmp_x*div_x + tmp_y*img0.width*div_y+ j + k*img0.width]; tmp_g += img_g[tmp_x*div_x + tmp_y*img0.width*div_y+ j + k*img0.width]; tmp_b += img_b[tmp_x*div_x + tmp_y*img0.width*div_y+ j + k*img0.width]; } } tmp_r = tmp_r/(div_x*div_y); tmp_g = tmp_g/(div_x*div_y); tmp_b = tmp_b/(div_x*div_y); img16_r[i] = tmp_r; img16_g[i] = tmp_g; img16_b[i] = tmp_b; } writeImg.loadPixels(); // matching pallet for (int i = 0; i < size_x*size_y; i++) { float []tmp_color_distance = new float[n_pallet]; for (int j= 0; j < n_pallet; j++) { tmp_color_distance[j] = (img16_r[i] - pallet_r[j])*(img16_r[i] - pallet_r[j]) + (img16_g[i] - pallet_g[j])*(img16_g[i] - pallet_g[j]) + (img16_b[i] - pallet_b[j])*(img16_b[i] - pallet_b[j]); } float tmp_color_min = tmp_color_distance[0]; img16_pallet[i] = 0; for (int j= 1; j < n_pallet; j++) { if (tmp_color_min > tmp_color_distance[j]) { tmp_color_min = tmp_color_distance[j]; img16_pallet[i] = j; } } } // reduce pallet while (CountColor (img16_pallet, n_pallet) > max_color) { int []pallet_cnt = new int[n_pallet]; for (int i=0; i < n_pallet; i++) { pallet_cnt[i] = 0; for (int j= 0; j < size_x*size_y; j++) { if (img16_pallet[j] == i) { pallet_cnt[i]++; } } } int min_colornumb = 0; int first_cnt=0; int min_tmp = 0; while (pallet_cnt[first_cnt] == 0) { first_cnt++; } int min_colorcnt = pallet_cnt[first_cnt]; for (int i=first_cnt; i < n_pallet; i++) { if (min_colorcnt > pallet_cnt[i] && pallet_cnt[i] > 0) { min_tmp = 1; min_colorcnt = pallet_cnt[i]; min_colornumb = i; } } float min_colordist = 0; int neardist_colornumb = 0; if (min_tmp == 0) { min_colornumb = first_cnt; int tmp_cnt = first_cnt+1; while (pallet_cnt[tmp_cnt] == 0) { tmp_cnt++; } min_colordist = (pallet_r[min_colornumb]-pallet_r[tmp_cnt])*(pallet_r[min_colornumb]-pallet_r[tmp_cnt]) + (pallet_g[min_colornumb]-pallet_g[tmp_cnt])*(pallet_g[min_colornumb]-pallet_g[tmp_cnt]) + (pallet_b[min_colornumb]-pallet_b[tmp_cnt])*(pallet_b[min_colornumb]-pallet_b[tmp_cnt]); neardist_colornumb = tmp_cnt; } else { min_colordist = (pallet_r[min_colornumb]-pallet_r[first_cnt])*(pallet_r[min_colornumb]-pallet_r[first_cnt]) + (pallet_g[min_colornumb]-pallet_g[first_cnt])*(pallet_g[min_colornumb]-pallet_g[first_cnt]) + (pallet_b[min_colornumb]-pallet_b[first_cnt])*(pallet_b[min_colornumb]-pallet_b[first_cnt]); neardist_colornumb = first_cnt; } for (int i=first_cnt; i < n_pallet; i++) { if (pallet_cnt[i] > 0 && i != min_colornumb) { float tmp_dist = (pallet_r[min_colornumb]-pallet_r[i])*(pallet_r[min_colornumb]-pallet_r[i]) + (pallet_g[min_colornumb]-pallet_g[i])*(pallet_g[min_colornumb]-pallet_g[i]) + (pallet_b[min_colornumb]-pallet_b[i])*(pallet_b[min_colornumb]-pallet_b[i]); if (min_colordist > tmp_dist) { min_colordist = tmp_dist; neardist_colornumb = i; } } } for (int i=0; i < size_x*size_y; i++) { if (img16_pallet[i] == min_colornumb) { img16_pallet[i] = neardist_colornumb; } } } // pallet update for (int i = 0; i < size_x*size_y; i++) { img16_r[i] = pallet_r[img16_pallet[i]]; img16_g[i] = pallet_g[img16_pallet[i]]; img16_b[i] = pallet_b[img16_pallet[i]]; } // scaling dot image for (int i = 0; i < size_x*size_y; i++) { int tmp_y = int(i / size_x); int tmp_x = i - size_x*tmp_y; for (int j = 0; j < scale; j++) { for (int k = 0; k < scale; k++) { writeImg.pixels[tmp_y*size_x*scale*scale+tmp_x*scale+j*size_x*scale+k] = color(img16_r[i], img16_g[i], img16_b[i]); } } } writeImg.updatePixels(); image(writeImg, 0, 0, size_x*scale, size_y*scale); // draw pallet number for (int x = 0; x < size_x; x++) { for (int y = 0; y < size_y; y++) { String tx = str(img16_pallet[y*size_x+x]+1); fill(255,255,255); textAlign(CENTER); text(tx, size_x*scale+(x+0.5)*scale, (y+0.5)*scale); } } // draw frame for (int x = 0; x < size_x*2+1; x++) { stroke(255); strokeWeight(dotframe); line(x*scale, 0, x*scale, size_y*scale); } for (int y = 0; y < size_y+1; y++) { stroke(255); strokeWeight(dotframe); line(0, y*scale-dotframe, size_x*scale*2+1, y*scale-dotframe); } } void keyPressed() { // save image if (key == 'p' || key == 'P') { save("screenshot.jpg"); println("screen saved."); } // exit if (key == ' ') { exit(); } }
é¢é£è¨äº
å¤æ´å±¥æ´
- 2020/03/21 ãã¤ã¾ãã©ãã¶ã¤ã®æ£®ã«é¢ãã¦è¿½è¨