Rolling Shutter Effect Explained Even Cheaper (than Matt Parker) - Page 1
Forum section: electronics / general

author: @rt
author_rank: Super Contributor
timestamp: July 15, 2017, 07:49:26 pm
content: Hi GuysThis is a video reply to a video reply by standupmaths, to a video by SmarterEveryDay.I hope you enjoy

author: @rt
author_rank: Super Contributor
timestamp: July 18, 2017, 03:58:08 pm
content: I cleaned up the software a little, mainly because I forgot the all important comparison propeller without the effect.This is roughly 120x240 with a palette of 256 colours.

author: firewalker
author_rank: Super Contributor
timestamp: July 18, 2017, 05:17:17 pm
content: No code? How do you expect us to criticize and correct you?Alexander.

author: @rt
author_rank: Super Contributor
timestamp: July 19, 2017, 03:04:20 pm
content: It was definitely about making an animation rather than writing a program, but go for your lifeFirst thing I’d do is roll the circle drawing into loops, then create an array of the four rotating points,and roll the propeller blades into a loop as well.Code:void transferToScreen() {unsigned int lrow;unsigned int lcol;unsigned int lpixelvalue;for (lrow = smlsizey-1; lrow > 0; lrow--) { // delete previous frame from bitmapfor (lcol = 0; lcol < FDATA_HEIGHT; lcol++) {lpixelvalue = 0;firedata = 0x00;imgdata = (lpixelvalue >> 16) & 0xFF;imgdata[bmpindex+1] = (lpixelvalue >> 8) & 0xFF;imgdata[bmpindex+2] = lpixelvalue & 0xFF;bmpindex+=3;}}// do propeller rotationint increment = 6rotation = rotation + increment;if (rotation > (360-increment)) {rotation = 0;}ox = 75; oy = 80; // propeller blade ax = 75; y = 20; // 7pixelrotation();drawline(ox,oy,x,y);lcol = xnew; lrow = ynew;cx = xnew; cy = ynew; radius=5; drawcircle();cx = xnew; cy = ynew; radius=4; drawcircle();cx = xnew; cy = ynew; radius=3; drawcircle();cx = xnew; cy = ynew; radius=2; drawcircle();cx = xnew; cy = ynew; radius=1; drawcircle();firedata = 0x2F; // prop edge aox = 75; oy = 80; // propeller blade bx = 75; y = 140;pixelrotation();drawline(ox,oy,x,y);lcol = xnew; lrow = ynew;cx = xnew; cy = ynew; radius=5; drawcircle();cx = xnew; cy = ynew; radius=4; drawcircle();cx = xnew; cy = ynew; radius=3; drawcircle();cx = xnew; cy = ynew; radius=2; drawcircle();cx = xnew; cy = ynew; radius=1; drawcircle();firedata = 0x3F; // prop edge box = 75; oy = 80; // propeller blade cx = 135; y = 80;pixelrotation();drawline(ox,oy,x,y);lcol = xnew; lrow = ynew;cx = xnew; cy = ynew; radius=5; drawcircle();cx = xnew; cy = ynew; radius=4; drawcircle();cx = xnew; cy = ynew; radius=3; drawcircle();cx = xnew; cy = ynew; radius=2; drawcircle();cx = xnew; cy = ynew; radius=1; drawcircle();firedata = 0x2F; // prop edge cox = 75; oy = 80; // propeller blade dx = 15; y = 80;pixelrotation();drawline(ox,oy,x,y);lcol = xnew; lrow = ynew;cx = xnew; cy = ynew; radius=5; drawcircle();cx = xnew; cy = ynew; radius=4; drawcircle();cx = xnew; cy = ynew; radius=3; drawcircle();cx = xnew; cy = ynew; radius=2; drawcircle();cx = xnew; cy = ynew; radius=1; drawcircle();firedata = 0x3F; // prop edge dlcol = ox; lrow = oy;firedata = 0x0F; // prop centreif (cycledir == 0) {pixcol++; pixcol++; // cycle coloursif (pixcol > 0xFD) {cycledir = 1;}} else {pixcol--; pixcol--;if (pixcol < 0x2F) {cycledir = 0;}} // cycledirint doline = 0;while (doline < 145) { // copy line to shutter effect bufferlcol = shutterline; lrow = doline;shutdata = firedata;doline++;} // dolineshutterline--;if (shutterline < 0) {shutterline = 159;} // move rolling shutterif (shutenable == 719) {shutterline = 160;} // startup raster delayif (shutenable > 720) {doline = 0;int shuttercnt = 159;while(shuttercnt > shutterline) {doline = 0;while (doline < 145) { // write shutter effect buffer to screenlcol = shuttercnt; lrow = doline;firedata = shutdata;doline++;} // dolineshuttercnt--;} // shuttercntdoline = 0;while (doline < 285) { // moving indicator linelcol = shutterline - 1; lrow = doline;firedata = 0xBE;doline++;} // doline} // shutenableshutenable++;if (shutenable > 9999) {shutenable = 9999;}bmpindex = 54;for (lrow = smlsizey-1; lrow > 0; lrow--) { // write current frame to bitmap imagefor (lcol = 0; lcol < FDATA_HEIGHT; lcol++) {lpixelvalue = palette[firedata];imgdata = (lpixelvalue >> 16) & 0xFF;imgdata[bmpindex+1] = (lpixelvalue >> 8) & 0xFF;imgdata[bmpindex+2] = lpixelvalue & 0xFF;bmpindex+=3;}}}

author: BravoV
author_rank: Super Contributor
timestamp: July 19, 2017, 03:26:38 pm
content: Hey @rt, whats the song's name for the 2nd video ?

author: @rt
author_rank: Super Contributor
timestamp: July 19, 2017, 04:13:13 pm
content: Did you like it? Well guess what.... Now you’re a Twilight fan! Go team Edward!!!Code:unsigned int lrow;unsigned int lcol;unsigned int lpixelvalue;int innercnt = 0;for (lrow = smlsizey-1; lrow > 0; lrow--) { // delete previous frame from bitmapfor (lcol = 0; lcol < FDATA_HEIGHT; lcol++) {lpixelvalue = 0;firedata = 0x00;imgdata = (lpixelvalue >> 16) & 0xFF;imgdata[bmpindex+1] = (lpixelvalue >> 8) & 0xFF;imgdata[bmpindex+2] = lpixelvalue & 0xFF;bmpindex+=3;}}int pointsx = {75,75,135,15};int pointsy = {20,140,80,80};// do propeller rotationint increment = 6; // must be evenly divisible by 360 at the momentrotation = rotation + increment;if (rotation > (360-increment)) {rotation = 0;}innercnt = 0;while (innercnt < 4) {ox = 75; oy = 80; // propeller bladex = pointsx; y = pointsy;pixelrotation();drawline(ox,oy,x,y);lcol = xnew; lrow = ynew;cx = xnew; cy = ynew; radius=5; drawcircle();cx = xnew; cy = ynew; radius=4; drawcircle();cx = xnew; cy = ynew; radius=3; drawcircle();cx = xnew; cy = ynew; radius=2; drawcircle();cx = xnew; cy = ynew; radius=1; drawcircle();firedata = 0x2F; // prop edgeinnercnt++;} // innercnt