1. NADAR SARASWATHI COLLEGE OF ARTS AND SCIENCE,
VADAPUTHUPATTI,THENI.
DEPARTEMENT OF COMPUTER SCIENCE
2D Graphics Animation –Bouncing Ball
PRESENTED BY:
S.AISHWARYA LAKSHMI I M.SC(CS)
2. What is Python?
Python is an interpreted, object-oriented, high-level programming
language with dynamic semantics.
Its high-level built in data structures, combined with dynamic
typing and dynamic binding, make it very attractive for Rapid
Application Development, as well as for use as a scripting or glue
language to connect existing components together.
Python's simple, easy to learn syntax emphasizes readability and
therefore reduces the cost of program maintenance.
Python supports modules and packages, which encourages program
modularity and code reuse.
3. What can Python do?
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and
modify files.
Python can be used to handle big data and perform complex
mathematics.
Python can be used for rapid prototyping, or for production-ready
software development.
4. Why Python?
Python works on different platforms (Windows, Mac, Linux,
Raspberry Pi, etc.)
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programs with
fewer lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be
executed as soon as it is written. This means that prototyping can
be very quick.
Python can be treated in a procedural way, an object-oriented way
or a functional way.
5. 2D graphics animation
2D computer graphics started in the 1950s, based on VECTOR
GRAPHICS DEVICES. These were largely supplanted by RASTER
BASED DEVICES in the following decades.
The POST SCRIPT: post script is the programming language
optimized for printing graphics and text.
The main purpose of postscript was to provide in which to describe
images in a device independent manner.
6. 2D graphics animation
And the X WINDOW SYSTEM protocol were landmark
developments in the field.
X window provides the basic framework for a GUI environment:
drawing and moving windows on the display device and interacting
with a mouse and keyboard.
X window does not mandate the user interface – this is handled by
individual programs.
As such, the visual styling of X-based environments varies greatly;
different programs may present radically different interfaces.
7. 2D graphics animation
2D computer graphics are mainly used in applications that were
originally developed for
traditional printing and drawing technologies, such
as typography, cartography, technical drawing, advertising, etc.
8. 2D graphic animation
In those applications, the two-dimensional images is not just a
representation of a real-world object.
two-dimensional models are therefore preferred, because they
give more direct control of the image than 3D Computer graphic.
9. GRAPHICS MODELS
2D graphics models may combine :
Geometric Model (also called Vector graphics),
Digital images (also called Raster graphics),
Text to be typeset (defined by content, font style and size, color,
position, and orientation),
Mathematical functions and equations, and more.
These components can be modified and manipulated by two
dimensional geometric transformations such as translation ,
rotation , scaling.
10. BOUNCING BALL
01 from visual import*
02 ground= box(size=(10,0.1,10), color = color. White , material=
03 =materials . wood)
04 ball=sphere(pos=(0,4,0),radius=1,color=color . yellow)
05
06 scene. Center = vector(0,5,5)
07 Velocity = 10
08 e = 0.9
09 dt =0.01
10 While True:
(cont…..)
12. ANIMATION-BOUNCING BALL
The animation is a continuous sequence of graphics ,
often termed as Frames , that are played back to back with respect
to time. We create an animation of a bouncing ball.
EXPLANATION:
02 ground= box(size=(10,0.1,10), color = color. White , material=
03 =materials . wood)
04 ball=sphere(pos=(0,4,0),radius=1,color=color . yellow)
In this we create a base ground using a box object and a
ball using sphere object and we have define their attributes .
13. ANIMATION-BOUNCING BALL
EXPLANATION:
06 scene. Center = vector(0,5,5)
The center point of thee visual display window is positioned
at(0,5,5).
07 Velocity = 10
08 e = 0.9
The ball is projected with an initial velocity
10 units/sec . In the direction of Y-axis, and the coefficient of restitution is
0.9.
09 dt =0.01
Change in time dt is set to 0.01sec.
10 While True:
The while loop produces a bouncing ball animation
14. ANIMATION-BOUNCING BALL
EXPLANATION:
11 rate(300)
Function rate defines a maximum number of loop per second.
12 prevPos = ball.Y
13 ball.y+= velocity * dt
The position of the bouncing ball in each iteration is updated using
current velocity and time.
14 If ball.y < ball . radius:
15 Velocity = -velocity * e
The current position of the is less than the radius of the ball, it
touches the floor. In this case , the velocity of the ball is negated changing the
direction of motion and its position is set to coordinates.
Velocity= u + a*t.