Products
Features
YouTube Video Summarizer
Summarize YouTube videos
Web & PDF Highlighter
Highlight web pages & PDFs
Chat with PDF
Ask any PDF questions with AI
Ask AI Clone
Chat with your highlights & memories
Audio Transcriber
Transcribe audio files to text
Glasp Reader
Read and highlight articles
Kindle Highlight Export
Export your Kindle highlights
Idea Hatch
Hatch ideas from your highlights
Integrations
Obsidian Plugin
Notion Integration
Pocket Integration
Instapaper Integration
Medium Integration
Readwise Integration
Snipd Integration
Hypothesis Integration
Apps & Extensions
Chrome Extension
Safari Extension
Edge Add-ons
Firefox Add-ons
iOS App
Android App
Discover
Discover
Ideas
Discover new ideas and insights
Articles
Curated articles and insights
Books
Book recommendations by great minds
Posts
Essays and notes from readers
Quotes
Inspiring quotes collection
Videos
Curated videos and summaries
Explore Glasp
Glasp Story
How we grew from 0 to 3 million users
Glasp Newsletter
Weekly insights and updates
Glasp Talk
Interview series with great minds
Glasp Blog
Latest news and articles
Glasp Use Cases
Learn how others use Glasp
Build & Support
Glasp API
Access Glasp's API for developers
MCP Connector
Connect Glasp to Claude & ChatGPT
Community
Glasp Reddit Community
Students
Student discount and benefits
FAQs
Frequently Asked Questions
AboutPricing
DashboardLog inSign up

2.4: random() Function - p5.js Tutorial

91.7K views
•
May 20, 2021
by
The Coding Train
YouTube video player
2.4: random() Function - p5.js Tutorial

TL;DR

Learn how to use the random function in p5JS to create dynamic and varied sketches easily.

Transcript

Welcome back to another video about variables, but not really. So in this video, I to help you use your variables in a different way. So most of the examples that you've seen, there's not a lot to them in terms of their design and their variability. This circle will always be white. It will always be the same size. Maybe, hopefully, you've been pla... Read More

Key Insights

  • 👻 The random function in p5JS generates random numbers between a specified range, allowing for variability in sketches.
  • 🏃 Initializing variables with random values in setup helps create dynamic visuals that change with each run of the sketch.
  • 💱 Using the random function in draw can result in continuously changing visuals, suitable for creating animations with random elements.
  • 🎨 The random function is essential for parametric design and creating random patterns in sketches.
  • 🪟 Leveraging system variables like width, height, window width, and window height in p5JS can simplify coding and adapt to different canvas sizes.
  • 👤 Combining the random function with user interactions can enhance the creative possibilities in p5JS sketches.
  • 🥺 Experimenting with random colors, sizes, and positions can lead to unique and innovative visual outcomes in p5JS sketches.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: What is the random function in p5JS, and how does it work?

The random function in p5JS is used to generate random numbers between a specified minimum and maximum value. It is essential for creating dynamic and varied visual elements in sketches.

Q: How can you initialize variables with random values in a p5JS sketch?

To initialize variables with random values in p5JS, you need to use the random function within the setup function. This ensures that the variables are assigned random values at the beginning of the sketch.

Q: What are some practical examples of using the random function in p5JS sketches?

Practical examples of using the random function in p5JS include varying the size, color, and position of shapes, creating dynamic patterns, and adding randomness to visual elements like circles and squares.

Q: How does using the random function in draw differ from using it in setup in p5JS?

When using the random function in draw in p5JS, the values generated by the random function change continuously, resulting in dynamic visuals that update with each frame. This can be useful for creating animations with random elements.

Summary & Key Takeaways

  • Introduces the concept of using the random function in p5JS to generate different values for variables.

  • Demonstrates how to initialize variables with random values in setup to create dynamic visuals.

  • Explores examples of using the random function to create random sizes, colors, and positions in sketches.


Read in Other Languages (beta)

English

Share This Summary 📚

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Explore More Summaries from The Coding Train 📚

How to Create Fractal Patterns with Toothpicks thumbnail
How to Create Fractal Patterns with Toothpicks
The Coding Train
9.4: Genetic Algorithm: Looking at Code - The Nature of Code thumbnail
9.4: Genetic Algorithm: Looking at Code - The Nature of Code
The Coding Train
Coding Challenge #116: Lissajous Curve Table thumbnail
Coding Challenge #116: Lissajous Curve Table
The Coding Train
Text Generation using Spell with Nabil Hassein thumbnail
Text Generation using Spell with Nabil Hassein
The Coding Train
8.1: Fractals - The Nature of Code thumbnail
8.1: Fractals - The Nature of Code
The Coding Train
Classifying Poses with ml5.js Part 2 thumbnail
Classifying Poses with ml5.js Part 2
The Coding Train

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Apps & Extensions

  • Chrome Extension
  • Safari Extension
  • Edge Add-ons
  • Firefox Add-ons
  • iOS App
  • Android App

Key Features

  • YouTube Video Summarizer
  • Web & PDF Summarizer
  • Web & PDF Highlighter
  • Chat with PDF
  • Ask AI Clone
  • Audio Transcriber
  • Glasp Reader
  • Kindle Highlight Export
  • Idea Hatch

Integrations

  • Obsidian Plugin
  • Notion Integration
  • Pocket Integration
  • Instapaper Integration
  • Medium Integration
  • Readwise Integration
  • Snipd Integration
  • Hypothesis Integration

More Features

  • APIs
  • MCP Connector
  • Blog & Post
  • Embed Links
  • Image Highlight
  • Personality Test
  • Quote Shots
  • Open Graph Checker

Company

  • About us
  • Our Story
  • Blog
  • Community
  • FAQs
  • Job Board
  • Newsletter
  • Pricing
Terms

•

Privacy

•

Guidelines

© 2026 Glasp Inc. All rights reserved.