nannou icon indicating copy to clipboard operation
nannou copied to clipboard

Port the Nature of Code examples over to run in Nannou

Open JoshuaBatty opened this issue 6 years ago • 5 comments

In order to both test the capabilities of nannou and it's API, and launch with some ridiculously handy tricks for users to reference, let's port of the Nature of Code examples written by Daniel Shiffman in Processing.

Below are a list of examples by chapter that i'll tick off and leave notes as I go.

Chapter 1: Vectors

  • [x] NOC_1_1_bouncingball_novectors
  • [x] NOC_1_2_bouncingball_vectors
  • [x] NOC_1_2_bouncingball_vectors_object
  • [x] NOC_1_3_vector_subtraction
  • [x] NOC_1_4_vector_multiplication
  • [x] NOC_1_5_vector_magnitude
  • [x] NOC_1_6_vector_normalize
  • [x] NOC_1_7_motion101
  • [x] NOC_1_8_motion101_acceleration
  • [x] NOC_1_9_motion101_acceleration
  • [x] NOC_1_10_motion101_acceleration
  • [x] NOC_1_11_motion101_acceleration_array

Chapter 2: Forces

  • [x] NOC_2_1_forces
  • [x] NOC_2_2_forces_many
  • [x] NOC_2_3_forces_many_realgravity
  • [x] NOC_2_4_forces_friction
  • [x] NOC_2_4_forces_nofriction
  • [x] NOC_2_5_fluidresistance need to add text
  • [ ] NOC_2_5_fluidresistance_sequence need to add image saving
  • [x] NOC_2_6_attraction
  • [x] NOC_2_7_attraction_many
  • [x] NOC_2_8_mutual_attraction
  • [ ] NOC_02forces_many_attraction_3D
  • [x] NOC_02forces_many_mutual_boundaries
  • [x] Exercise_2_10_attractrepel
  • [ ] Extra_instantforce

