Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
[source code] motion blur
Author Message
Tony

Posted: Sun Nov 09, 2003 3:51 pm   Post subject: [source code] motion blur

based on my blur filter and thx to thoughtful for the idea

Motion Blur is used to blur images in a direction and with magnitude, creating an effect of the object moving in that direction.

 code: %a more advanced version of the Blur Filter. %This includes the direction and magnitude of the blur %so that motion blurs can be created procedure Blur(direction:int, magnitude:int) var d:array 1..maxx, 1..maxy of int %vertual image, holds pixel colors var c:int:=255 %just a variable for color var cr,cb,cg:array 1..magnitude of real %temporary colors var acr,acb,acg:real %used for average color calculation for x:1..maxx for y:1..maxy d(x,y):=whatdotcolor(x,y) %records pixel colors end for end for for x:magnitude..maxx-magnitude for y:magnitude..maxy-magnitude for m:1..magnitude RGB.GetColor(d(x+round(cosd(direction)*m),y+round(sind(direction)*m)),cr(m),cg(m),cb(m)) end for acr:=0 for i:1..magnitude acr+=cr(i) end for acr:=acr/magnitude %average color acg:=0 for i:1..magnitude acg+=cg(i) end for acg:=acg/magnitude %average color acb:=0 for i:1..magnitude acb+=cb(i) end for acb:=acb/magnitude %average color RGB.SetColor(c,acr,acg,acb) %create the new color Draw.Dot(x,y,c) %draw that color end for end for end Blur

Not much has changed. The only difference really is that trig is used to find which points to blur together.

Direction:int is degrees at which to blur, Magnitude:int is how many pixels in that direction will be blured.

Here're some SS:
Blur(0,10)

Blur(0,10) + redraw of text

Blur(45,25) + redraw of text

Note, I've left a border around the image of "Magnitude:int" length, so that filter would not crash, trying to get the color of a pixel outside the screen

mblur3.JPG
Description:
Filesize:  12.92 KB
Viewed:  6472 Time(s)

mblur2.JPG
Description:
Filesize:  10.97 KB
Viewed:  6470 Time(s)

mblur1.JPG
Description:
Filesize:  10.04 KB
Viewed:  6465 Time(s)

Tony's programming blog. DWITE - a programming contest.

rizzix

Posted: Sun Nov 09, 2003 7:39 pm   Post subject: (No subject)

as i said nice stuff
thoughtful

Posted: Mon Nov 10, 2003 3:38 pm   Post subject: (No subject)

Hey tony this is jus great, i wasn't expecting an effect this great this fast. it is splendid.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 3 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: