From a68d04a87c78ed9120e05e66ed1952e1ba5d6248 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 18 Feb 2021 18:37:37 +0100 Subject: i&m: update rotation with increasing/decreasing theta --- Year_2/IandM/rotation/rotation.pde | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'Year_2') diff --git a/Year_2/IandM/rotation/rotation.pde b/Year_2/IandM/rotation/rotation.pde index 33f79ad..b427779 100644 --- a/Year_2/IandM/rotation/rotation.pde +++ b/Year_2/IandM/rotation/rotation.pde @@ -1,13 +1,25 @@ void setup() { size(768, 256); +} + +float th = 0; + +void draw() { PImage img = loadImage("lena.png"); img.resize(256, 256); - img.filter(GRAY); image(img, 0, 0); - image(rotate_forward(img, radians(45)), 256, 0); - - image(inverse_rotate(img, radians(45)), 512, 0); + image(rotate_forward(img, radians(th)), 256, 0); + + image(inverse_rotate(img, radians(th)), 512, 0); +} + +void keyPressed() { + if (key == '+') { + th++; + } else if (key == '-') { + th--; + } } PImage rotate_forward(PImage I, float theta) { -- cgit v1.2.3-18-g5258