Paintutils APIã使ã£ã¦å³å½¢ãæãã
ã¯ããã«
前回ã®èª¬æã§ã¿ã¼ããã«ç»é¢ã«ç¹ãæããç·ãå¼ããé·æ¹å½¢ãæãã¾ããã
ãããã®æç»ãéãã¦åºæ¬çãªåçãç解ã§ããã¨æãã®ã§ãä»åã¯æ¥½ãããæ¹æ³ãç´¹ä»ãã¾ãããã
Paintutils API
æ¨æºã§ç¨æããã¦ããPaintutilsãAPIã¯ãç»åãåãæ±ããç¹ãæããç·ãå¼ãããã®ä¾¿å©ãªé¢æ°ãç¨æãã¦ãã¾ãã
ããã§ã¯ãã®ä¸ãã以ä¸ã®2ã¤ã®é¢æ°ãç°¡åã«ç´¹ä»ãã¾ãããã
paintutils.drawPixel(X座æ¨, Y座æ¨, è²)
- ã¿ã¼ããã«ç»é¢ä¸ã§ãæå®ãã座æ¨ã«ãæå®ããè²ã§ç¹ãæãã
ãµã³ãã«ã³ã¼ã
--座æ¨(2,2)ã«éè²ã§ç¹ãæã paintitls.drawPixel(2,2,colors.blue)
å®è¡çµæ
paintutils.drawLine(å§ç¹X座æ¨, å§ç¹Y座æ¨, çµç¹X座æ¨, çµç¹Y座æ¨, è²)
- ã¿ã¼ããã«ç»é¢ä¸ã§ãå§ç¹åº§æ¨ããçµç¹åº§æ¨ã¾ã§ãæå®ããè²ã§ç·ãå¼ãã
ãµã³ãã«ã³ã¼ã
-- (2,2)ãã(11,11)ã¾ã§éãç·ãå¼ã paintutils.drawLine(2,2,11,11, colors.blue)
å®è¡çµæ
åè§å½¢ãæããµã³ãã«ããã°ã©ã
ãããã®é¢æ°ã使ã£ã¦ãå³å½¢ãæãã¦ã¿ã¾ãã
åè§å½¢ï¼æ ï¼
ã¾ãã¯ãåè§å½¢ã®æ ã ãæãã¦ä¸ãå¡ãã¤ã¶ããªãããã°ã©ã ã§ãã
å·¦ä¸ã®å§ç¹(2,2)ããå³ä¸ã®çµç¹(11,11)ã¨ããéãåè§å½¢ãæãã¾ããä¸ã¯å¡ãã¤ã¶ãã¾ããã
åç´ã«æ ã¨ãªã4æ¬ã®ç·ãå¼ãã¦ããã ãã§ããã·ã³ãã«ã
ãµã³ãã«ã³ã¼ã
-- ### function function drawFrame(startX, startY, endX, endY, color) paintutils.drawLine(startX,startY,endX,startY, color) -- ä¸ã®æ¨ªæ£ paintutils.drawLine(endX,startY,endX,endY, color) -- å³ã®ç¸¦æ£ paintutils.drawLine(startX,startY,startX,endY, color) -- å·¦ã®ç¸¦æ£ paintutils.drawLine(startX,endY,endX,endY, color) -- ä¸ã®æ¨ªæ£ end -- ### main drawFrame(2,2,11,11, colors.blue)
å®è¡çµæ
åè§å½¢ï¼å¡ãã¤ã¶ãï¼
次ã¯ä¸ãå¡ãã¤ã¶ãå ´åã§ãã
å·¦ä¸ã®å§ç¹(2,2)ããå³ä¸ã®çµç¹(11,11)ã¨ããéãåè§å½¢ãæãã¾ãã
ãµã³ãã«ã³ã¼ã
-- ### function function drawRectangle(startX, startY, endX, endY, color) for y=startY, endY do paintutils.drawLine(startX,y,endX,y, color) end end -- ### main drawRectangle(2,2,11,11, colors.blue)
åç´ã«ã横ç·ã10æ¬å¼ãã¦ããã ãã§ãã
å®è¡çµæ
drawLine()ã使ãã¨ãã®æ³¨æ
å§ç¹ã¨çµç¹ãæå®ããã ãã§ç·ãå¼ããã¨ãã§ããé¢æ°ãªã®ã§ãããä¸ã¤ã ãå¼±ç¹ãããã¾ãã
ããã¯ãæãç·ãæ±ããã¨ã§ãã
ããã¯ãã¿ã¼ããã«ç»é¢ä¸ã®ç»ç´ æ°ãå°ãªãæç»ãç²ããã¨ãåå ãªã®ã§ä»æ¹ãªãã®ã§ããã
æç·ãå¼ãã¨ãã¯æ³¨æãã¾ãããã
ã¾ã¨ã
ã¿ã¼ããã«ç»é¢ã§ç¹ãæããç·ãå¼ã
- Paintutils APIã®ãdrawPixel()ãdrawLine()ãé¢æ°ã¯ä¾¿å©ã§ãã
- ã¿ã¼ããã«ç»é¢ã®ç»ç´ æ°ãå°ãªãç²ãããã«ãæãç·ã¯ã©ããã¦ãæ±ããªããã¡ã§ãã