Skip to content

Commit 650afa1

Browse files
committed
add image examples.
1 parent a72ef5d commit 650afa1

19 files changed

+171
-1
lines changed

ATTRIBUTION

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ reference/image/raspberries-*.jpg:
1010
from Wikimedia Commons
1111
<https://commons.wikimedia.org/wiki/File:Raspberries05.jpg>
1212

13+
reference/image/rebar-*.jpg
14+
By W.carter
15+
[CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0)],
16+
from Wikimedia Commons
17+
<https://commons.wikimedia.org/wiki/File:Rusty_rebar_nets.jpg>
18+
1319
reference/image/seeds-*.jpg:
1420
Sanjay Acharya
1521
[CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0)],

reference/image/pimage/blend_add.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from p5 import *
2+
3+
img1 = load_image('../src/luminale-512.jpg')
4+
img2 = load_image('../src/grand-theatre-512.jpg')
5+
img3 = load_image('../src/luminale-512.jpg')
6+
7+
img3.blend(img2, 'add')
8+
9+
def setup():
10+
size(img1.width, int(img1.height * 1.5))
11+
no_loop()
12+
13+
def draw():
14+
image(img1, (0, 0), (img1.width // 2, img1.height // 2))
15+
image(img2, (img1.width // 2, 0), (img1.width // 2, img1.height // 2))
16+
image(img3, (0, img1.height // 2))
17+
18+
if __name__ == '__main__':
19+
run()

reference/image/pimage/blend_blend.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from p5 import *
2+
3+
img1 = load_image('../src/luminale-512.jpg')
4+
img2 = load_image('../src/grand-theatre-512.jpg')
5+
img3 = load_image('../src/luminale-512.jpg')
6+
7+
img3.filter('opacity', 0.5)
8+
img3.blend(img2, 'blend')
9+
10+
def setup():
11+
size(img1.width, int(img1.height * 1.5))
12+
no_loop()
13+
14+
def draw():
15+
background(0)
16+
image(img1, (0, 0), (img1.width // 2, img1.height // 2))
17+
image(img2, (img1.width // 2, 0), (img1.width // 2, img1.height // 2))
18+
image(img3, (0, img1.height // 2))
19+
20+
if __name__ == '__main__':
21+
run()
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from p5 import *
2+
3+
img1 = load_image('../src/luminale-512.jpg')
4+
img2 = load_image('../src/grand-theatre-512.jpg')
5+
img3 = load_image('../src/luminale-512.jpg')
6+
7+
img3.blend(img2, 'darkest')
8+
9+
def setup():
10+
size(img1.width, int(img1.height * 1.5))
11+
no_loop()
12+
13+
def draw():
14+
image(img1, (0, 0), (img1.width // 2, img1.height // 2))
15+
image(img2, (img1.width // 2, 0), (img1.width // 2, img1.height // 2))
16+
image(img3, (0, img1.height // 2))
17+
18+
if __name__ == '__main__':
19+
run()
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from p5 import *
2+
3+
img1 = load_image('../src/luminale-512.jpg')
4+
img2 = load_image('../src/grand-theatre-512.jpg')
5+
img3 = load_image('../src/luminale-512.jpg')
6+
7+
img3.blend(img2, 'lightest')
8+
9+
def setup():
10+
size(img1.width, int(img1.height * 1.5))
11+
no_loop()
12+
13+
def draw():
14+
image(img1, (0, 0), (img1.width // 2, img1.height // 2))
15+
image(img2, (img1.width // 2, 0), (img1.width // 2, img1.height // 2))
16+
image(img3, (0, img1.height // 2))
17+
18+
if __name__ == '__main__':
19+
run()
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from p5 import *
2+
3+
img1 = load_image('../src/luminale-512.jpg')
4+
img2 = load_image('../src/grand-theatre-512.jpg')
5+
img3 = load_image('../src/luminale-512.jpg')
6+
7+
img3.blend(img2, 'multiply')
8+
9+
def setup():
10+
size(img1.width, int(img1.height * 1.5))
11+
no_loop()
12+
13+
def draw():
14+
image(img1, (0, 0), (img1.width // 2, img1.height // 2))
15+
image(img2, (img1.width // 2, 0), (img1.width // 2, img1.height // 2))
16+
image(img3, (0, img1.height // 2))
17+
18+
if __name__ == '__main__':
19+
run()
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from p5 import *
2+
3+
img1 = load_image('../src/luminale-512.jpg')
4+
img2 = load_image('../src/grand-theatre-512.jpg')
5+
img3 = load_image('../src/luminale-512.jpg')
6+
7+
img3.blend(img2, 'screen')
8+
9+
def setup():
10+
size(img1.width, int(img1.height * 1.5))
11+
no_loop()
12+
13+
def draw():
14+
image(img1, (0, 0), (img1.width // 2, img1.height // 2))
15+
image(img2, (img1.width // 2, 0), (img1.width // 2, img1.height // 2))
16+
image(img3, (0, img1.height // 2))
17+
18+
if __name__ == '__main__':
19+
run()
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from p5 import *
2+
3+
img1 = load_image('../src/luminale-512.jpg')
4+
img2 = load_image('../src/grand-theatre-512.jpg')
5+
img3 = load_image('../src/luminale-512.jpg')
6+
7+
img3.blend(img2, 'subtract')
8+
9+
def setup():
10+
size(img1.width, int(img1.height * 1.5))
11+
no_loop()
12+
13+
def draw():
14+
image(img1, (0, 0), (img1.width // 2, img1.height // 2))
15+
image(img2, (img1.width // 2, 0), (img1.width // 2, img1.height // 2))
16+
image(img3, (0, img1.height // 2))
17+
18+
if __name__ == '__main__':
19+
run()

reference/image/pimage/copy_image.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from p5 import *
2+
3+
raspberries = load_image("../raspberries-256.jpg")
4+
5+
def setup():
6+
size(*raspberries.size)
7+
raspberries[:128, :] = raspberries[128:, :]
8+
no_loop()
9+
10+
def draw():
11+
background(raspberries)
12+
13+
if __name__ == '__main__':
14+
run()

reference/image/pimage/get_1.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from p5 import *
2-
32
lake = load_image('../lake-512.jpg')
43

54
def setup():

reference/image/pimage/get_2.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from p5 import *
2+
3+
lake = load_image("../lake-512.jpg")
4+
new_lake = lake[256:, :]
5+
6+
def setup():
7+
size(*lake.size)
8+
no_loop()
9+
10+
def draw():
11+
background(lake)
12+
image(new_lake, (0, 0))
13+
14+
if __name__ == '__main__':
15+
run()

reference/image/pimage/set_1.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def draw():
1313
soyuz[px, py] = white
1414

1515
image(soyuz, (0, 0))
16+
soyuz.save("soy.png")
1617

1718
if __name__ == '__main__':
1819
run()

reference/image/rebar-128.jpg

56 KB
Loading

reference/image/rebar-256.jpg

158 KB
Loading

reference/image/rebar-512.jpg

456 KB
Loading
71.5 KB
Loading
194 KB
Loading

reference/image/src/luminale-256.jpg

95.6 KB
Loading

reference/image/src/luminale-512.jpg

233 KB
Loading

0 commit comments

Comments
 (0)