惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Troy Hunt's Blog
F
Fortinet All Blogs
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
The Register - Security
The Register - Security
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
V
Vulnerabilities – Threatpost
S
Securelist
S
SegmentFault 最新的问题
T
Threat Research - Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Privacy International News Feed
S
Schneier on Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
GbyAI
GbyAI
Apple Machine Learning Research
Apple Machine Learning Research
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
美团技术团队
Cyberwarzone
Cyberwarzone
C
Cisco Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google Online Security Blog
Google Online Security Blog
M
MIT News - Artificial intelligence
U
Unit 42
V
V2EX
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
B
Blog
博客园 - 叶小钗
Attack and Defense Labs
Attack and Defense Labs
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - Franky
Engineering at Meta
Engineering at Meta
Schneier on Security
Schneier on Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
IT之家
IT之家
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
Martin Fowler
Martin Fowler
SecWiki News
SecWiki News

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
同樣是 50 行程式碼,為什麼做出來的東西像藝術品?
張旭豐 · 2026-06-28 · via DEV Community

張旭豐

先玩再說

這是做出來會長這樣——看到那些「會呼吸」的漸層了嗎?不是漸變,是雜訊。但看起來像是有生命的流體。

為什麼?

別人做出來像藝術品,你做出來像數學作業

p5.js 有兩個 noise()

// 壞掉的 noise(直線)
ellipse(x, noise(x)*height, 10, 10);  // 看起來像鋸齒

// 會呼吸的 noise(加時間)
ellipse(x, noise(x, frameCount*0.01)*height, 10, 10);  // 看起來像海草

差別只有一個維度:時間

加上 frameCount 這件事,多數教學都有講。但多數教學沒講的是:同樣是 50 行,為什麼做出來像藝術品而不是像「證明我會用 noise 函式」?

秘密一:視覺幻覺——你的大腦在幫視覺「加工」

看這張圖:

●●●●●●●●●●●●●●●●●●●●
●●●●○○○○●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●

你看到什麼?

多數人說「一條線」。但實際上那只是一群各自獨立的點,大腦自動幫你連起來了。

這叫視覺幻覺——沒有意義的訊號,大腦自動幫你補上結構和意圖。

TeamLab 就是用這個原理:500 個各自輕微不同步的簡單元素,大腦把它們當成「一片會呼吸的森林」。

秘密二:讓變化「慢一點開始」——看起來自然多了

「慢慢亮」「慢慢暗」比「立刻亮立刻暗」感覺自然,為什麼?

因為現實世界裡東西改變速度很少是均勻的。一盞燈關掉的時候,是先快後慢——不是線性勻速。

不是線性的:

  • brightness = distance(線性:均勻變化,感覺像機器)
  • brightness = t * (2 - t)(快開始,慢結束,感覺像真的)

人眼對「一開始快、然後慢下來」的速度變化特別有感覺,因為這跟我們在物理世界遇到的情況一致。

function easeOutQuad(t) {
  return t * (2 - t);  // 簡單的緩出公式
}

做出來(一):基礎流體場

let particles = [];

function setup() {
  createCanvas(windowWidth, windowHeight);
  for (let i = 0; i < 300; i++) {
    particles.push({
      x: random(width),
      y: random(height),
      speed: random(0.8, 1.5)
    });
  }
}

function draw() {
  background(255, 253, 250);  // 暖白,不是純白

  for (let p of particles) {
    // 正確的 flow field:用粒子真實位置算 noise
    let noiseScale = 0.005;
    let angle = noise(p.x * noiseScale, p.y * noiseScale, frameCount * 0.004) * TWO_PI * 2;

    p.x += cos(angle) * p.speed;
    p.y += sin(angle) * p.speed;

    // 繞圈回來
    if (p.x < 0) p.x = width;
    if (p.x > width) p.x = 0;
    if (p.y < 0) p.y = height;
    if (p.y > height) p.y = 0;

    // 日系啞色
    let col = noise(p.x * 0.01, p.y * 0.01, frameCount * 0.008);
    fill(60 + col*40, 80 + col*30, 100 + col*60, 150);
    noStroke();
    ellipse(p.x, p.y, 4, 4);
  }
}

為什麼看起來像藝術品?

  1. 暖白底色background(255, 253, 250) 不是純白,是紙張的顏色
  2. 啞色粒子RGB(60-100, 80-110, 100-160) 不是鮮豔的藍或紅,是日本寺廟感的光
  3. 300 個粒子:數量夠多,大腦就會開始「出戲」——把機械過程詮釋成生命

做出來(二):加分項——滑鼠互動

