Coding Challenge 183: Paper Marbling Algorithm

  Рет қаралды 57,503

The Coding Train

The Coding Train

Күн бұрын

All aboard as I attempt to simulate the artistic process of paper marbling. The algorithm is based on the paper 'Mathematical Marbling' by S. Lu, A. Jaffer, X. Jin, H. Zhao, and X. Mao. The code is written in JavaScript using the p5.js library. Code: thecodingtrain.com/challenges...
🚀 Watch this video ad-free on Nebula nebula.tv/videos/codingtrain-...
p5.js Web Editor Sketches:
🕹️ Mathematical Marbling: editor.p5js.org/codingtrain/s...
🕹️ Dodecahedron: editor.p5js.org/codingtrain/s...
🕹️ Marbling Phyllotaxis: editor.p5js.org/codingtrain/s...
🕹️ Marbling Mouse: editor.p5js.org/codingtrain/s...
🕹️ Marbling Color: editor.p5js.org/codingtrain/s...
🕹️ Marbling Combs: editor.p5js.org/codingtrain/s...
🕹️ Marbling Raster Pixels: editor.p5js.org/codingtrain/s...
🕹️ Marbling Raster Pixels - Image: editor.p5js.org/codingtrain/s...
🕹️ Marbling Raster Pixels - Video: editor.p5js.org/codingtrain/s...
🕹️ Marbling Color - animate ink: editor.p5js.org/codingtrain/s...
🕹️ handPose Marbling: editor.p5js.org/codingtrain/s...
🎥 Previous: • Coding Challenge 182: ...
🎥 All: • Coding Challenges
References:
🔗 Paper Marbling: en.wikipedia.org/wiki/Paper_m...
🔗 Tokutaro Yagi: suminagashi.com/meet-the-arti...
🔗 Digital Marbling: blog.amandaghassaei.com/2022/...
📄 Mathematical Marbling: doi.org/10.1109/MCG.2011.51
🔗 Mathematical Marbling: people.csail.mit.edu/jaffer/M...
Videos:
🎥 The Hydrodynamics of Marbling Art: gfm.aps.org/meetings/dfd-2023...
🎥 • 3.4 Polar Coordinates ...
Related Coding Challenges:
🚂 • Coding Challenge #56: ...
🚂 • Coding Challenge 102: ...
🚂 • Coding Challenge #132:...
🚂 • Coding Challenge 177: ...
Timestamps:
0:00 Introduction
1:47 Mathematical Marbling
2:16 Explain approach
3:20 Start Coding
4:20 Dropping paint
7:03 Add the circle vertices using polar coordinates
10:57 Add a marble function
13:24 Refine the algorithm
16:45 Add a tine function
19:46 Circle detail
24:50 Generalize the tine function
29:43 Possible variations
31:45 Outro
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
🚂 Website: thecodingtrain.com/
👾 Share Your Creation! thecodingtrain.com/guides/pas...
🚩 Suggest Topics: github.com/CodingTrain/Sugges...
💡 GitHub: github.com/CodingTrain
💬 Discord: thecodingtrain.com/discord
💖 Membership: kzbin.infojoin
🛒 Store: standard.tv/codingtrain
🖋️ Twitter: / thecodingtrain
📸 Instagram: / the.coding.train
🎥 • Coding Challenges
🎥 • Start learning here!
🔗 p5.js: p5js.org
🔗 p5.js Web Editor: editor.p5js.org/
🔗 Processing: processing.org
📄 Code of Conduct: github.com/CodingTrain/Code-o...
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
#mathematicalmarbling #fluidsimulation #p5js #javascript

