Sei sulla pagina 1di 21

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH

Name : M.H.Prasad Rao


Designation : HCCP
Branch : D.C.C.P.
Institute : SGM G.P.T., Abdullapurmet
Year/Semester : V Semester
Subject : VISUAL BASIC-I
Subject Code : CCP-503 (52/75)
Topic : MDI Applications and Graphics
Duration : 50 Mts
Sub-Topic : Graphics – Pset() method.. Contd.
Teaching Aids used : PPT, Animations, Window
outputs
CCP503.52 1
Objectives
After completion of this class, you would
be able to:
 Use Pset() with COLOR parameter

 Use Pset() with STEP parameter

 Use Pset() with variables & loops

CCP503.52 2
Use of Pset() method of color parameter
All the examples hereon assume a form
with the name Form1 having 5000(X) X
5000(Y) coordinates
Syntax of Pset() with color parameter:

Form1.Pset() [color] (IntX, IntY)

CCP503.52 3
Explanation:
IntX and IntY were already explained.

What are they?

[color] makes Pset() method to draw the point


in the color specified by parameter value

CCP503.52 4
Explanation of Pset() with color parameter

Values of Color parameter:


There are different values for different
colors for color parameter. These values
are named constants as listed below or
hex numbers:

vbWhite, vbBlack, vbRed, vbYellow,


vbBlue, vbCyan, vbMagenta etc.

CCP503.52 5
You can use any of the above values for
color parameter of Pset() method to set
the color of the point to be drawn

CCP503.52 6
Examples of Pset() with color parameter
Examples:
Pset(2500, 2500), vbRed --- sets red color point in form
center
Pset(2600, 2500), vbGreen-- sets Green color point in
form center
Pset(2700, 2500), vbBlue--- sets Blue color point in form
center
Pset(2800, 2500), vbBlack--- sets Black color point in form
center

CCP503.52 7
Can the Background color of the form be any of
the above colors set by Pset() method above?

Fig:1

CCP503.52 8
Explanation Of Step Parameter of
Pset() Method
EXPLANATION:
Step Parameter sets point as offset from
previous point
Syntax of Pset() with step parameter:
Pset step (IntX, IntY)
intX, intY are coordinate points on
form
What are Coordinate points?

CCP503.52 9
Example of Pset() with step parameter
Example:
Form1.Pset(2500,2500), vbRed
Form1.Pset Step(100, 100), vbWhite
Form1.Pset (2500, 2500), vbRed
Form1.Pset Step(100, -100), vbBlue
Form1.Pset (2500, 2500), vbRed
Form1.Pset Step(-100, -100), vbMagenta
Form1.Pset (2500, 2500), vbRed
Form1.Pset Step(-100, 100), vbGreen
Form with 5000 X 5000 Coordinates

CCP503.52 10
Example of Pset() with step
parameter

Fig:2

CCP503.52 11
Pset() with variables and Loops
Explanation:
Variables can be used as intX, intY values so
that they can be changed at runtime.
What is runtime?

CCP503.52 12
Pset() with variables and Loops
Example:
x=inputbox(“Give x value”)

y=inputbox(“Give y value”)

Pset(x, y), vbRed

The firs two instructions ask for values for x, y


coordinates and the Pset() draws a point at the
point indicated by x, y coordinates

CCP503.52 13
Pset() with Step and loops
Explanation:
Loops, the control structures for iterations,
can be used to repeat a set of dots with step
parameter so that a series of dots can be
drawn from a fixed point
Example:
Pset(2500,2500), VbRed
for I = 1 to 100
Pset step (100,100)
Next I

CCP503.52 14
The first instruction draws a point in the
middle of the form. The loop draws 100
points, each, 100 points away from previous
point diagonally right down

CCP503.52 15
Some More Examples using loops
and variable with Step parameter
Example:
Pset(2500, 2500), VbGreen
For I = 1 to 10
Pset step (100, 0)
next I
The first instruction sets a point at coordinates
2500(x),2500(y).The loop draws 10 dots from
the above point every 100 twips away on the
same line (x-axis) without changing row(Y-axis)
CCP503.52 16
Assignment:
Write programs to draw lines vertically up, vertically
down, horizontally left, diagonally left up, left down,
right up

CCP503.52 17
Summary
We have discussed about:
 Dots with color parameter

 Dots with Step parameter

 Dots with Step and loops

CCP503.52 18
Quiz – Objective Type

1. The color of a point Pset() draws is set by


_______parameter.
Color

2. The Parameter that draws points as offset of previous


point is _______.
Step

3. In drawing a horizontal line with a loop,


_____coordinate
‘Y’ does not change.

CCP503.52 19
Quiz – Objective Type

1. In drawing a right up diagonal, X coordinate___ ______


increases

and Y coordinate___________.
Decreases

2. Variables cannot be used with Pset()


command________.
False

3. Step is a parameter of Pset() method_______.


True

CCP503.52 20
Frequently Asked Question

1. Explain about Graphics in VB.

CCP503.52 21

Potrebbero piacerti anche