function mouseMoved() {
  for (let p of particles) {
    let d = dist(mouseX, mouseY, p.x, p.y);
    if (d < 100) {
      // 滑鼠靠近時,粒子被推開
      let angle = atan2(p.y - mouseY, p.x - mouseX);
      p.x += cos(angle) * (100 - d) * 0.05;
      p.y += sin(angle) * (100 - d) * 0.05;
    }
  }
}

這段加上去,畫面從「動態壁布」變成「活的空間」——滑鼠變成一種存在感。

做出來(三):再加一個維度——顏色也跟著變

把以下函式加到前面的程式碼下面,就能在同一個粒子系統裡同時控制位置和顏色:

function displayParticle(p) {
  // 用粒子的真實位置算 noise(與上方 flow field 共用同一套三維 noise 空間)
  let n = noise(p.x*0.01, p.y*0.01, frameCount*0.008);

  // 日系啞色系:低對比、有灰度
  let r = 80 + n * 80;    // 80-160
  let g = 100 + n * 60;   // 100-160
  let b = 120 + n * 60;   // 120-180
  let a = 100 + n * 100;  // 透明度也有漸層

  fill(r, g, b, a);
  noStroke();

  // 粒子大小也呼吸
  let size = 3 + sin(frameCount*0.05 + p.x * 0.1) * 2;
  ellipse(p.x, p.y, size, size);
}

然後在 draw() 迴圈裡,每次畫完位置呼叫 displayParticle(p) 就能著色。

為什麼日系美學做出來的東西看起來比較貴?

因為低對比、灰階、有「餘韻」的顏色,大腦不會覺得被「攻擊」,反而願意停留在上面。這就是 TeamLab 每個展都排隊的原因之一——視覺不疲勞。

完整程式碼

// p5.js Noise Flow Field — 日系啞光版本
// 50行以內,做出像藝術品的流體視覺效果

let particles = [];
const NUM = 300;

function setup() {
  createCanvas(windowWidth, windowHeight);
  colorMode(RGB, 255, 255, 255, 255);

  for (let i = 0; i < NUM; i++) {
    particles.push({
      x: random(width),
      y: random(height),
      speed: random(0.8, 1.5)
    });
  }
}

function draw() {
  // 暖白底(紙張色,不是純白)
  background(255, 253, 250);

  for (let p of particles) {
    // noise 三維:x, y, time — 用粒子真實位置算
    let noiseScale = 0.005;
    let angle = noise(p.x * noiseScale, p.y * noiseScale, frameCount * 0.004) * TWO_PI * 2;

    p.x += cos(angle) * p.speed;
    p.y += sin(angle) * p.speed;

    // 從左邊出去的從右邊回來
    if (p.x < 0) p.x = width;
    if (p.x > width) p.x = 0;
    if (p.y < 0) p.y = height;
    if (p.y > height) p.y = 0;

    // 日系啞色(低對比、灰藍調)
    let n = noise(p.x * 0.01, p.y * 0.01, frameCount * 0.008);
    let c = 90 + n * 70;
    fill(c + 10, c + 30, c + 60, 120);
    noStroke();

    // 大小也呼吸
    let sz = 3 + sin(frameCount * 0.03 + p.x * 0.1) * 1.5;
    ellipse(p.x, p.y, sz, sz);
  }
}

function mouseMoved() {
  for (let p of particles) {
    let d = dist(mouseX, mouseY, p.x, p.y);
    if (d < 120) {
      let angle = atan2(p.y - mouseY, p.x - mouseX);
      let force = (120 - d) * 0.04;
      p.x += cos(angle) * force;
      p.y += sin(angle) * force;
    }
  }
}

為什麼這個做起來「貴」?

  1. 視覺幻覺:300 個各自輕微不同步的粒子 = 大腦說「這是活的」
  2. 日系啞光:不是RGB(0,0,255),是 RGB(90,120,180) 這種「看得到情緒」的藍
  3. 讓變化有節奏:大小變化用 sin(),不是線性——看起來像呼吸,不像閃爍
  4. 滑鼠存在:不是點擊,是「靠近就離開」的空間感

下一步

想更有 Fu?試試:

  1. NUM 從 300 改成 800——數量多到一個程度,視覺會從「一群點」變成「一種物質」
  2. 把顏色從「灰藍」改成「暖橙→深褐」漸層——馬上從「北歐極簡」變成「昭和復古」
  3. 加入超聲波感測器——讓實際的「人在空間中移動」驅動粒子方向

最後一個方向,就是我們下一篇文章的主題。