Пікірлер: 110
@samuelgunter
@samuelgunter 21 күн бұрын
I've been subscribed since watching the snake coding challenge back in 2016 riding home from school, and now I'm at a university, I see we're still forgetting the "this dots" 😅
@maxwellhunt3732
@maxwellhunt3732 19 күн бұрын
Some things never change
@watchnarutoshippuden3228
@watchnarutoshippuden3228 10 күн бұрын
Haha I came here to comment exactly this
@lbgstzockt8493
@lbgstzockt8493 21 күн бұрын
This video is a great example for why single-letter variable names are a bad idea.
@lowellrindler9454
@lowellrindler9454 20 күн бұрын
You’ll never take my garbage variable names from me!
@WhateverOwO
@WhateverOwO 20 күн бұрын
as long as they work and you put a comment besides it it'll be fine lol
@qwerty_qwerty
@qwerty_qwerty 20 күн бұрын
@@WhateverOwO God, please do not suggest that to anyone. Ever. It's okay if it's a solo project with old code that you don't want to touch, but don't _suggest_ it to people!
@jeanlasalle2351
@jeanlasalle2351 20 күн бұрын
​@@WhateverOwOWhy put a comment saying what it is instead of naming it? Have fun with "int a; //smoothing factor" And adding insult to injury intellisense will be worthless when you call your function which is accepting a variable of type int named a.
@krccmsitp2884
@krccmsitp2884 20 күн бұрын
@@WhateverOwO With self-explanatory names you don't need extra comments
@djtomoy
@djtomoy 21 күн бұрын
Every time I watch the intro to one of these videos it feels like you have access to a different version of the internet than me, one filled with wonder, creativity and beauty. 😢
@AryehS1989
@AryehS1989 21 күн бұрын
some of the best content on YT!
@jasonoconner7863
@jasonoconner7863 3 күн бұрын
That historical artistic context at the start is gold. Great video!
@justinfahland1225
@justinfahland1225 19 күн бұрын
programming alongside you and trying to work out these challenges in python has reinvigorated my motivation for programming as a hobby again. Its really exciting recreating the things you make in your videos and I'm finally finding programming fun again, keep up the good work
@RedHair651
@RedHair651 14 күн бұрын
What's your equivalent of P5.js?
@sontapaa11jokulainen94
@sontapaa11jokulainen94 13 күн бұрын
@@RedHair651 I am not the one you originally asked, but I myself use pythons turtle library to draw this stuff. You need to implement some stuff yourself, which exists as a builtin in p5js (for example in python you need to program the main drawing loop yourself), but it is quite good still in my opinion.
@motbus3
@motbus3 18 күн бұрын
This still is the best channel about programming ever. You gotta love Dan ❤
@RicoGalassi
@RicoGalassi 21 күн бұрын
This has got to be the coolest coding train videos yet!! Awesome Dan!
@jaydeep-p
@jaydeep-p 21 күн бұрын
Hands down, you're the best coding channel!
@ForrestLowe-ez6is
@ForrestLowe-ez6is 21 күн бұрын
Coding Bob Ross
@Apchenail
@Apchenail 21 күн бұрын
First video I look at since many years (of the "purple rain coding challenge generation"). The pacing of your video is much more dynamic now, I am sure the young brains are even more attracted by it.
@vavassor
@vavassor 21 күн бұрын
Years ago I tried to make a fluid sim for marbling. I had a flow sim and was trying to make things more incompressible by reducing diffusion using "back and forth error correction and compensation". Which helped the ink not mix together into grey/brown as quickly. But didn't have that thick ink look. Using vector shapes looks fantastic! And the raster method is cool too. Now I wanna revisit this idea
@TheCodingTrain
@TheCodingTrain 18 күн бұрын
I hope you do!
@aniketmehendale
@aniketmehendale 16 күн бұрын
i used to watch your channel when i was in college, i came across this video randomly. glad to see youre still at it, ah the nostalgia
@HeadmostCantaloupe
@HeadmostCantaloupe 21 күн бұрын
You gotta love the new editing style with distinctive intros and all of that fancy stuff
@tunaroll3957
@tunaroll3957 21 күн бұрын
This is so genuis and showcases how much P5 can accomplish, combined w math!
@MauroGrizia
@MauroGrizia 20 күн бұрын
I'm sometimes absolutely marveled at the amount of science that's being put into art to create this amazing patterns. I just saw a minute of this video and I already made up my mind. I'm soooo following this tutorial.
@realcygnus
@realcygnus 21 күн бұрын
Back on the scene with ordinary old school challenges ! 💪
@clearwavepro100
@clearwavepro100 13 күн бұрын
Excellent explanation of the formula! Super accessible :)
@AndersonChristianPurigringo
@AndersonChristianPurigringo 14 күн бұрын
Cara, vc é fera demais. gosto muito dos seus conteudo e a sua forma alegre de compartilha.
@theminivann
@theminivann 21 күн бұрын
Oh snap this is my first coding train video that I'm catching on release day, HI DAN THANK YOU FOR BEING AWESOME
@fabiomartins1218
@fabiomartins1218 20 күн бұрын
You have no idea how many times I tried to do this, Daniel. Thank you oh-so-much!
@elmeromero8761
@elmeromero8761 20 күн бұрын
I just started studying Computer Engineering on College and it has been kinda rough, a lot of stress and there has been times that I've thought about droping out. But then I found your videos and my love for programming came back. I just wanted to say thank you for making programming seem so fun and interesting to me again!!!
@TheCodingTrain
@TheCodingTrain 18 күн бұрын
I believe in you!
@forgey9211
@forgey9211 21 күн бұрын
I'm here for you 😊 Another beautiful video
@matcha69420
@matcha69420 21 күн бұрын
yay just in time for my bus commute!
@onkelhoy1
@onkelhoy1 20 күн бұрын
Dan as always, thank you for your video, I love listen, watch you struggle in whatever the exciting task you take open yourself meanwhile I struggle on my own work/projects etc
@TiferetJackson
@TiferetJackson 6 күн бұрын
That's amazing at first I thought it impossible yet you made it look so easy! 😮
@esphix
@esphix 21 күн бұрын
The reason for the magSq function being better to use is because it is just the dot product of a vector with itself. This is due to the magnitude being computed using the Pythagorean theorem which uses a square root, which is an expensive operation. By immediately calling the magnitude squared function you remove the need to compute the sqrt.
@BarneyCodes
@BarneyCodes 20 күн бұрын
Amazing video as always! This one was so much fun!
@ZerofeverOfficial
@ZerofeverOfficial 21 күн бұрын
immiscible, my new favorite word
@raulAlbiyol
@raulAlbiyol 21 күн бұрын
Why Are you so Awesome? Keeping making such videos.. Love from INDIA❤
@HansMilling
@HansMilling 18 күн бұрын
Long time follower. This reminds me so much of making graphics demos on my Amiga and later PC. It was all about creating cool effects.
@reid_makes_art
@reid_makes_art 21 күн бұрын
Great aesthetic!
@DipamSen
@DipamSen 21 күн бұрын
Very cool video!! PS: After having watched many OOP tutorials, at 2:31 i totally expected the two "properties" to be "centre" and "radius" 😅
@tedhinklater3203
@tedhinklater3203 19 күн бұрын
I don't even code but your enthusiasm is pretty infectious and I do love the art
@umitsn
@umitsn 16 күн бұрын
Great example, thanks so much 🙏🏻
@mrkjsmt
@mrkjsmt 17 күн бұрын
Thanks so much!! I'd love more of these oldskool graphics challenges, please, please!!
@leonardopotenza7379
@leonardopotenza7379 21 күн бұрын
u are the best Dan
@mmilerngruppe
@mmilerngruppe 21 күн бұрын
that's really an awesome video! thank you a lot.
@jaybee2530
@jaybee2530 21 күн бұрын
This is fantastic, great work! This also makes me feel very dumb. 😅
@SimpleCarGuy
@SimpleCarGuy 20 күн бұрын
Can you do a tutorial on how to always be happy, enthusiastic and so positive!? Love the videos!
@andreestermeneses5615
@andreestermeneses5615 18 күн бұрын
You are the best!
@marcospaulolima642
@marcospaulolima642 19 күн бұрын
Damn, insane video! ❤
@TheCatull
@TheCatull 13 күн бұрын
Danke!
@ethanhermsey
@ethanhermsey 21 күн бұрын
Ooh this is really cool! I've unsuccesfully been trying to get something like the immiscible drops, definitely trying this out :) hhmm.. tine lines from flowfields
@xotmatrix
@xotmatrix 20 күн бұрын
Super interesting.
@wlockuz4467
@wlockuz4467 3 күн бұрын
The Bob Ross of coding.
@DivineIntervention-12
@DivineIntervention-12 9 күн бұрын
2.5 thousand likes and 0 dislikes is incredibly uncommon XD keep it up
@WinterSolsticeGaming
@WinterSolsticeGaming 20 күн бұрын
Cool Vid
@yousifmobark6981
@yousifmobark6981 19 күн бұрын
i love this channel
@chichongc
@chichongc 20 күн бұрын
Oh! I found I really like this algo~
@bluegamemc1403
@bluegamemc1403 20 күн бұрын
no clue what this means but I still clicked right away
@outside8312
@outside8312 21 күн бұрын
Kinda want to try water marbling my nails again now... But it will probably end badly 😅💅
@paultapping9510
@paultapping9510 21 күн бұрын
that would totally work! enamel is hydrophobic, so as long as you masked your fingers off you could use hydrodipping.
@TheCodingTrain
@TheCodingTrain 18 күн бұрын
Please share if you do!
@sangwookim5551
@sangwookim5551 19 күн бұрын
Hi Daniel! I am a huge fan of your works and even made my own generative art NFTs using p5.js following your tutorials! Just wondering though, what are your thoughts on AI art, and how it may impact the value of human-made art in the coming years? Do you think the current art(including generative art) will retain its value when AI could make them just as good, if not better? :)
@zylascope
@zylascope 20 күн бұрын
Cool!
@flashbond
@flashbond 21 күн бұрын
That's a Turkish art called "Ebru". I guess the English phonetic will be Abrou
@HarDarkable
@HarDarkable 20 күн бұрын
Long time since This dot Song!
@StayMotivate-or7rf
@StayMotivate-or7rf 7 күн бұрын
Hello sir you are doing great work for our community,but I have a humble request please make video on maths learning topics which are important to become AI and ml engineer with proper guidance and free learning resources and full roadmap of learning mathematics please sir ! 🙏🙏 But thanks for your hardwork😊.
@subinaypanda9936
@subinaypanda9936 20 күн бұрын
We can have a relation between the radius and the circleDetails like higher the radius, higher will be circleDetails.
@TheCodingTrain
@TheCodingTrain 18 күн бұрын
Yes, this is a great idea!
@limboreversible
@limboreversible 15 күн бұрын
Hi, this is amazing. Is there a version in processing code of this coding challenge ? I'm totally Stuck with the marble function:-( Thanks again Mr. Schifman for your continuous inspiration
@daviddawkins
@daviddawkins 19 күн бұрын
I watched this at x1.25 by mistake and now I don't think I can sleep
@TheCodingTrain
@TheCodingTrain 18 күн бұрын
if you watch it backwards at 0.75x it'll cure you
@daviddawkins
@daviddawkins 18 күн бұрын
@@TheCodingTrain I forgot to add that I loved the video.
@at-2974
@at-2974 17 күн бұрын
Could a generalized tine line still function effectively without relying on the dot product? Instead, could it exclusively use vertical tine line, achieved by rotating shapes to align the vertical tine line at the desired location, and then rotating the shapes back to their original angles?
@NoVIcE_Source
@NoVIcE_Source 19 күн бұрын
lovely
@gutzimmumdo4910
@gutzimmumdo4910 11 күн бұрын
hi coding train, i saw a cool pattern and i was wondering if u could program such a thing, is called "cohomology fractals", seems quite cool of a visual but also kinda complex maybe.
@nguyenlevlog4586
@nguyenlevlog4586 20 күн бұрын
good
@RajJaiswal538
@RajJaiswal538 19 күн бұрын
Any idea how the smoother version of it would work? Should I just interpolate it from older position to newer position with time?
@TheCodingTrain
@TheCodingTrain 18 күн бұрын
That's an interesting idea to try! I did it by adding multiple smaller blobs of the same color slowly, it's not efficient or optimal but seems to work. Maybe removing blobs that are fully enclosed would help? You can see all the example and variations on the webpage linked in the description.
@RajJaiswal538
@RajJaiswal538 18 күн бұрын
@@TheCodingTrain thanks! Will check them
@RandomEG1234
@RandomEG1234 18 күн бұрын
please help, my variable will not save, and i need it to stay the same when i re run it
@dhairyashah3104
@dhairyashah3104 16 күн бұрын
make a video on queuing theory please
@000aleph
@000aleph 20 күн бұрын
So do we have incompressibility?
@egebayraktar6620
@egebayraktar6620 13 күн бұрын
adamsın kralsın
@SquareRootOfNegativeOne
@SquareRootOfNegativeOne 18 күн бұрын
Does the java code exist for Processing? I tried converting it myself and I can't get it to work. Probably because I don't know what I'm doing....
@SquareRootOfNegativeOne
@SquareRootOfNegativeOne 18 күн бұрын
never mind. figured it out - learned a couple things too!!
@TheCodingTrain
@TheCodingTrain 18 күн бұрын
I haven't been keeping up with porting the examples, but you are welcome to add to github.com/CodingTrain/Coding-Challenges/
@SquareRootOfNegativeOne
@SquareRootOfNegativeOne 16 күн бұрын
@@TheCodingTrain I put up what I got but I can't help but feel like I shouldn't be the one doing it - I'm self taught and there may be errors. It would be amazing though if I could get some feedback though...
@bobweiram6321
@bobweiram6321 20 күн бұрын
Imagine applying this in real time to reality through Apple's Vision Pro Goggles.
@pierremarcotte6299
@pierremarcotte6299 16 күн бұрын
Dumb guy here... what part in the code guarantees that the area of a drop is always equal?
@jthawken123
@jthawken123 20 күн бұрын
Ah yes, the inside cover page of the hymnal.
@geoffwagner4935
@geoffwagner4935 15 күн бұрын
holy cowsay , I actually got magSq();
@alvarobyrne
@alvarobyrne 20 күн бұрын
Kwel!
@planktonfun1
@planktonfun1 16 күн бұрын
its not fluid enough
@gsestream
@gsestream 20 күн бұрын
less is more you know. one is enough. do you be lacking marbles. God be your only marble. of great worth. dont sell it to anyone. localized intersection fluid sim is not expensive. you can either do a octree space division or just 3d range sorting intersection algorithm. or just the falling sand simulation but using liquid/gas pressure local small steps simulation. just like life simulator. nothing is a problem. all pre-solved. even those that you have not solved. honor to God. not to knowledge. even if God knows everything. you say you are miscible. you said "I am miscible". who do you mix with in the pot. fluid sim is like neutral net drift training by evolutionary algorithm. it will settle in some balance after simple optimization steps. minimum (proton) sized dots self-arranging neural fluid matrix. the fluid dots approximate the whole fluid in the mass. you can also derive your own fluid pixel algorithm of other type. physical or not. well if each pixel/cell can hold only hold one fluid unit then you have the algorithm working principles. the more and smaller the simulated drop cells are, the better and heavier (gpu) the simulation is. graphically making the drops overlap makes a continuous fluid in all places necessary, using smaller area for sphere/circle drop collision. there are no other drops. you dropped your marbles. time will tell. lol only a bit insane. stay sane dr. so you make a gpu object of circle shape and push it around. hmh. deformation. not dot simulation at low scale. instead of using the deformation graphics function directly, maybe do the low level simulation yourself. also interesting. the underlying tech code I mean. seems like deformation math lib is being used heavily. oh you actually do the small drops simulation. my bad. drink drink. coffee makes depressed drops. wow dude. nice trip bro. photoshop finger tool for paint drops. maf. the paint must be a leaner. paint water foundation simulator. no sell.
@user-gs7vk6sw9y
@user-gs7vk6sw9y 20 күн бұрын
its nearly impossible to follow your video if you are always zooming in for now reason.
@AtomicBl453
@AtomicBl453 20 күн бұрын
watch this at 0.25 speed, thank me later.
@danielrubio2746
@danielrubio2746 18 күн бұрын
You are the best!
Coding Challenge #116: Lissajous Curve Table
27:57
The Coding Train
Рет қаралды 113 М.
Coding Challenge 182: Apollonian Gasket Fractal
56:48
The Coding Train
Рет қаралды 74 М.
когда одна дома // EVA mash
00:51
EVA mash
Рет қаралды 13 МЛН
Did you find it?! 🤔✨✍️ #funnyart
00:11
Artistomg
Рет қаралды 114 МЛН
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
Coding Challenge 181: Weighted Voronoi Stippling
28:59
The Coding Train
Рет қаралды 148 М.
Making Tiger Eye Marbled Paper
8:52
Four Keys Book Arts
Рет қаралды 78 М.
Better Mountain Generators That Aren't Perlin Noise or Erosion
18:09
Josh's Channel
Рет қаралды 256 М.
Coding Challenge 179: Elementary Cellular Automata
21:41
The Coding Train
Рет қаралды 140 М.
The Most Underrated Concept in Number Theory
28:00
Combo Class
Рет қаралды 99 М.
We should use this amazing mechanism that's inside a grasshopper leg
19:19
Coding Adventure: Simulating Fluids
47:52
Sebastian Lague
Рет қаралды 1,6 МЛН
What Gear Shape Meshes With a Square?
31:17
Morphocular
Рет қаралды 312 М.