Last active
October 27, 2017 15:54
-
-
Save aurelianonava/5eda45a2da8c4c860ca6fb5d7377b2cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
class Circle { | |
constructor() { | |
this.logtext = "circle instantiated" | |
} | |
draw() { | |
// var x = 10; | |
P$.ellipse(x, P$.height/4, P$.height * 0.25, P$.height * 0.25) | |
} | |
draw1() { | |
P$.ellipse(P$.width/3, P$.height/4, P$.height * 0.25, P$.height * 0.25) | |
} | |
rect1() { | |
P$.ellipseMode(P$.RADIUS); | |
// var z = 25, radius = 50, speed = 0.5, y = 50; | |
x += speed * direction; | |
yradius = radius-=.1; | |
if (x > P$.width-radius || x < radius) { | |
direction = -direction; | |
} | |
if (yradius < 0 ) { | |
yradius = -yradius; | |
} | |
P$.ellipse(x, y, radius, yradius); | |
} | |
log() { | |
console.log(this.logtext); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Introduction to OOP</title> | |
<meta name="description" content="Multiple Mini-Project on one Canvas"> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |
<script data-require="p5.js@*" data-semver="0.5.7" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.min.js"></script> | |
<script src="script.js" type="text/javascript"></script> | |
<script src="Circle.js"></script> | |
<script src="Mammal.js"></script> | |
</head> | |
<body> | |
<h4>Introduction to OOP - Object Oriented Programming</h4> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
class Mammal { | |
constructor() { | |
} | |
william() { | |
P$.rect(50, 50, 50, 50); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
var y =25, radius = 25; | |
var x = 50, speed = 1, direction = 1; | |
var yradius = 25; | |
// x += speed; | |
window.P$ = new p5(p => { | |
// var y = 25; | |
let c | |
let e | |
p.setup = function () { | |
p.createCanvas(600, 400); | |
// p.ellipseMode(RADIUS); | |
c = new Circle(); | |
e = new Mammal(); | |
c.log() | |
} | |
p.draw = function () { | |
p.background(100, 200, 250); | |
// x += speed; | |
p.fill(0, 100, 145); | |
// c.draw(); | |
// c.draw1(); | |
c.rect1(); | |
// c.draw(); | |
e.william(); | |
} | |
}, "script") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment