Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                const setting = {
  cricleNum: 20, // オブジェクトの総数
  cx: 0, // 中心点xの座標位置
  cy: 0, // 中心点yの座標位置
  h: 100, // 円の半径
  angle: 0.01 // 円全体の角度
};

// dat.GUI を使うための準備
const gui = new dat.GUI();
gui.add(setting, 'angle', 0, 1);
gui.add(setting, 'h', 0, window.innerHeight);
gui.add(setting, 'CirclesNum', 1, 40).step(1);
gui.add(setting, 'cx', 0, window.innerWidth).listen();
gui.add(setting, 'cy', 0, window.innerHeight).listen();

// 最初に実行される処理
function setup() {
  createCanvas(windowWidth, windowHeight); // ウィンドウのサイズでキャンバスを作る
  setting.cx = width / 2; // x軸の中心座標を求めて setting.cx に代入する
  setting.cy = height / 2; // y軸の中心座標を求め
}

// 毎フレームごとに実行される処理
function draw() {
  clear(); // 前のフレームで描画されているものをクリアする
  background('rgba(76,141,161,1)'); // 背景を塗りつぶす
  noStroke(); // 線を描画しない
  fill("rgb(254,240,195)"); // 塗りつぶしの色指定

  [...new Array(setting.cricleNum)].forEach((_, i) => {
    const _rad = i / setting.cricleNum * PI * 2 + setting.angle; //  現在の円のインデックス / 円の総数 * 2π + 円全体の角度
    const x = setting.h * cos(_rad) + setting.cx; // x座標を求める
    const y = setting.h * sin(_rad) + setting.cy; // y座標を求める
    ellipse(x, y, 10, 10); // 円を描画する
  })
}
              
            
!
999px

Console