Chapter 3: Oscillation

  • [x] NOC_3_01_angular_motion
  • [x] NOC_3_02_forces_angular_motion
  • [x] NOC_3_03_pointing_velocity
  • [x] NOC_03spring_exercise_sine
  • [x] NOC_3_04_PolarToCartesian
  • [x] NOC_3_04_PolarToCartesian_trail
  • [x] NOC_3_05_simple_harmonic_motion
  • [x] NOC_3_06_simple_harmonic_motion
  • [x] NOC_3_07_oscillating_objects
  • [x] NOC_3_08_static_wave_lines
  • [x] NOC_3_09_exercise_additive_wave
  • [x] NOC_3_09_wave
  • [x] NOC_3_09_wave_a
  • [x] NOC_3_09_wave_b
  • [x] NOC_3_09_wave_c
  • [x] NOC_3_10_PendulumExample
  • [x] NOC_3_10_PendulumExampleSimplified
  • [x] NOC_3_11_spring
  • [ ] Exercise_3_02_cannon (need #125 & #126 first)
  • [x] Exercise_3_04_spiral (need to clear background color in setup)
  • [ ] Exercise_3_05_asteroids
  • [x] Exercise_3_10_OOPWave
  • [x] Exercise_3_11_AdditiveWave
  • [x] Exercise_3_16_springs
  • [x] Exercise_3_16_springs_array
  • [x] OOPWaveParticles
  • [ ] AttractionArrayWithOscillation
  • [x] ExtraOscillatingBody (need to be able to define a pivot point for rotations)
  • [x] ExtraOscillatingUpAndDown
  • [x] MultipleOscillations

Chapter 4: Systems

  • [x] NOC_4_01_SingleParticle
  • [x] NOC_4_01_SingleParticle_trail
  • [x] NOC_4_02_ArrayListParticles
  • [x] NOC_4_03_ParticleSystemClass
  • [x] NOC_4_04_SystemofSystems
  • [x] NOC_4_05_ParticleSystemInheritancePolymorphism
  • [x] NOC_4_06_ParticleSystemForces
  • [x] NOC_4_07_ParticleSystemForcesRepeller
  • [ ] NOC_4_08_ParticleSystemSmoke (Need Images)
  • [ ] NOC_4_08_ParticleSystemSmoke_b (Need Images)
  • [ ] NOC_4_09_AdditiveBlending (Need Images)
  • [x] Exercise_4_03_MovingParticleSystem
  • [ ] Exercise_4_04_asteroids (need to be able to define a pivot point for rotations)
  • [x] Exercise_4_06_Shatter
  • [x] Exercise_4_10_particleintersection
  • [x] Exercise_4_10_particlerepel
  • [ ] Exercise_4_12_ArrayofImages (Need Images)
  • [ ] CircleVsBlob (Need Images)
  • [ ] ParticleSystemInheritance_pushpop (need #125 & #126 first)
  • [ ] flight404 (Need Images)
  • [ ] simpleInheritance (maybe not relevant ..?)
  • [ ] simplePolymorphism (maybe not relevant ..?)

Chapter 5: Physics Libraries

  • to be determined based on physics library used.

Chapter 6: Agents

  • [x] NOC_6_01_Seek
  • [x] NOC_6_01_Seek_trail
  • [x] NOC_6_02_Arrive
  • [x] NOC_6_03_StayWithinWalls
  • [x] NOC_6_03_StayWithinWalls_trail
  • [ ] NOC_6_04_Flow_Figures
  • [ ] NOC_6_04_Flowfield
  • [ ] NOC_6_05_PathFollowingSimple
  • [ ] NOC_6_06_PathFollowing
  • [ ] NOC_6_07_Separation
  • [ ] NOC_6_08_SeparationAndSeek
  • [ ] NOC_6_09_Flocking
  • [ ] Exercise_6_04_Wander
  • [ ] Exercise_6_07_FlowField3DNoise
  • [ ] Exercise_6_09_AngleBetween
  • [ ] Exercise_6_13_CrowdPathFollowing
  • [ ] Exercise_6_17_View
  • [ ] FlowfieldImage
  • [ ] Alignment
  • [ ] SimpleScalarProjection
  • [ ] StayWithinCircle
  • [ ] binlatticespatialsubdivision
  • [ ] box2d
  • [ ] flocking_sliders

Chapter 7: Cellular Automata

  • [x] NOC_7_01_WolframCA_figures
  • [x] NOC_7_01_WolframCA_simple
  • [x] NOC_7_02_GameOfLifeSimple
  • [x] NOC_7_03_GameOfLifeOOP
  • [x] Exercise_7_04_WolframCA_scrolling
  • [x] HexagonCells
  • [x] GameOfLifeWrapAround

Chapter 8: Fractals

  • [x] NOC_8_01_Recursion
  • [x] NOC_8_02_Recursion
  • [x] NOC_8_03_Recursion
  • [x] NOC_8_04_CantorSet
  • [x] NOC_8_04_Tree
  • [ ] NOC_8_05_Koch
  • [ ] NOC_8_05_KochSimple
  • [x] NOC_8_06_SimpleLSystem
  • [ ] NOC_8_06_Tree_static
  • [ ] NOC_8_07_TreeStochastic
  • [ ] NOC_8_07_TreeStochastic_angleonly
  • [ ] NOC_8_09_LSystem
  • [ ] Exercise_8_01_RecursionLines
  • [ ] Exercise_8_02_KochSnowFlake
  • [ ] Exercise_8_06_Tree
  • [ ] Exercise_8_07_Tree
  • [ ] Exercise_8_08_09_TreeArrayListLeaves
  • [ ] Exercise_8_10_TreeStochasticNoise
  • [ ] Figure_8_02_Mandelbrot
  • [ ] Figure_8_14_Koch
  • [ ] Figure_8_20_Tree
  • [ ] Figure_8_CantorLine
  • [ ] CantorSetArrayList

Chapter 9: Genetic Algorithms

  • [x] NOC_9_01_GA_Shakespeare create a get_random_ascii() function for nannous random module
  • [ ] NOC_9_01_GA_Shakespeare_simplified
  • [ ] NOC_9_02_SmartRockets_superbasic
  • [ ] NOC_9_03_SmartRockets
  • [ ] NOC_9_04_Faces_interactiveselection
  • [ ] NOC_9_05_EvolutionEcosystem
  • [ ] EvolveFlowField
  • [ ] GA_Shakespeare_fancyfitness
  • [ ] bruteforce

Chapter 10: Neural Networks

  • [x] NOC_10_01_SimplePerceptron
  • [x] NOC_10_02_SeekingNeural
  • [x] NOC_10_03_NetworkViz
  • [ ] NOC_10_04_NetworkAnimation
  • [ ] LayeredNetworkViz
  • [ ] xor

JoshuaBatty avatar Mar 27 '18 14:03 JoshuaBatty

I'd love to give Agents a go if no one else is already doing this. This it could be good with the AI course fresh in my mind

freesig avatar Jul 19 '18 08:07 freesig

Sounds good, go for it! Hit us up if you're unsure about anything :+1:

mitchmindtree avatar Jul 19 '18 10:07 mitchmindtree

Hey how close to the original style are we aiming for? For example Rust usually encourages functions that apply to an struct vs calling methods on an object. Should we change the style to be more rustic? And perhaps a broader question, do we have a style we want to present in our examples? For example I know Mitch likes to try and compose values over nesting matches. Which I really like. I'm also a fan of using map map_err etc. over more verbose match where appropriate. This means using lots of closures which isn't a thing in processing. However it's a pretty valuable concept that I wish I was introduced to earlier and is also pretty rustic.

Clippy just got added to rustup and will probably be stable soon. Could be a good idea to run this on our code. I've found it pretty helpful in finding not so good style.

Also side question do we have stroke?

freesig avatar Jul 20 '18 01:07 freesig

I'm more than happy to see the examples go with a more "rustic" style and take advantage of the tools/language features that rust has to offer. The original examples are written to fit the Processing language, so I think it's fine to adapt and modify them slightly to fit the Nannou and Rust, as long as they feel familiar, give the same results and the correlations are easy to notice when looked at side-by-side.

I feel like there are two goals that would be nice to keep in mind and balance as we work on these:

  1. I imagine many users will come from Processing, OF, etc, and this may be their first time exposed to rust code, so seeing a close mapping from the original examples to how it can be done in a familiar way in Rust could be a valuable, less-scary first impression.
  2. Nannou has the potential to not only reach existing creative coders, but to also 1. introduce other rustaceans to creative coding and 2. introduce brand new coders in a fun / interactive way. For these cases, I think it is important to attempt to remain idiomatic and apply good-practice, "rustic" conventions.

I think running clippy is an awesome idea! Would be stoked to see a PR applying clippy conventions :+1: I haven't used it, but what I've heard it sounds like clippy can be a bit overbearing at times, so maybe we should take each suggestion with a grain of salt. That said, I've also heard loads of good reviews and folks saying that it has helped them a lot when learning rust conventions.

mitchmindtree avatar Jul 20 '18 15:07 mitchmindtree

This is just what I've been looking for. Daniel looks like the guy to teach creative coding and Nature of Code still seems a great book to work through. Also I would like to get better with Rust and Nannou. Great to see that more people have the same idea and can get some help with this endeavour to get started.

jhaand avatar Jan 23 '22 20:01 jhaand