Skip to content

Commit

Permalink
Merge branch 'release/0.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
berinhard committed May 27, 2019
2 parents 2f56239 + a429191 commit 5b52bfe
Show file tree
Hide file tree
Showing 30 changed files with 87,519 additions and 79 deletions.
27 changes: 27 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
0.0.5
-----
- Adds all p5's missing global variables

0.0.4.1
-------
- Supports event functions such as `keyPressed`

0.0.4
-----
- Supports p5.js pop function
- Adds `monitor` command to the CLI
- Allows to run `pyp5js` commands specifying a directory
- First try on organizing the docs

0.0.3
-----
- Add WEBGL variables

0.0.2
-----
- Supports more of P5's variable


0.0.1
-----
- First release
3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r requirements.txt
pytest==4.5.0
tox==3.10.0
19 changes: 13 additions & 6 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
### Examples list

- [Angles and mouse coordinates](sketch_001/index.html)
- [Move Eye](sketch_002/index.html), [@villares](https://github.com/villares) implementation of Simon Greenwold's code
- [3D](sketch_003/index.html)
- [Boids](sketch_004/index.html) from [@esperanc](https://github.com/esperanc) [BrythonIDE examples](https://github.com/esperanc/brythonide/blob/master/demoSketches/boids.py)
- [Globals variables (HSB and CENTER)](sketch_005/index.html)
- [Registering event functions such as keyPressed](sketch_006/index.html)
- Angles and mouse coordinates: [see code](https://github.com/berinhard/pyp5js/tree/develop/docs/examples/sketch_001) | [run example](sketch_001/index.html)

- Move Eye, an example by Simon Greenwold, ported by [@villares](https://github.com/villares): [see code](https://github.com/berinhard/pyp5js/tree/develop/docs/examples/sketch_002) | [run example](sketch_002/index.html)

- Rotating 3D box: [see code](https://github.com/berinhard/pyp5js/tree/develop/docs/examples/sketch_003) | [run example](sketch_003/index.html)

- Boids, from [@esperanc](https://github.com/esperanc) [BrythonIDE examples](https://github.com/esperanc/brythonide/blob/master/demoSketches/boids.py): [see code](https://github.com/berinhard/pyp5js/tree/develop/docs/examples/sketch_004) | [run example](sketch_004/index.html)

- Globals variables (HSB and CENTER): [see code](https://github.com/berinhard/pyp5js/tree/develop/docs/examples/sketch_005) | [run example](sketch_005/index.html)

- Registering event functions such as keyPressed: [see code](https://github.com/berinhard/pyp5js/tree/develop/docs/examples/sketch_006) | [run example](sketch_006/index.html)

- p5.Vector static methods: [see code](https://github.com/berinhard/pyp5js/tree/develop/docs/examples/sketch_007) | [run example](sketch_007/index.html)
73 changes: 71 additions & 2 deletions docs/examples/sketch_001/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,80 @@

<script src="static/p5.js"></script>
<script src="target/sketch_001.js" type="module"></script>

<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/default.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

<style>
html {
overflow-y: scroll;
}

.demoContainer {
display: flex;
align-items: center;
justify-content: center;
}

pre {
padding-left: 2em;
}
</style>
</head>

<body>
<div id="sketch-holder">
<!-- You sketch will go here! -->
<p style="background-color: #f6f8fa">
Python code <a href="https://github.com/berinhard/pyp5js/blob/develop/docs/examples/sketch_001" target="_blank">here</a>.
</p>


<div class="demoContainer">
<div id="sketch-holder" style="">
<!-- You sketch will go here! -->
</div>
<div style="">
<pre>
<code>
from pytop5js import *

t = 0

def setup():
createCanvas(600, 600)
stroke(250)
strokeWeight(3)
fill(40, 200, 40)


def draw():
global t
background(10, 10)

xAngle = map(mouseX, 0, width, -4 * PI, 4 * PI, True)
yAngle = map(mouseY, 0, height, -4 * PI, 4 * PI, True)
for x in range(0, width, 30):
for y in range(0, height, 30):

angle = xAngle * (x / width) + yAngle * (y / height)

myX = x + 20 * cos(2 * PI * t + angle)
myY = y + 20 * sin(2 * TWO_PI * t + angle)

ellipse(myX, myY, 10)

t = t + 0.01

console.log(frameRate())


my_p5 = start_p5(setup, draw, {})
</code>
</pre>
</div>
</div>

</body>


</html>
74 changes: 71 additions & 3 deletions docs/examples/sketch_002/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,79 @@

<script src="static/p5.js"></script>
<script src="target/sketch_002.js" type="module"></script>

<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/default.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

<style>
html {
overflow-y: scroll;
}

.demoContainer {
display: flex;
align-items: center;
justify-content: center;
}

pre {
padding-left: 2em;
}
</style>
</head>

<body>
<div id="sketch-holder">
<!-- You sketch will go here! -->
<p style="background-color: #f6f8fa">
Python code <a href="https://github.com/berinhard/pyp5js/blob/develop/docs/examples/sketch_002" target="_blank">here</a>.
</p>

<div class="demoContainer">
<div id="sketch-holder" style="">
<!-- You sketch will go here! -->
</div>


<div style="">
<pre>
<code>
"""
* Move Eye.
* by Simon Greenwold.
*
* The camera lifts up (controlled by mouseY) while looking at the same point.
"""
from pytop5js import *

def setup():
createCanvas(640, 360, _P5_INSTANCE.WEBGL)
fill(204)


def draw():
ambientLight(50)
directionalLight(255, 0, 0, 0.25, 0.25, 0);
background(0)

# Change height of the camera with mouseY
camera(30.0, mouseY, 220.0, # eyeX, eyeY, eyeZ
0.0, 0.0, 0.0, # centerX, centerY, centerZ
0.0, 1.0, 0.0) # upX, upY, upZ

noStroke()
box(90)
stroke(255)
line(-100, 0, 0, 100, 0, 0)
line(0, -100, 0, 0, 100, 0)
line(0, 0, -100, 0, 0, 100)


# This is required by pyp5js to work
start_p5(setup, draw, {})
</code>
</pre>
</div>

</div>
</body>
</html>
</html>
58 changes: 55 additions & 3 deletions docs/examples/sketch_003/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,63 @@

<script src="static/p5.js"></script>
<script src="target/sketch_003.js" type="module"></script>

<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/default.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

<style>
html {
overflow-y: scroll;
}

.demoContainer {
display: flex;
align-items: center;
justify-content: center;
}

pre {
padding-left: 2em;
}
</style>
</head>

<body>
<div id="sketch-holder">
<!-- You sketch will go here! -->
<p style="background-color: #f6f8fa">
Python code <a href="https://github.com/berinhard/pyp5js/blob/develop/docs/examples/sketch_003" target="_blank">here</a>.
</p>

<div class="demoContainer">
<div id="sketch-holder">
<!-- You sketch will go here! -->
</div>

<pre>
<code>
# 3d example
from pytop5js import *


def setup():
createCanvas(600, 600, WEBGL)

def draw():
background(200)
translate(-100, -100, 0)
push()
normalMaterial()
rotateZ(frameCount * 0.01)
rotateX(frameCount * 0.01)
rotateY(frameCount * 0.01)
box(50, 70, 100)
pop()


start_p5(setup, draw, {})
</code>
</pre>

</div>
</body>
</html>
</html>
Loading

0 comments on commit 5b52bfe

Please sign in to comment.