Warp Images with Particles

  Рет қаралды 5,370

Barney Codes

Barney Codes

Күн бұрын

Пікірлер: 12
@BarneyCodes
@BarneyCodes 2 жыл бұрын
Be sure to check out my other P5js videos: kzbin.info/aero/PLlaA0JvEhcG8kb6x-Cc3RM5JMjq4ribQ5 What would you like to see me do in the next video?
@ChaseRiesterer-c4e
@ChaseRiesterer-c4e Жыл бұрын
What if the particles keep sliding off of the canvas after we hover over it?
@BarneyCodes
@BarneyCodes Жыл бұрын
Good question! You should be able to use the constrain() function to make sure the particles position stays inside the screen (use 0 for the low value and width or height for the high value depending on which axis, x or y, you're constraining. You can read more on the constrain function here: p5js.org/reference/#/p5/constrain Hope that helps! Let me know if you have any more questions!
@zeroalpha_nz
@zeroalpha_nz 2 жыл бұрын
Hey Barney, cheers for this. Great tutorial and well presented. can this be done with a shape I already have in a class instead of a image? I want to place the particles so they replace the shape
@BarneyCodes
@BarneyCodes 2 жыл бұрын
Thanks so much, and that's a great question! The way I'd probably approach this is to use createGraphics (p5js.org/reference/#/p5/createGraphics) which essentially creates a new canvas that you can draw your shape onto, but won't actually be seen on the screen. You can then use this graphics object (after you've drawn your shape onto it) the exact same way that I use the image in video. Let me know how you go, and if you have any more questions I'm more than happy to answer them!
@kiwis2923
@kiwis2923 8 ай бұрын
Hi Barney, is there a way to do this for moving particles being repelled by the mouse?
@BarneyCodes
@BarneyCodes 8 ай бұрын
I think my first ever video on this channel did something similar to this. The general idea is the same, where the proximity to the mouse influences a particle, but instead of having a "home" position that the particle is trying to reach, they just have a velocity that they use to move around. The velocity can then just be pushed in a direction away from the mouse if the particle gets too close. Hope that helps!
@theman7050
@theman7050 2 жыл бұрын
Nice Barney. But I think you could have used P5's in-built vector.heading() function to get the angle between points, instead of atan2(). Am I right?
@BarneyCodes
@BarneyCodes 2 жыл бұрын
You definitely could use the heading() function! I believe that it gets the angle between a vector and the origin though, so you'd still have to do a bit of fiddling around to get the angle between two vectors. Something like: let angle = p5.Vector.sub(v1, v2).heading(); Probably just comes down to a matter of preference, good suggestion though!
@theman7050
@theman7050 2 жыл бұрын
@@BarneyCodes thanks for that snippet. Yeah I am not familiar with the use of tan/atan in p5 as no tutorials exclusively exist that I know of, so I depend on in-built functions. Great vid again, mate. :)
@BarneyCodes
@BarneyCodes 2 жыл бұрын
No worries, glad you enjoyed the video! Both tan and atan are just things I remember from maths at school, if you wanted to learn more I highly recommend this video: kzbin.info/www/bejne/eoHJqZ2Ha9ikqMU There's a section dedicated to angles, but there's a lot more great information in there too! Once you're comfortable with the concepts, using the functions in p5 will become second nature.
@theman7050
@theman7050 2 жыл бұрын
@@BarneyCodes thx very much.
How to Draw a Mandala in Java + Processing
15:57
Barney Codes
Рет қаралды 2 М.
Coding Challenge 166: ASCII Text Images
22:42
The Coding Train
Рет қаралды 1,1 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Easy Perlin Noise Flow Fields
10:22
Barney Codes
Рет қаралды 36 М.
Beginner's Guide to Shader Distortion Techniques
17:03
Barney Codes
Рет қаралды 9 М.
Fixing the REALTIME terrain shadows using YOUR suggestions!
8:40
Barney Codes
Рет қаралды 72 М.
Generative Vasarely with P5js
16:10
Shaun Wegscheid
Рет қаралды 14 М.
Rasterize 3D (Processing Tutorial)
23:40
tim rodenbröker creative coding
Рет қаралды 89 М.
19: Clipping Function in p5.js: How to Code Generative Art
9:13
Steve's Makerspace
Рет қаралды 1,1 М.
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,5 МЛН
3 Hours vs. 3 Years of Blender
17:44
Isto Inc.
Рет қаралды 7 МЛН
Learn flexbox the easy way
34:04
Kevin Powell
Рет қаралды 742 М.
Code an Audio Visualizer in p5js (from scratch) | Coding Project #17
19:37
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН