jonathanperret / paysage

Paysage is a visual shared playground for code.
http://paysage.xyz
GNU Affero General Public License v3.0
20 stars 9 forks source link

New "kawaï" creature for beginners in examples #122

Closed CharlotteMaucherat closed 5 years ago

CharlotteMaucherat commented 5 years ago

Hi,

During a lesson with @juliendorra , we had to create something in order to discover Paysage.

Julien asked me to add my creation as a new creature.

Here is the code : You may change some lines to clean it.

void draw() {
  background(0);
    noStroke()

// EARS

fill (0,0,0)
  ellipse (200 , 100 , 100 , 85) ;
  ellipse (400 , 100 , 100 , 85) ;

//HEAD

fill (0,0,0)
  ellipse (300, 200, 240, 240) ;

//MOUTH

fill (255, 255, 255)
  ellipse (300 , 250 , 110 , 15) ;

//CHEEKS

var teinteDeRouge = abs ( sin(millis ()/1000 ) )* 255
var teinteDeVert = abs ( sin(millis ()/500 ) )* 100 + 50
fill(teinteDeRouge, 90, 90, 127)
  ellipse (220 , 240 , 26 , 25) ;
  ellipse (380 , 240 , 26 , 25) ;

// WHITE EYES

fill (255, 255, 255)
  ellipse (250 , 170 , 50 , 85) ;
  ellipse (350 , 170 , 50 , 85) ;

// PUPILS EYES

translate (0, abs( sin(millis () / 2000)) *40)
fill (0,0,0)
  ellipse (250 , 170 , 20 , 20) ;
  ellipse (350 , 170 , 20 , 20) ;

}
juliendorra commented 5 years ago

Thanks @CharlotteMaucherat , I thought it looks cute, simple to hack, and different from what we have. I wanted to have some feedback on whether it would be a good addition to the list of examples

The code might be very accessible from a beginner perspective, as it was wrote by a beginner.

The only magic part (for persons who forgot math, and they are many) are the abs ( sin( millis ()/1000 ) )* 255 formulas for oscillating variables. It might be interesting to explain it or to point to an explanation somewhere in the comments.

image

image