Author Topic: Rolling Shutter Effect Explained Even Cheaper (than Matt Parker)  (Read 2931 times)

0 Members and 1 Guest are viewing this topic.

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1059
Hi Guys :)
This is a video reply to a video reply by standupmaths, to a video by SmarterEveryDay.
I hope you enjoy :D

 
The following users thanked this post: Cliff Matthews

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1059
Re: Rolling Shutter Effect Explained Even Cheaper (than Matt Parker)
« Reply #1 on: July 18, 2017, 03:58:08 pm »
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.

 
The following users thanked this post: BravoV

Offline firewalker

  • Super Contributor
  • ***
  • Posts: 2450
  • Country: gr
Re: Rolling Shutter Effect Explained Even Cheaper (than Matt Parker)
« Reply #2 on: July 18, 2017, 05:17:17 pm »
No code? How do you expect us to criticize and correct you?  :P :P :P :P

Alexander.
Become a realist, stay a dreamer.

 

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1059
Re: Rolling Shutter Effect Explained Even Cheaper (than Matt Parker)
« Reply #3 on: July 19, 2017, 03:04:20 pm »
It was definitely about making an animation rather than writing a program, but go for your life :D

First 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: [Select]

void transferToScreen() {
   
    unsigned int  lrow;
    unsigned int  lcol;
    unsigned int  lpixelvalue;
   
    for (lrow = smlsizey-1; lrow > 0; lrow--) { // delete previous frame from bitmap
    for (lcol = 0; lcol < FDATA_HEIGHT; lcol++) {
    lpixelvalue = 0;firedata[lcol][lrow] = 0x00;
    imgdata[bmpindex] = (lpixelvalue >> 16) & 0xFF;
    imgdata[bmpindex+1] = (lpixelvalue >> 8) & 0xFF;
    imgdata[bmpindex+2] = lpixelvalue & 0xFF;
    bmpindex+=3;
    }}
   
    // do propeller rotation
    int increment = 6
    rotation = rotation + increment;
    if (rotation > (360-increment)) {rotation = 0;}
   
    ox = 75; oy = 80; // propeller blade a
    x = 75; y = 20; // 7
    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[lcol][lrow] = 0x2F; // prop edge a

    ox = 75; oy = 80; // propeller blade b
    x = 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[lcol][lrow] = 0x3F; // prop edge b
   
    ox = 75; oy = 80; // propeller blade c
    x = 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[lcol][lrow] = 0x2F; // prop edge c
   
    ox = 75; oy = 80; // propeller blade d
    x = 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[lcol][lrow] = 0x3F; // prop edge d
   
    lcol = ox; lrow = oy;
    firedata[lcol][lrow] = 0x0F; // prop centre
   
    if (cycledir == 0) {
    pixcol++; pixcol++; // cycle colours
    if (pixcol > 0xFD) {cycledir = 1;}
    } else {
    pixcol--; pixcol--;
    if (pixcol < 0x2F) {cycledir = 0;}
    } // cycledir
   
    int doline = 0;
    while (doline < 145) { // copy line to shutter effect buffer
    lcol = shutterline; lrow = doline;
    shutdata[lcol][lrow] = firedata[lcol][lrow];
    doline++;
    } // doline
   
    shutterline--;
    if (shutterline < 0) {shutterline = 159;} // move rolling shutter
   
    if (shutenable == 719) {shutterline = 160;} // startup raster delay
    if (shutenable > 720) {
   
    doline = 0;
    int shuttercnt = 159;
    while(shuttercnt > shutterline) {
    doline = 0;
    while (doline < 145) { // write shutter effect buffer to screen
    lcol = shuttercnt; lrow = doline;
    firedata[lcol][lrow] = shutdata[lcol][lrow];
    doline++;
    } // doline
    shuttercnt--;
    } // shuttercnt
   
    doline = 0;
    while (doline < 285) { // moving indicator line
    lcol = shutterline - 1; lrow = doline;
    firedata[lcol][lrow] = 0xBE;
    doline++;
    } // doline
   
    } // shutenable
    shutenable++;
    if (shutenable > 9999) {shutenable = 9999;}
   
    bmpindex = 54;
    for (lrow = smlsizey-1; lrow > 0; lrow--) { // write current frame to bitmap image
    for (lcol = 0; lcol < FDATA_HEIGHT; lcol++) {
    lpixelvalue = palette[firedata[lcol][lrow]];
    imgdata[bmpindex] = (lpixelvalue >> 16) & 0xFF;
    imgdata[bmpindex+1] = (lpixelvalue >> 8) & 0xFF;
    imgdata[bmpindex+2] = lpixelvalue & 0xFF;
    bmpindex+=3;
    }}
}
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7547
  • Country: 00
  • +++ ATH1
Re: Rolling Shutter Effect Explained Even Cheaper (than Matt Parker)
« Reply #4 on: July 19, 2017, 03:26:38 pm »
Hey @rt, whats the song's name for the 2nd video ?

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1059
Re: Rolling Shutter Effect Explained Even Cheaper (than Matt Parker)
« Reply #5 on: July 19, 2017, 04:13:13 pm »
Did you like it? Well guess what.... Now you’re a Twilight fan! Go team Edward!!! :D


Code: [Select]
    unsigned int  lrow;
    unsigned int  lcol;
    unsigned int  lpixelvalue;
    int innercnt = 0;
   
    for (lrow = smlsizey-1; lrow > 0; lrow--) { // delete previous frame from bitmap
    for (lcol = 0; lcol < FDATA_HEIGHT; lcol++) {
    lpixelvalue = 0;firedata[lcol][lrow] = 0x00;
    imgdata[bmpindex] = (lpixelvalue >> 16) & 0xFF;
    imgdata[bmpindex+1] = (lpixelvalue >> 8) & 0xFF;
    imgdata[bmpindex+2] = lpixelvalue & 0xFF;
    bmpindex+=3;
    }}
   
    int pointsx[4] = {75,75,135,15};
    int pointsy[4] = {20,140,80,80};
   
    // do propeller rotation
    int increment = 6; // must be evenly divisible by 360 at the moment
    rotation = rotation + increment;
    if (rotation > (360-increment)) {rotation = 0;}
   
    innercnt = 0;
    while (innercnt < 4) {
    ox = 75; oy = 80; // propeller blade
    x = pointsx[innercnt]; y = pointsy[innercnt];
    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[lcol][lrow] = 0x2F; // prop edge
    innercnt++;
    } // innercnt

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf