{"id":3853,"date":"2019-03-16T21:07:20","date_gmt":"2019-03-16T12:07:20","guid":{"rendered":"https:\/\/greentown.tokyo\/?p=3853"},"modified":"2019-03-31T08:19:35","modified_gmt":"2019-03-30T23:19:35","slug":"10minutes-go17","status":"publish","type":"post","link":"https:\/\/greentown.tokyo\/?p=3853","title":{"rendered":"10\u5206GO 17\u65e5\u76ee"},"content":{"rendered":"<p>\u4eca\u65e5\u306f\u3001\u30c6\u30fc\u30de\u30d5\u30ea\u30fc\u306e\u3082\u304f\u3082\u304f\u4f1a\u306b\u3044\u3063\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>13:00 &#8211; 19:00 \u304f\u3089\u3044\u307e\u3067\u3082\u304f\u3082\u304f\u3002<\/p>\n<p>\u53c2\u52a0\u8005\u306f\u3001\u30a4\u30f3\u30d5\u30e9\u30a8\u30f3\u30b8\u30cb\u30a2\u304b\u3089\u3001Unity\u3067\u30b2\u30fc\u30e0\u3084VR\u30a2\u30d7\u30ea\u4f5c\u3063\u3066\u3044\u308b\u4eba\u3001\u30a2\u30ec\u30af\u30b5\u30b9\u30ad\u30eb\u3084\u3063\u3066\u3044\u308b\u4eba\u3001\u3068\u3055\u307e\u3056\u307e\u3067\u3057\u305f\u3002<\/p>\n<p>\u4e00\u7dd2\u306e\u5e2d\u306b\u3044\u305f\u67d0\u30e1\u30fc\u30ab\u30fc\u306e\u30d5\u30eb\u30b9\u30bf\u30c3\u30af\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u4eba\u304c\u3001\u304a\u4ed5\u4e8b\u7247\u624b\u9593\u306b\u3001\u56f0\u3063\u3066\u308b\u4eba\u306e\u305f\u3081\u306b\u4f5c\u3063\u3066\u3044\u308b\u30a2\u30d7\u30ea\u304c\u7d20\u6674\u3089\u3057\u304b\u3063\u305f\u306e\u3067\u3057\u305f\u3002\u79c1\u3082\u65e9\u901f\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u3002\u30e6\u30fc\u30b6\u30fc\u3068\u4e00\u7dd2\u306b\u306a\u3063\u3066\u4f5c\u3063\u3066\u3044\u304d\u305f\u3044\u305d\u3046\u3067\u3001\u5fd7\u3082\u7d20\u6575\u3067\u611f\u52d5\u3057\u307e\u3057\u305f\u3002\u30a2\u30d7\u30ea\u306e\u30ea\u30ea\u30fc\u30b9\u30bf\u30a4\u30df\u30f3\u30b0\u306b\u3064\u3044\u3066\u3068\u304b\u3001\u3044\u307e\u767a\u751f\u3057\u3066\u3044\u308b\u969c\u5bb3\u306b\u5bfe\u3057\u3066\u610f\u898b\u6b32\u3057\u3044\u306a\u3093\u3066\u8a00\u308f\u308c\u3066\u3001\u304a\u5f79\u306b\u7acb\u3066\u305f\u3088\u3046\u3067\u826f\u304b\u3063\u305f\u3067\u3059\u3002\u4eba\u306e\u5f79\u306b\u7acb\u3066\u308b\u3063\u3066\u5b09\u3057\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30ea\u30b5\u30b8\u30e5\u30fc\u56f3\u5f62\uff08\u30ea\u30b5\u30b8\u30e5\u30fc\u66f2\u7dda\uff09<\/h2>\n<p>\u4e92\u3044\u306b\u76f4\u4ea4\u3059\u308b\u4e8c\u3064\u306e\u70b9\u304c\u632f\u52d5\u3057\u306a\u304c\u3089\u8ecc\u8de1\u3092\u63cf\u304f\u56f3\u5f62\u306e\u3053\u3068\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>GO<\/h2>\n<p>API\u306e\u7d9a\u304d\u3092\u3057\u3088\u3046\u304b\u3068\u601d\u3063\u305f\u3051\u3069\u3001\u4eca\u65e5\u306f\u3053\u3063\u3061\u2193<\/p>\n<h3>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9eGo<\/h3>\n<h6>GIF\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3<\/h6>\n<pre class=\"lang:go decode:true\">package main\r\n\r\nimport (\r\n\t\"image\"\r\n\t\"image\/color\"\r\n\t\"image\/gif\"\r\n\t\"io\"\r\n\t\"math\"\r\n\t\"math\/rand\"\r\n\t\"os\"\r\n\t\"time\"\r\n)\r\n\r\n\/\/ color.White, color.Bloack \u306f image\/color\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u5c5e\u3057\u3066\u3044\u308b\r\n\/\/ []color.Color{...} \u30b3\u30f3\u30dd\u30b8\u30c3\u30c8\u30ea\u30c6\u30e9\u30eb\u3002\r\n\/\/     Go\u306e\u30b3\u30f3\u30dd\u30b8\u30c3\u30c8\u578b\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3059\u308b\u305f\u3081\u306e\u7c21\u6f54\u306a\u8868\u8a18\r\n\/\/     \u8981\u7d20\u306e\u5024\u306e\u4e26\u3073\u304b\u3089\u751f\u6210\u3055\u308c\u308b\uff08\u3053\u306e\u5834\u5408\u306f\u30b9\u30e9\u30a4\u30b9\uff09\r\nvar palette = []color.Color{color.White, color.Black}\r\n\r\nconst (\r\n    whiteIndex = 0\r\n    blackIndex = 1\r\n)\r\n\r\nfunc main() {\r\n\trand.Seed(time.Now().UTC().UnixNano())\r\n\tlissajous(os.Stdout)\r\n}\r\n\r\nfunc lissajous(out io.Writer) {\r\n\tconst (\r\n\t\tcycles = 5    \/\/ \u5468\u56de\u306e\u6570\r\n\t\tres = 0.001\r\n\t\tsize = 100\r\n\t\tnframes = 64  \/\/ \u30d5\u30ec\u30fc\u30e0\u6570\r\n\t\tdelay = 8     \/\/ \u9045\u5ef6\r\n\t)\r\n\tfreq := rand.Float64() * 3.0\r\n\t\/\/ []gif.GIF{...} \u30b3\u30f3\u30dd\u30b8\u30c3\u30c8\u30ea\u30c6\u30e9\u30eb\u3002\r\n\t\/\/     Go\u306e\u30b3\u30f3\u30dd\u30b8\u30c3\u30c8\u578b\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3059\u308b\u305f\u3081\u306e\u7c21\u6f54\u306a\u8868\u8a18\r\n\t\/\/     \u8981\u7d20\u306e\u5024\u306e\u4e26\u3073\u304b\u3089\u751f\u6210\u3055\u308c\u308b\uff08\u3053\u306e\u5834\u5408\u306f\u69cb\u9020\u4f53\uff09\r\n\tanim := gif.GIF{LoopCount: nframes}\r\n\tphase := 0.0\r\n\tfor i := 0; i &lt; nframes; i++ {\r\n\t\trect := image.Rect(0,0, 2*size+1, 2*size+1)\r\n\t\timg := image.NewPaletted(rect, palette)\r\n\t\tfor t := 0.0; t &lt; cycles*2*math.Pi; t += res {\r\n\t\t\tx := math.Sin(t)\r\n\t\t\ty := math.Sin(t*freq + phase)\r\n\t\t\timg.SetColorIndex(size + int(x*size+0.5), size+int(y*size+0.5), blackIndex)\r\n\t\t}\r\n\t\tphase += 0.1\r\n\t\tanim.Delay = append(anim.Delay, delay)\r\n\t\tanim.Image = append(anim.Image, img)\r\n\t}\r\n\tgif.EncodeAll(out, &amp;anim) \/\/ \u30a8\u30f3\u30b3\u30fc\u30c9\u30a8\u30e9\u30fc\u3092\u7121\u8996\r\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u30d3\u30eb\u30c9<\/p>\n<pre class=\"lang:default decode:true\">$ go build ch1-lissajous.go\r\n$ ls\r\nREADME.md               ch1-dup1.go             ch1-dup3.go             ch1-lissajous           dup2.txt\r\nch1--di.go              ch1-dup2.go             ch1-echo1.go            ch1-lissajous.go        go\r\n<\/pre>\n<p>ch1-lissajous \u3063\u3066\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u304c\u3067\u304d\u3066\u3044\u308b\u306e\u3067<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \">$ .\/ch1-lissajous &gt; out.gif<\/pre>\n<p>\u5b9f\u884c\uff06\u51fa\u529b\u7d50\u679c\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u5410\u304f\u3002<\/p>\n<p><a href=\"https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/03\/out.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3858\" src=\"https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/03\/out.gif\" alt=\"\" width=\"201\" height=\"201\" \/><\/a><\/p>\n<p>\u52d5\u3044\u3066\u308b\u301c\uff01\uff01<\/p>\n<p>&nbsp;<\/p>\n<h6>\u7df4\u7fd2\u554f\u984c1.5<\/h6>\n<blockquote><p>\u3082\u3063\u3068\u3082\u3089\u3057\u304f\u3059\u308b\u305f\u3081\u306b\u3001\u30ea\u30b5\u30b8\u30e5\u30fc\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u30ab\u30e9\u30fc\u30d1\u30ec\u30c3\u30c8\u3092\u80cc\u666f\u3092\u9ed2\u3068\u3057\u3066\u7dd1\u306e\u7dda\u306b\u306a\u308b\u3088\u3046\u306b\u4fee\u6b63\u3057\u306a\u3055\u3044\u3002\u30a6\u30a7\u30d6\u30ab\u30e9\u30fc #RRGGBB \u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b color.BGBA{0xRR, 0xGG, 0xBB, 0xFF} \u3092\u4f7f\u3044\u306a\u3055\u3044\u3002<\/p><\/blockquote>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u80cc\u666f\u3092\u30c1\u30a7\u30f3\u30b8\u3057\u3066\u307f\u308b<\/p>\n<p>var palette = []color.Color{color.White, color.Black}<br \/>\n\u2193<br \/>\nvar palette = []color.Color{color.Black, color.White}<\/p>\n<p><a href=\"https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/03\/out2.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3861\" src=\"https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/03\/out2.gif\" alt=\"\" width=\"201\" height=\"201\" \/><\/a><\/p>\n<p>\u306a\u3093\u304b\u3001\u9055\u3046\uff1f\u3042\u3063\u3066\u308b\uff1f<\/p>\n<pre class=\"lang:default decode:true\">\/*\r\nvar palette = []color.Color{color.Black, color.White}\r\n*\/\r\nvar palette = []color.Color{\r\n\tcolor.RGBA{0x00, 0x00, 0x00, 0xFF},\r\n\tcolor.RGBA{0x00, 0xFF, 0x00, 0xFF},\r\n}<\/pre>\n<p>\u66f8\u304d\u63db\u3048\u3066\u3001\u5b9f\u884c<\/p>\n<p><a href=\"https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/03\/out3.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3867\" src=\"https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/03\/out3.gif\" alt=\"\" width=\"201\" height=\"201\" \/><\/a><\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u30fb\u30fb<\/p>\n<p>&nbsp;<\/p>\n<h6>\u7df4\u7fd2\u554f\u984c1.6<\/h6>\n<blockquote><p>\u30ea\u30b5\u30b8\u30e5\u30fc\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4fee\u6b63\u3057\u3066palette\u306b\u3082\u3063\u3068\u5024\u3092\u8ffd\u52a0\u3057\u3001\u4f55\u3089\u304b\u306e\u8208\u5473\u6df1\u3044\u65b9\u6cd5\u3067 SetColorIndex \u306e\u7b2c\uff13\u5f15\u6570\u3092\u5909\u66f4\u3057\u3066\u8907\u6570\u306e\u8272\u3067\u753b\u50cf\u3092\u751f\u6210\u3059\u308b\u3088\u3046\u306b\u3057\u306a\u3055\u3044\u3002<\/p><\/blockquote>\n<p>SetColorIndex\u3092\u8aad\u3093\u3067\u307f\u308b\u3002<\/p>\n<pre class=\"lang:go decode:true\">func (p *Paletted) SetColorIndex(x, y int, index uint8) {\r\n    if !(Point{x, y}.In(p.Rect)) {\r\n        return\r\n    }\r\n    i := p.PixOffset(x, y)\r\n    p.Pix[i] = index\r\n}<\/pre>\n<p>\u3088\u30fb\u30fb\u8aad\u3081\u306a\u3044\u3057\uff01<\/p>\n<p>\u632b\u6298\u30fb\u30fb\u7d42\u4e86\uff01\uff01<\/p>\n<p>&nbsp;<\/p>\n<h6>\u8ffd\u8a18<\/h6>\n<p>func (p *Paletted) \u3053\u306e\u90e8\u5206\u3066\u4f55\u3088\u30fb\u30fb\u3068\u601d\u3063\u3066\u3001\u304a\u4e16\u8a71\u306b\u306a\u3063\u3066\u3044\u308b\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u306b\u6295\u3052\u3066\u307f\u305f\u3068\u3053\u308d\u3001\u3054\u56de\u7b54\u3044\u305f\u3060\u3051\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/tour.golang.org\/methods\/4\">https:\/\/tour.golang.org\/methods\/4<\/a><\/p>\n<p>\u30ec\u30b7\u30fc\u30d0\u30fc\u3068\u3044\u3046\u3089\u3057\u3044<\/p>\n<blockquote><p>Go\u3067\u306f\u3001\u7279\u5b9a\u306e\u578b\u306b\u95a2\u9023\u3065\u3051\u3089\u308c\u305f\u95a2\u6570\u3092\u300c\u30e1\u30bd\u30c3\u30c9\u300d\u3068\u547c\u3076<br \/>\n\u307e\u305f\u3001\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3055\u308c\u308b\u5bfe\u8c61(\u578b)\u306e\u3053\u3068\u3092\u300c\u30ec\u30b7\u30fc\u30d0\u300d\u3068\u547c\u3076<\/p><\/blockquote>\n<p>\u69cb\u9020\u4f53+\u30ec\u30b7\u30fc\u30d0\u30fc\uff08\u306e\u95a2\u6570\uff09\u30fb\u30fb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3067\u3044\u3046\u30af\u30e9\u30b9\u307f\u305f\u3044\u306a\u30e2\u30ce\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u304a\u308f\u308a<\/h2>\n<p>\u5bdd\u4e0d\u8db3\uff06\u4e0d\u7720\u304c\u7d9a\u3044\u3066\u3001\u3061\u3087\u3063\u3068\u4f53\u8abf\u304c\u60aa\u3044\u3067\u3059\u3002<\/p>\n<p>\u30e1\u30f3\u30bf\u30eb\u9762\u3082\u3088\u308d\u3057\u304f\u306a\u3044\u3002\u8f9b\u3044\u30fb\u30fb<\/p>\n<p>\u3053\u3053\uff12\u3001\uff13\u30f6\u6708\u30b5\u30dc\u3063\u3066\u305f\u00a0\u82d3\u6842\u672e\u7518\u6e6f \u3092\u98f2\u3093\u3060\u3002<\/p>\n<p>\u4eca\u65e5\u3053\u305d\u65e9\u304f\u5bdd\u3088\u3046\u3002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u306f\u3001\u30c6\u30fc\u30de\u30d5\u30ea\u30fc\u306e\u3082\u304f\u3082\u304f\u4f1a\u306b\u3044\u3063\u3066\u304d\u307e\u3057\u305f\u3002 13:00 &#8211; 19:00 \u304f\u3089\u3044\u307e\u3067\u3082\u304f\u3082\u304f\u3002 \u53c2\u52a0\u8005\u306f\u3001\u30a4\u30f3\u30d5\u30e9\u30a8\u30f3\u30b8\u30cb\u30a2\u304b\u3089\u3001Unity\u3067\u30b2\u30fc\u30e0\u3084VR\u30a2\u30d7\u30ea\u4f5c\u3063\u3066\u3044\u308b\u4eba\u3001\u30a2\u30ec\u30af\u30b5 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":3948,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[95],"tags":[],"class_list":["post-3853","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-golang"],"_links":{"self":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/3853"}],"collection":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3853"}],"version-history":[{"count":19,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/3853\/revisions"}],"predecessor-version":[{"id":3878,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/3853\/revisions\/3878"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/media\/3948"}],"wp:attachment":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}