こんにちは、たやち(tayati369)です。
p5.jsでコーディングしています。
PCD@Tokyoさんの「デイリーコーディングチャレンジ」!!に素人極まりない私も参加しております。
毎日できるかわからないけれど、リモートワークのこのご時世、通勤分の時間があるでチャレンジしていきます。(デイリーとはw)
36日目のテーマは「ヤマタノオロチ」。
5月3日〜5月5日まで事情があり、参加できませんでしたが今日から再開いたします!
8つの頭がこちらを凝視する様子をイメージして作りました。なんとなく、1匹ずつ個性を出してあげたくて色に少し変化をつけてあげています。ただ、鋭い眼光は同じ赤色にして、常にこちらを見ている感じを出しています。
背景と、大蛇の体の色は実行するごとに変わるようになっています。
では、ごらんあれ〜。
var yamatanooroti = []; function setup(){ createCanvas(500, 500); colorMode(HSB, 360, 100, 100, 100); background(random(114,165) ,100, 30 ,100); for (let i = 0; i < 8; i++) { yamatanooroti[i] = new Oroti; } noLoop(); } function draw(){ for (let i = 0; i < yamatanooroti.length; i++) { push(); translate(width/2 - random(-150, 150), 0); stroke(random(166,181), 100, random(10,30), 100); yamatanooroti[i].show(); pop(); } } class Oroti{ constructor(){ this.x = 0; this.y = height; this.w = 0; this.length = random(70, 350); this.wave = random(20, 40); noFill(); strokeWeight(25); this.a = random(1); } show(){ beginShape(); for (let i = 0; i < this.length; i+=0.1) { if (this.a < 0.5) { this.x = 50 * cos(i/this.wave); } this.x = 50 * sin(i/this.wave); this.y =height - i; vertex(this.x, this.y); } endShape(); push(); fill(341, 100, 50, 100); circle(this.x , this.y, 40); pop(); } }
ではでは、さようなら〜〜〜。
なにかあればTwitterまで。
コメント