Perlin snakes

博客展示了相似参数下几种噪声的效果对比,包括perlin2、perlin3、simplex2、simplex3的效果,这是个动态绘制过程,还给出了效果来源链接,代码虽古老但仍可用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

noise perlin

相似参数下几种噪声的效果对比:

在这里插入图片描述
这是个动态的绘制过程

perlin2的效果
在这里插入图片描述

perlin3的效果
在这里插入图片描述

simplex2的效果:
在这里插入图片描述

simplex3的效果
在这里插入图片描述

<body>
	<div class="centerbox">
	  <canvas width="1440" height="900"></canvas>
	  <input type="button" value="Save">
	</div>
	<script src="./Perlin snakes_files/perlin.js"></script>
	<script src="./Perlin snakes_files/p.js"></script>
</body>
// Generated by CoffeeScript 1.3.3
var TAU, button, canvas, ctx, draw, f, fpselem, h, p1, particles, period, raf, w, _i;
canvas = document.getElementsByTagName('canvas')[0];
fpselem = document.getElementById('fps');
w = canvas.width = 1440;
h = canvas.height = 900;
TAU = 2 * Math.PI;
ctx = canvas.getContext('2d');
period = 1 / 800;
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = 'rgba(1,1,1,0.3)';
noise.seed(Math.random());
particles = [];
for (_i = 1; _i <= 200; _i++) {
  p1 = {
    x: Math.random() * w,
    y: h / 2 + Math.random() * 50,
    a: 0
  };
  particles.push(p1);
  particles.push({
    x: p1.x,
    y: p1.y,
    a: TAU / 2
  });
}
draw = function() {
  var a, p, v, _j, _len, _results;
  _results = [];
  for (_j = 0, _len = particles.length; _j < _len; _j++) {
    p = particles[_j];
    v = noise.perlin2(p.x * period, p.y * period);
    ctx.fillStyle = "hsla(" + (Math.floor(v * 360)) + ", 95%, 20%, 0.05)";
    ctx.fillRect(p.x, p.y, 1.5, 1.5);
    p.h++;
    a = v * 2 * Math.PI + p.a;
    p.x += Math.cos(a);
    _results.push(p.y += Math.sin(a));
  }
  return _results;
};
raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
  return window.setTimeout(callback, 1000 / 60);
};

button = document.getElementsByTagName('input')[0];

button.onclick = function() {
  return window.open(canvas.toDataURL('image/png'));
};

f = function() {
  raf(f);
  return draw();
};

raf(f);

来源:https://josephg.com/perlin/3/
代码很古老,但是能用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

X01动力装甲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值