| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
-n ;no sound output |
| 5 |
</CsOptions> |
| 6 |
<CsInstruments> |
| 7 |
|
| 8 |
sr = 44100 |
| 9 |
ksmps = 32 |
| 10 |
0dbfs = 1 |
| 11 |
nchnls = 2 ; doesn't matter because there is no sound output |
| 12 |
|
| 13 |
; by Menno Knevel 2021 |
| 14 |
; image opcodes need a black canvas- black = no sound! |
| 15 |
|
| 16 |
giimageOLD imageload "imageOpcode02.png" ; load this image |
| 17 |
giimagew, giimageh imagesize giimageOLD ; get dimensions of imageOpcode02.png |
| 18 |
giimageNEW1 imagecreate giimagew,giimageh ; and use those same dimensions |
| 19 |
giimageNEW2 imagecreate giimagew,giimageh ; for 3 new images |
| 20 |
giimageNEW3 imagecreate giimagew,giimageh ; |
| 21 |
|
| 22 |
instr 1 ; copies imageOpcode02.png and transforms it |
| 23 |
|
| 24 |
kndx = 0 |
| 25 |
kx linseg 0, p3, 1 ; scans x-axis |
| 26 |
prints "\nwidth = %d pixels, heigth = %d pixels\n\n", giimagew, giimageh |
| 27 |
|
| 28 |
myloop: |
| 29 |
ky = kndx/(giimageh) ; y-axis |
| 30 |
krd, kgn, kbl imagegetpixel giimageOLD, kx, ky ; get pixels from 'old' image |
| 31 |
prints "\n--**giimageNEW1 zooms out**--\n" |
| 32 |
imagesetpixel giimageNEW1, kx*.9, ky*.5, krd, kgn, kbl |
| 33 |
prints "\n--**giimageNEW2 zooms in**--\n" |
| 34 |
imagesetpixel giimageNEW2, kx*rnd(10), ky*rnd(10), krd, kgn, kbl |
| 35 |
prints "\n--**giimageNEW3 zooms in and applies offset on y-axis**--\n\n" |
| 36 |
imagesetpixel giimageNEW3, kx*rnd(5), (ky*rnd(5)+.2), krd, kgn, kbl |
| 37 |
loop_lt kndx, 0.5, giimageh, myloop |
| 38 |
|
| 39 |
endin |
| 40 |
|
| 41 |
instr 2 |
| 42 |
imagesave giimageNEW1, "imageNEW1.png" ; save those 3 new images |
| 43 |
imagesave giimageNEW2, "imageNEW2.png" |
| 44 |
imagesave giimageNEW3, "imageNEW3.png" |
| 45 |
endin |
| 46 |
|
| 47 |
instr 3 |
| 48 |
imagefree giimageOLD ; unload all images |
| 49 |
imagefree giimageNEW1 |
| 50 |
imagefree giimageNEW2 |
| 51 |
imagefree giimageNEW3 |
| 52 |
endin |
| 53 |
|
| 54 |
</CsInstruments> |
| 55 |
<CsScore> |
| 56 |
|
| 57 |
i1 1 2 |
| 58 |
i2 2 1 |
| 59 |
i3 4 .1 |
| 60 |
e |
| 61 |
</CsScore> |
| 62 |
</CsoundSynthesizer> |