803 Web Application Class XI 1
803 Web Application Class XI 1
CLASS-XI
SESSION-2020-21
(DRAFT STUDY MATERIAL)
Evolution of Internet
In 1876 Bell came forward with the concept of communication through telephone lines
leading to development of Public Switched Telephone Network (PSTN) in 1877. It
opened the new frontiers allowing several homes to connect through telephone lines.
From that time, communication was mainly through telephone lines.
In the late 1950s, all the military communications started using telephone networks
setting up dedicated connections between the two parties. This dedicated connection
made use of technology called circuit switching. The connection consisted of several
intermediary lines and switching offices enroute. They were vulnerable to danger of
damage to the switching offices which may disrupt the entire network. At the peak of the
cold war, the US Department of Defense (DoD) realized the need to establish fault-
tolerant networks that would not fail at the time of nuclear war and could survive a single
point failure in the network. Paul Baran along with Donald Davies and Len Kleinrock
came forward with the idea of digital packet switching in which the message to be
transmitted is divided into small chunks called packets. Unlike circuit switching in which
resources are reserved along the dedicated path of communication, packet switching is
based on link sharing.
The US Department of Defense realized the need to connect geographically separated
research computers together to form a network. This led to the development of
Advanced Research Projects Agency Network (ARPANET) in 1969. ARPANET made
use of technology called digital packet switching. Initially its use was restricted to non-
commercial purposes such as military and research. Subsequently, its use extended to
education by supporting various educational institutes.
Need for communication between various heterogeneous networks led to the
development of TCP/IP (Transmission Control Protocol/Internet Protocol) in 1970. Along
with several smaller networks, another large network called NSFNET was developed in
1984 by NSF, U.S. National Science Foundation for research and education purposes.
When ARPANET and NSFNET were interconnected, the network growth increased
tremendously. TCP/ IP protocol (rules for communication) acted as a glue to connect
various heterogeneous networks together into a single network. This wide network is an
Internet (network of networks).
The Internet is a global network that comprises many voluntarily interconnected
networks. It operates without a central governing body. The standardization of the core
protocols (IPv4 and IPv6) is an activity of the Internet Engineering Task Force (IETF),
To maintain interoperability, the principal name spaces of the Internet are administered
by the Internet Corporation for Assigned Names and Numbers (ICANN). ICANN
coordinates the assignment of unique identifiers for use on the Internet, including
domain names, Internet Protocol (IP) addresses and many other parameters. Several
government and private organizations, collectively called Internet Service Providers
(ISPs) joined hands to provide connectivity for the Internet. The Internet made it
possible to exchange information and communicate with remote nodes. Bandwidth
describes the maximum data transfer rate of a network or Internet connection.
iii) Network Interface Unit (NIU):- A network interface unit is a device that is attached
to each of the workstations and the server which helps to establish communication
between the server and workstations. As soon as a standalone computer becomes a
workstation, it needs an interface to help establish connection with the network because
without this the workstations will not be able to share network resources or
communicate with each other. The NIC basically acts like an interpreter and is also
known as Terminal Access Point (TAP) or Network Interface card(NIC).The NIC
manufacturer assigns a unique physical address to each NIC card and this physical
address is known as the MAC address.
● The data transfer rate (DTR) is the amount of data in digital form that is moved
from one place to another in a given time on a network. As studied before, the
greater the bandwidth of a given medium, the higher is the data transfer rate.
This can also be referred to as throughput, although data transfer rate applies
specifically to digital data streams. Data transfer rate is often measured in bits
per second (bps), although the unit baud , which is one bit per second is also
used. It is commonly used to measure how fast data is transferred from one
location to another. For example, your ISP may offer an Internet connection with
a maximum data transfer rate of 4Mbps.
On the basis of geographical span, the network can be broadly categorized as PAN,
LAN, MAN, and WAN.
● Personal Area Network
A personal area network (PAN) is a computer network used for communication among
computers and devices close to one person. Some examples of devices that are used in
a PAN are personal computers, printers, fax machines, telephones, PDAs, scanners,
and even video game consoles. A PAN may include wired and wireless devices. The
reach of a PAN typically extends to 10 meters.
● Local Area Network
Local Area networks (LAN) are private networks and can span a radius of up to 1 Km.
They are generally established within a building or campus.LANs operate at a speed in
the range 10 Mbps to 1 Gbps.
● Metropolitan Area Network
Metropolitan Area Network (MAN) may be owned by a single organization or by many
individuals or organizations. These networks are used to establish links within a city,
and span an area of radius up to 50 Km. MANs facilitate sharing of resources by
connecting various local area networks For example, a cable television network within a
city.
1.2.1Transmission Medium
A transmission medium refers to the channel of transmission through which data can be
transmitted from one node to another in the form of signal. A signal encodes the data in
a form suitable for transmission on the medium. A medium is characterized by its
bandwidth defining the information carrying capacity of the medium. Common meth methods
of Internet access by users include dial dial-up
up with a computer modem via telephone
circuits, broadband over coaxial cable, fiber optics or copper wires, Wi Wi-Fi, satellite, and
cellular telephone technology (e.g. 3G, 4G).A transmission medium may belong to one
of the following two categories:
● Guided Medium: The term refers to physical conductors such as twisted pairs,
coaxial cable, and fiber optics. In twisted pair and coaxial cable, the signal travels
as voltage and current signal whereas in optical fibre, the signal is in the form of
light.
● Unguided Medium:: The unguided medium uses electro magnetic waves that do
electro-magnetic
not require a physical conductor. Examples of unguided medium include
microwave, radio wave,infrared.
1.2.2.Network Topologies
The arrangement (also called layout) of nodes in a network is called network topology.
There are broadly two types of topologies – broadcast and point to point.
In broadcast topology, all nodes share the same physical link. When one node
transmits, all nodes receive. Collision may occur when more than one node
simultaneously transmits, and there is a collision resolution mechanism for handling it.
Broadcast topologies are mainly bus and ring. In point to point topology, every pair of
nodes has a dedicated link. Popular point to point topologies are star and mesh.
● Bus Topology
In bus topology, there is a long cable, called backbone cable (or simply backbone), that
tha
connects various nodes through a connector called tap as shown in Figure 1.10 In this,
a message sent by one is received by all devices connected to backbone cable. This
topology requires less cabling and is easy to install and extend the network laid using
u it.
however, fault detection and isolation is difficult.
● Ring Topology
In ring topology, all the devices are attached through a cable in the form of ring as
shown in Figure 1.11The message to be communicated is transmitted in one direction,
thereby, relaying the message to the intended recipient. addition and deletion of
ion and isolation is easy. However, the topology suffers from
devices, and fault detection
the limitation of single point failure leading to disruption of the entire network. sending a
message from one node to another node may take more time (four steps while sending
● Mesh Topology
In mesh topology, every node is connected with every other node in the network as
shown in Figure 1.13 Because of dedicated point to point connection between every
transfer without any traffic
possible pair of nodes, the topology provides secure data transfer
problem. it requires a large number of connections to establish the topology. This leads
to difficulty in installation as the number of nodes grow as the network grows.
Fig 1.6 Mesh Topology
● Tree Topology
tree topology is a hybrid topology using a combination of star and bus topology.
Backbone cable in a bus topology acts like the stem of the tree, and star networks (and
even individual nodes) are connected to the main backbone cable like the branches of
tree as shown in Figure 1.14 damage to a segment of a network laid using tree topology
will not affect other segments.installation and configuration is difficult as compared to
other topologies. also, if the backbone cable cable is damaged, the entire network
communication is disrupted
Creation of a network requires various network devices, s, each of which plays a specific
role in the network.
● Repeater
With increase in distance, a signal may become weak and distorted. A repeater is used
to restore the input signal to its original form, so that it can travel a larger distance.
Thus, it is placed between two cable segments as shown in Fig ure 1.8 It is also known
Figure
as digital regenerator which reshapes and amplifies the digital signal.
● Hub
Unlike a repeater which connects two cables, a hub connects several lines, also called,
input/output (I/O) ports, each of which Fig 1.5
cable segments. A hub comprises several input/output
connects to a single cable as shown in Figure 1.5 Data arriving on an incoming line is
output to all lines except the line on which the hub receives the data.
Fig1.5 Hub
● Bridge
ce used for connecting two or more local area networks
A bridge is a multiport device
(LAN), possibly operating at different speeds as shown in Figure 1.6 Thus, a bridge may
be used to produce bigger LAN by combining smaller LANs. A bridge enables devices
on one LAN segment to communicate
communicate with the devices on another LAN segment. Unlike
hubs, they are intelligent devices which exercise discretion while forwarding data to the
outgoing line leading to the destination.
Fig1.6 Bridge
● Switch
Unlike bridges which connect two or more LAN segments, switches are used to connect
individual nodes in the network with each other. Each node within network is connected
to a unique port in the switch as shown in Figure 1.7 On receiving the incoming data
connecting to the destination node. All the nodes
rame, it forwards it to only a single line connecting
connected through switch forms only one LAN.
● Router
Routers are used for connecting various networks (LAN or WAN) with each other as
router transmits data from an incoming network to another
shown in Figure 1.8. A router
network. A route maintains a routing table of various networks. Based on the destination
address, the router determines to which network the incoming packet should be
transmitted.
● RJ-45
RJ-45 nnector that is used to
45 , short form of Registered Jack - 45 , is an eight wired connector
connect computers on a local area network(LAN), especially Ethernet. RJ RJ-45
RJ 11 connector used for connecting telephone
connectors look similar to the RJ-11
equipment, but they are somewhat wider.
● Wi-Fi Card
Wi-Fi cards are small and portable cards that allow your desktop or laptop computer to
connect to the internet through a wireless network. Wi-Fi transmission is through the
use of radio waves. The antenna transmits the radio signals and these signals are
picked up by Wi-Fi receivers such as computers and cell phones equipped with Wi-Fi
cards. These devices have to be within the range of a Wi-Fi network to receive the
signals. The Wi-Fi card then reads the signals and produces a wireless internet
connection. Many newer computers, mobile devices etc. are equipped with wireless
networking capability and do not require a Wi-Fi card.
Network protocols are formal standards and rules that define communication between
two or more devices over a network. They ensure that computer network devices can
transmit and receive data using a common language regardless of their different
designs, hardware or infrastructures. Some of the protocols are listed below.
Transmission Control Protocol / Internet protocol (TCP/IP) TCP/IP are the two protocols
that are used together and together they form the backbone protocol of the internet.
They can also be used for private networks i.e. intranets and extranets. When you are
set up with direct access to the Internet, your computer is provided with a copy of the
TCP/IP program TCP/IP has two major components: TCP and IP.
● Transmission Control Protocol (TCP)
TCP is a popular communication protocol which is used for communicating over a
network. It divides any message into a series of packets that are sent from source to
destination and there it gets reassembled at the destination.
● Internet Protocol (IP)
IP is designed explicitly as addressing protocol. It is mostly used with TCP. The IP
addresses in packets help in routing them through different nodes in a network until it
reaches the destination system. An IP address is a unique identifier for a node or host
connection on an IP network. An IP address is a 32 bit binary number usually
represented as 4 decimal values, each representing 8 bits, in the range 0 to 255 (known
as octets) separated by decimal points. This is known as "dotted decimal" notation.
Example: 140.179.220.200
● Point-to-Point Protocol
PPP (Point-to-Point Protocol) is used for communication between two computers using
a serial interface, mostly a personal computer connected by phone line to a server. For
example, an Internet Service Provider (ISP) may provide you with a PPP connection so
that the ISP's server can respond to your requests, pass them on to the Internet, and
forward your requested Internet responses back to you. It was basically designed to
help communication between two systems through telephone lines as it supports
transmission of network packets over a serial point to point link. PPP is sometimes
considered a member of the TCP/IP suite of protocol
● HyperText Transfer Protocol (HTTP)
HTTP is designed for transferring a hypertext among two or more systems. HTML tags
are used for creating links. These links may be in any form like text or images. HTTP is
designed on Client-server principles which allow a client system for establishing a
connection with the server machine for making a request. The server acknowledges the
request initiated by the client and responds accordingly. HTTP has three important
features. Firstly, it is connectionless. After a request is made, the client disconnects
from the server and waits for a response. To process the request, the server has to re-
establish the connection with the client. Secondly, HTTP is media independent. This
means any type of data(text , images , sound , video etc.) can be sent by HTTP as long
as both the client and server know how to handle the data content. Thirdly HTTP is
stateless.This is because the server and the client are aware of each other only during a
request. Afterwards, they get disconnected. Hence neither the client nor the browser
can retain information between different requests across the web pages.
HTTPS is abbreviated as HyperText Transfer Protocol Secure is a standard protocol to
secure the communication among two computers one using the browser and other
fetching data from a web server. HTTP is used for transferring data between the client
browser (request) and the web server (response) in the hypertext format, same in case
of HTTPS except that the transferring of data is done in an encrypted format. So it can
be said that https thwart hackers from interpretation or modification of data throughout
the transfer of packets.
● File Transfer Protocol (FTP)
FTP allows users to transfer files from one machine to another. Types of files may
include program files, multimedia files, text files, and documents, etc.
● Simple mail transport Protocol (SMTP)
SMTP is designed to send and distribute outgoing EMail.SMTP is a reliable and easy to
set up protocol. Messages either get to a recipient, or there is an error message that
explains why that wasn't possible. One of the purposes of an SMTP is that it simplifies
the communication of email messages between servers. It allows the server to break up
different parts of a message into categories the other server can understand. Any email
message has a sender, a recipient or sometimes multiple recipients - a message body,
and usually a title heading. Once a message goes out on the internet, everything is
turned into strings of text. This text is separated by code words or numbers that identify
the purpose of each section of an email. SMTP provides those codes, and email server
software is designed to interpret these codes. SMTP has a major disadvantage that it is
relatively easy to send a message with a fake sender address. This results in the
spread of many email-based viruses.
● Post office Protocol (POP)
POP3 is designed for receiving incoming Emails. Post Office Protocol 3 or POP3 is the
third version of a widespread method of receiving email which receives and holds email
for an individual until they pick it up. SMTP has a disadvantage that if the destination
computer is not online, mails cannot be received. So the SMTP server receives the mail
on behalf of every host and the respective host then interacts with the SMTP server to
retrieve messages by using a client server protocol called POP3.
● Telnet
Telnet is the main internet protocol for creating a connection with a remote machine. It
allows you to connect to remote computers (called remote hosts) over a TCP/IP network
(such as the Internet). Once your telnet client establishes a connection to the remote
host, your client becomes a virtual terminal, allowing you to communicate with the
remote host from your computer with whatever privileges you may have been granted to
the specific application and data on that host computer.
Web Architecture can be defined as the conceptual structure of the internet. The WWW
or internet is a constantly changing medium that enables communication between
different users and the technical interaction between different systems and
subsystems. The infrastructure of the internet is made of three core components of data
transmission protocols (TCP/IP, HTTP, HTTPS), representation formats (HTML, CSS,
XML), and addressing standards (URI, URL).
Origin of web architecture
The world wide web is a concept that was realized in the 1990s so that people and
machines could communicate with each other within a certain space. It is used to
exchange, distribute, and share information in a network. At that time, the web
consisted predominantly of static websites based on HTML, in other words, hypertexts
that can be retrieved by a browser. Dynamic websites and distributed web services
were added later.
I) Client-server model
Initially, the web consisted of a two-tiered architecture: clients and servers. Clients and
servers shared the tasks and services that the system was supposed to perform. For
example, the client may request a service from the server; the server answers the
request by providing the service. Retrieving a website using a URL address that directs
a server to load the site in the client’s browser is an example of the two-layer model,
also known as the client-server model.
The internet protocol family, which now consists of around 500 different network
protocols, is usually used as the basis for the WWW, but it usually comprises the
TCP/TCP/IP reference model. Three prerequisites must exist in the web architecture for
the application systems to communicate with one another:
● Representation formats with a fixed standard: The most frequently used formats
are HTML(HyperText Mark Up Language) , CSS(Cascading Style Sheet) or XML
(Extensible Mark up Language )when machines communicate with one another.
● The standard for addressing: This refers to the URL (Uniform Resource Locator)
which is an instance of the more general concept of URI.
Finally, the web architecture is the operational structure of application systems for data
storage, data transmission, and presentation. When transferred to the web, the web
architecture typically consists of database servers that manage the data and resources.
They communicate with a client using a transfer protocol that can retrieve the data and
view it in a browser. The representation is usually done with HTML and CSS.
If the Web architecture was represented as an evolutionary timeline, IoT and Semantic
Web would be the top of the development. The architectures that are used there are
correspondingly complex.
The effects of different architectures are extremely diverse. From a user perspective,
websites and web services are changing to a degree that not even developers can keep
track of, what with hundreds of protocols, programming and scripting languages,
frameworks and interfaces. Websites become interactive, data can be exchanged
faster, and services interact with each other easily. From a developer’s perspective,
web architectures are becoming more and more complex and many different
approaches exist at the same time.
● MAC Address
Once a network has been set up, the nodes can communicate among themselves. But
for proper communication, the nodes should be uniquely identifiable. If a node X sends
some information for node Y on a network, then it is mandatory that nodes X and Y are
uniquely identifiable on the network. Let us see how this is achieved.Each NIC has a
universally unique address assigned to it by its manufacturer. This address is known as
the MAC (Media Access Control) address of the card. It means that a machine with an
NIC can be identified uniquely through its NIC's MAC address. The MAC address of an
NIC is permanent and does not change.
MAC addresses are 12-digit hexadecimal (or 48 bit) numbers. By convention, MAC
addresses are usually written in one of the following two formats:
MM:MM:MM:SS:SS:SS
MM-MM-MM-SS-SS-SS
The first half (MM:MM:MM) of a MAC address contains the ID number of the adapter
manufacturer. The second half (SS:SS:SS) of a MAC address represents the serial
number assigned to the adapter (NIC) by its manufacturer.
For example, in the following MAC address,
00:A0:C9 : 14:C8:35
The prefix 00:A0:C9 indicates that the manufacturer is Intel Corporation. And the last
three numbers 14:C8:35 are given by the manufacturer (Intel in this example) to this
NIC.
● IP Address
Every machine in a network has another unique identifying number, called its IP
Address. An IP address is a group of four bytes (or 32 bits) each of which can be a
number from 0 to 255. A typical IP address looks like this:
59.177.134.72
To make it easier for us to remember, IP addresses are normally expressed in decimal
format as a "dotted decimal number" like the one above.
On a network, the IP address of a machine, and not the MAC address of its NIC, is used
to identify it. Do you recall IP protocol? IP protocol identifies a machine with its IP
address to route the packets.
MAC address is used only when a specific machine is to be targeted. For example,
suppose we want to block a specific PC to access some network resource. If we use the
PCs IP address, then the PC is not blocked permanently as its IP address may change
when it connects to the network next time. Instead, if the PCs MAC address is used for
the purpose, then the job is done!
An IP (Internet Protocol) address is a unique 4 digit hexadecimal number assigned to
each node on a network. IP address settings of a node can be changed by the user You
might wonder how an IP address differs from a MAC address. In fact, the IP address is
assigned by the network administrator or the internet service provider while the MAC
address is assigned by the manufacturer. Thus if a computer is transferred from one
network to another, its IP address gets changed whereas the MAC address remains the
same. From the IP address it is usually possible to track the tentative location of the
computer but this is not the case with a MAC address.
● Domain Name
So, whenever we have to communicate with a computer on the internet, we can do so
by using its IP address. But it is practically impossible for a person to remember the IP
addresses of all the computers one may have to communicate with. Therefore, a
system has been developed which assigns names to some computers (web servers)
and maintains a database of these names and corresponding IP addresses. These
names are called Domain Names. Examples of some domain names are cbse.nic.in,
sikkimipr.org, indianrailway.gov.in etc. Domain names are used in URLs to identify
particular Web servers. For example, in the URL http://www.cbse.nic.in/welcome.htm,
the domain name is www.cbse.nic.in.
A domain name usually has more than one parts: top level domain name or primary
domain name and sub-domain name(s). For example, in the domain name , in is the
primary domain name; nic is the sub-domain of in; cbse is the sub-domain of nic.There
are only a limited number of top level domains, and these are divided into two
categories: Generic Domain Names and Country-Specific Domain Names. For example
Generic Domain Names:
·com - commercial business
·edu - Educational institutions
·gov - Government agencies
·mil - Military
·net - Network organizations
·org - Organizations (nonprofit)
.in - India
·au - Australia
·ca - Canada
.ch - China
.nz - New Zealand
.pk - Pakistan
.jp - Japan
.us - United States of America
With the increase in use of the network for accessing data and resource sharing,
security is becoming a prime concern. The Internet represents an insecure channel for
exchanging information, which leads to a high risk of intrusion or fraud, such as
phishing,[viruses, trojans, worms and more.
1.5.1Malwares
The term malware refers to malicious software (programs) designed with the intention to
affect the normal functionality by causing harm to the system, or with the intention of
getting unauthorized access to the system, or denying access to legitimate users of
computing resources. A malware may be a virus, worm, Trojan horse.
● Virus
A virus is a software code that may harm your system by overwriting or corrupting the
system files. A computer virus is similar in action to viruses in our body which replicate
themselves and affect body cells. The affected part is called the infected area. A
computer virus may make several copies of it by inserting its code onto the system
programs, files or boot sector of hard drives and thereby may corrupt them. This causes
the system to slow down or even stop functioning like boot sector virus, file infector
virus, and macro virus.
● Worm
A worm is often received via network, and it automatically keeps on creating several
copies of itself on the hard disk thereby flooding the hard disk. When a worm is received
as an email attachment, it is automatically forwarded to the recipients leading to network
congestion. Thus a worm may crash the system and entire network. No host application
is required for worms to replicate themselves e.g. Code Red Worm which makes more
than 2,50,000 copies of itself in approximately 9 hours.
● Trojan Horse
Trojan Horse is a code that appears to be desirable and useful but ends up harming the
system.Trojan horse can attach itself with a safe application. For example, it may be
attached to any game downloaded over the Internet. Such an application when
executed creates a backdoor in the system through which a hacker can access the
system. The hacker can monitor all the activity performed on the system. He can also
control the infected system by harming the data on the system. For example, in the late
1990s, Trojan Horse named Sub7 was created which took advantage of security flaws
of earlier version browsers such as Internet Explorer and Chrome to illegally access the
host computer.
1.5.2 Evesdropping
Eavesdropping is the act of secretly or stealthily listening to the private conversation or
communications of others without their consent. Eavesdropping is done through
telephone lines, cellular networks, email, and instant messaging.
1.5.3 Denial of Service
A denial-of-service attack (DoS attack) is a cyber-attack in which the machine or
network resource becomes unavailable to its users by temporarily or indefinitely
disrupting services.. Denial of service is typically accomplished by flooding the targeted
machine or resource with superfluous requests in an attempt to overload systems and
prevent requests from being fulfilled. A DoS attack is like a group of people crowding
the entry door of a shop, making it hard for legitimate customers to enter.
1.5.4.4Phishing
Phishing refers to the act of stealing a user's personal information through fraud mails.
These emails eit4er entail personal information through embedded forms, or contain
links to the web page that may prompt you to provide this information. Information
attempted to be stolen may include bank account number, debit/credit card number,
passwords or any other valuable data
Since the Internet has emerged as a prime tool for sharing resources and accessing
data, an exponentially growing number of users are using it with both good and bad
intentions. Everyone accessing the Internet needs to be aware of the security issues
and take protective measures to address the same.
1.5.1Firewalls
A password manager is a software application that helps a user store and organize
passwords. Password managers usually store passwords encrypted, requiring the user
to create a master password; a single, ideally very strong password which grants the
user access to their entire password database from top to bottom
1.5.4 Protective Measures while accessing Internet
● Never click on a suspicious link specified on a web page or send through a mail
for which you are not sure about its authenticity.
● Make sure that passwords are strong and are changed frequently. Passwords
are the means for authenticating users, thereby allowing access to networked
systems. Weak passwords have smaller length and use a small subset of
possible characters, and thus, are subjected to be cracked easily. One should
also avoid setting obvious passwords such as names, mobile numbers, or date of
birth. Passwords should be strong, having long length and including characters
such as numbers and punctuation signs.
● Never disclose personal information such as date of birth, home address,
personal phone number, account details, passwords, credit and debit card
details, work history details.
● Report phishing issues to the concerned authorities or at cybercrime.gov.in. In
case of unsolicited mails, mark them as spam mails.
● Security of the communication made over the Internet can be indicated by the
security of protocol being used. Secure HyperText Transfer Protocol (HTTPs) is
a secure version used for communication between client and host on the
Internet. So, ensure that all communications are secure, especially online
transactions.The security of the website can be ensured if there is a padlock on
the left side of the address bar. It indicates that the website has a SSL (Secure
Socket Layer) digital certificate issued by a trusted party which ensures and
proves the identity of the remote host.
● Ensure that the web browser being used for accessing the web is updated and is
secure. For example, chrome browser is up to date, if the security patch
indicated by three dots on top right corner are grey in color. Green, orange and
red color security patches indicate that browser update is available for two, four
and seven days Respectively.
● Be selective while making friends on the social networking site. Do not send or
accept friendship requests from any unknown user. Also, trust the authenticity of
a message only if you are sure about its origin (sender).
● Do not post any offensive content on social networking site as it may lead to a
criminal
action against you.
● Beware before spreading any kind of a rumor as it may be treated as a cyber-
crime.
● If someone is harassing or threatening you, take snapshot of it as a proof, and
block
the person. Also, report the incident to the site administrator.
● Use updated antivirus and firewall, secure browsing, and password management
techniques.
● Make sure that the website address is properly spelled. Because there may be
two websites with almost the same name, one being a phishing website.
● Delete cookies periodically. A cookie is a small piece of information about the
client browsing a website. On receiving a request from a client, the server
records the client information such as domain name and registration id on the
server site in the form of a file or a string. The server sends this cookie along with
the response requested by the client. At the client side, the browser stores this
cookie received from the server in a directory called cookie directory. By
obtaining access to these cookies, hackers may gain unauthorized access to
these websites. Thus, cookies should be deleted occasionally along with the
temporary files stored on our system during web browsing.
Intellectual property rights are the rights given to an individual over the invention of their
own. They usually give the creator an exclusive right over the use of his/her creation for
a certain period of time. There are only three ways to protect intellectual property
● Patent is a term used for a specific product designed by an individual. The
designer is given exclusive rights over the patent for a limited period of time. With
help of the patent right, the owner can stop others from making, using or selling
the product design. The owner can take a legal action if someone uses the
patent without his/ her permission In order to obtain a patent, the following
conditions should be met: The product should be new It should be capable of
being made or used in some kind of industry It should not be a scientific or
mathematical discovery It should not be a dramatic, musical dramatic or artistic
work
● Trademark can be defined as a name or a different sign or a device identifying a
product or a service. The product or the service is produced or provided by a
specific person or a company. A Trademark is also known as brand name.It
should be officially registered and legally restricted to the use of the specific
person or the company.
● Copyright is the term used for a written document. A legal action can be taken, if
copyrights are violated. The following category of work can be considered for
copyrights. literary works musical works, including any accompanying words
Points to Remember
LONG ANSWERS
1. What is a network? Give any two uses of having a network in your school computer lab.
2. Mention any two disadvantages of a network.
3. What are the requirements for setting up a network?
4. How is a dedicated server different from a non dedicated server?
5. Define a channel. Name the three categories of communication channels.
6. What do you mean by bandwidth and DTR?
7. Two companies in different states wanted to transfer information. Which type of network will be
used to implement the same?
8. Two schools in the same city wanted to transfer e-learning information. Which type of network will
be used to implement the same?
9. Two teachers in the same school sitting in different labs wanted to transfer information. Which
type of network will be used to implement the same?
10. What do you mean by a transmission medium? Differentiate between guided and unguided
transmission media.
11. Define the term topology.
12. List any two advantages and any two disadvantages of Star topology.
13. How is Tree Topology different from Bus topology?
14. Identify the type of topology from the following.
a. Each node is connected with the help of a single cable.
b. Each node is connected with the help of independent cable with central switching.
15. Ms. Anjali discovered that the communication between her centre and the primary block of the
school is extremely slow and signals drop quite frequently. The distance between these two blocks is
140 meters.
a. Name the type of network.
b. Name the device which may be used for smooth communication.
16. ABC International School is planning to connect all computers, each spread over a distance of
50 meters. Suggest an economic cable type having high speed data transfer to connect these
computers.
17. Sahil wants to transfer data across two continents at very high speed. Write the name of the
transmission medium that can be used to do the same. Write the type of network also.
18. Mayank wants to transfer data within a city at very high speed. Write the name of the wired
transmission medium that he should use. Write the type of network also.
19. Mr. Akash wants to send/receive email through the internet. Which protocol will be used for this
purpose?
20. Answer the following questions in the context of a computer lab with 100 computers.
a. Which device is used to connect all computers inside the lab?
b. Which device is used to connect all computers to the internet using telephone wire?
21. Name the device that establishes an intelligent connection between a local network and external
network with completely different structures.
22. Name the network device that works like a bridge to establish connection between two networks
but it can also handle networks with different protocols.
23.Neha wants to upload and download files from/to a remote internal server. Write the name of the
relevant communication protocol, which will let her do the same.
24. Meha wants to upload hypertext documents on the internet. Write the name of protocol, which
will let her do the same.
25. This protocol is used for communication between two personal computers using a serial interface
and connected by a phone line. Write the name of the protocol.
26. This protocol is used to transfer email over the internet. What is the name of the protocol?
27. This protocol is used to implement remote login. What is the name of the protocol?
28. This protocol is used for chatting between two groups or between two individuals. Write the
name of the protocol.
29. This protocol is used to transfer voice using packet switched networks. Write the name of the
protocol.
30. Explain Remote Access Protocol.
31. Why do we need VoIP protocol?
32. Differentiate between FTP and HTTP.
33. Differentiate between VoIP and IRC.
34. Explain the three types of web architecture
35. Differentiate between IP address and MAC address
36.Differentiate between Worm and Virus
37.Explain the significance of the IT Act.
38. Explain the following terms: Patent Copyright Trademark
39. Differentiate between hacking and cracking
40. Rohan wants to prevent unauthorized access to/from his company's local area network. Write
the name of the system, which he should install to do the same.
41. When the user browses a website, the web server sends a text file to the web browser. What is
the name of this?
42. It is defined as a crime in which a computer and internet is used in an illegitimate way to harm
the user. What is the name of this crime?
43. A person who gains unauthorized access to a computer with the intention of causing damage.
What is the name of this crime?
UNIT - 2
WEBSITE DEVELOPMENT USING HTML AND CSS
What is Website?
A website is a collection of web pages which contains the information about the
particular organization or institution or any product. It contains the related content
that is identified by a common domain name and published on any one web server.
Few examples of such websites are bing.com,
wikipedia.org, google.com, amazon.com etc. A website can be opened using the
software known as Browser. Commonly used browsers are Google Chrome, Internet
Explorer, Mozilla Firefox etc.
Purpose
Websites are developed for a particular purpose, such as commerce, education,
media and entertainment, or social networking. It can be the work of an individual, a
business or other organization for the interest of public or any personal reasons. It
helps to communicate with the world anytime, anywhere irrespective of distance.
Today the world has become a global market for the businesses also.
Static website
A static website is stored on the web server in the format that has to be sent to a
client web browser. It is mainly coded in Hypertext Markup Language (HTML)
and Cascading Style Sheets (CSS) to control the appearance of the website. These
are non-interactive websites which are only used to display the same information to
all visitors. If any changes are to be made then website owner can do it.It is a
manual process to edit the text, photos and other content and may require basic
website design skills and software. After the changes again it is published on the
same domain. Website containing the basic information or a brochure website are
often come under this category as these websites contains the present pre-defined,
static information to the user.
Dynamic website
Prerequisites
You will need a text editor, such as Notepad and an Internet browser, such as Internet
Explorer or Netscape Navigator.
Q: What is Notepad and where do I get it?
A: Notepad is the default Windows text editor. On most Windows systems, click your Start
button and choose Programs then Accessories. Its icon is a little blue notebook. Mac Users:
SimpleText is the default text editor on the Mac. In OSX use TextEdit and change the
following preferences: Select (in the preferences window) Plain text instead of Rich text and
then select Ignore rich text commands in HTML files. This is very important because if you
don’t do this HTML codes probably won’t work. One thing you should avoid using is a word
processor (like Microsoft Word) for authoring your HTML documents.
What is an Html File?
The documents themselves are plain text files with special “tags” or codes that a web
browser uses to interpret and display information on your computer screen.
Try It:
Open your text editor and type the following text:
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
This is my first homepage. <b>This text is bold</b>
</body>
</html>
Example Explained
What you just made is a skeleton html document. This is the minimum required
information for a web document and all web documents should contain these basic
components.
The first tag in your html document is <html>. This tag tells your browser that this is
the start of an html document.
The last tag in your document is </html>. This tag tells your browser that this is the
end of the html document.
The text between the <head> tag and the </head> tag is header information.
Header information is not displayed in the browser window.
The text between the <title> tags is the title of your document.
The <title> tag is used to uniquely identify each document and is also displayed in
the title bar of the browser window.
The text between the <body> tags is the text that will be displayed in your browser.
The text between the <b> and </b> tags will be displayed in a bold font.
1.2 Basic HTML Tags
The most important tags in HTML are tags that define headings, paragraphs and line
breaks.
Headings
Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading
while <h6> defines the smallest.
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
<h6> This is a heading</h6>
HTML automatically adds an extra blank line before and after a heading. A useful
heading attribute is “align”.
Paragraphs are defined with the <p> tag. Think of a paragraph as a block of text.
You can use the align attribute with a paragraph tag as well.
Line Breaks
The <br> tag is used when you want to start a new line, but don’t want to start a new
paragraph. The <br> tag forces a line break wherever you place it. It is similar to
single spacing in a document.
Horizontal Rule
The <hr> element is used for horizontal rules that act as dividers between sections,
like this:
The horizontal rule does not have a closing tag. It takes attributes such as align and
width.
For instance:
Comments in HTML
The comment tag is used to insert a comment in the HTML source code. A comment
can be placed anywhere in the document and the browser will ignore everything
inside the brackets. You can use comments to write notes to yourself, or write a
helpful message to someone looking at your source code.
Note: - You don’t see the text between the tags <!-- and -->. If you look at the source
code, you would see the comment. To view the source code for this page, in your
browser window, select View and then select Source.
There are logical styles that describe what the text should be and physical styles
which actually provide physical formatting. It is recommended to use the logical tags
and use style sheets to style the text in those tags.
Character tags like <strong> and <em> produce the same physical display as
<b>and <i> but are more uniformly supported across different browsers.
Some characters have a special meaning in HTML, like the less than sign (<) that
defines the start of an HTML tag. If we want the browser to actually display these
characters we must insert character entities in place of the actual characters
themselves.
The Most Common Character Entities:
A character entity has three parts: an ampersand (&), an entity name or an entity
number, and finally a semicolon (;). The & means we are beginning a special
character, the; means ending a special character and the letters in between are sort
of an abbreviation for what it’s for. To display a less than sign in an HTML document
we must write: < or< the advantage of using a name instead of a number is
that a name is easier to remember. The disadvantage is that not all browsers support
the newest entity names, while the support for entity numbers is very good in almost
all browsers.
The <body> tag has two attributes where you can specify backgrounds. The
background can be a color or an image.
Bgcolor
The bgcolor attribute specifies a background-color for an HTML page. The value of
this attribute can be a hexadecimal number, an RGB value, or a color name:
<body bgcolor=“#000000”>
<body bgcolor=“rgb(0,0,0)”>
<body bgcolor=“black”>
Background
The background attribute can also specify a background-image for an HTML page.
The value of this attribute is the URL of the image you want to use. If the image is
smaller than the browser window, the image will repeat itself until it fills the entire
browser window.
<body background=“clouds.gif”>
<body background=“http://profdevtrain.austincc.edu/html/graphics/clouds.gif”>
The URL can be relative (as in the first line above) or absolute (as in the second line
above).
Will the background image increase the loading time too much?
Will the background image look good with other images on the page?
Will the background image look good with the text colors on the page?
Will the background image look good when it is repeated on the page?
Will the background image take away the focus from the text?
Note: The bgcolor, background, and the text attributes in the <body> tag are
deprecated in the latest versions of HTML (HTML 5).
The World Wide Web Consortium (W3C) has removed these attributes from its
recommendations. Cascading Style sheets (CSS) should be used instead (to define
the layout and display properties of HTML elements).
Try It Out!
<html>
<head>
<title>My First Webpage</title>
</head>
<body background=“http://profdevtrain.austincc.edu/html/graphics/clouds.gif”
bgcolor=“#EDDD9E”>
</body>
</html>
Webpages in a website can be linked with each other with the help of tags. HTML
uses the <a> anchor tag to create a link to another document or web page.
Internal Linking
A webpage is linked within the same web page. It is done by using an absolute path or
relative path of a link. The internal link name is followed by the hash sign(#).By assigning an
id to refer section of the webpage, which is referred to as an internal link to the same page.
Syntax:
<a name= “#Text” ></a>
<a hreaf=”#Text”></a>
Try it!
<html>
<b>Gender </b>
<Br>
Comment<Br>
</Form>
</html>
Note : In the above example highlighted text depicts the internal linking. Try the
above code and see the output in the browser window.
External Linking
The Anchor Tag and the “href” Attribute
An anchor can point to any resource on the Web: an HTML page, an image, a sound
file, a movie, etc.
With the target attribute, you can define where the linked document will be opened.
By default, the link will open in the current window. The code below will open the
document in a new browser window:
Email Links
To create an email link, you will use mailto: plus your email address.
To add a subject for the email message, you would add? subject= after the email
address.
For example:
The <img> tag is an empty tag, which means that it contains attributes only and it
has no closing tag. To display an image on a page, you need to use the src attribute.
Src stands for “source”. The value of the src attribute is the URL of the image you
want to display on your page.
When you have an image, the browser usually figures out how big the image is all by
itself. If you put in the image dimensions in pixels however, the browser simply
reserves a space for the image, then loads the rest of the page. Once the entire
page is loaded it can go back and fill in the images. Without dimensions, when it runs
into an image, the browser has to pause loading the page, load the image, then
continue loading the page.
Image Alignment
You can set the alignment of an image also to make your webpage more
presentable.
There are five types of alignment which can be applied on the image are as follows:
Left
Right
Top
Bottom
Middle
Note: By default, images are left aligned. The image with the top and bottom
alignment will be set at the top of the line or bottom of the line.
Few examples are given for your reference rest you can try it by changing the
alignment in the html code.
Open the file mypage2.html in your text editor and add code highlighted in bold:
Try It!
(An image with “middle” alignment.)
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1 align="center">My First Web page</h1>
<p>Welcome to my first webpage. I am writing this page using a text editor
and plain
old html.</p>
<p>By learning html, I’ll be able to create web pages like a pro....<br>
which I am of course.
<!-- Who would have guessed how easy this would be :) -->
<imgsrc="C:\Users\Desktop
Desktop\graphics\chef.jpg"
align="middle" width=130 h
height=101 alt="Smiling Happy Chef">
<p align="center">This is my Chef</p>
</body>
</html>
OUTPUT:
Try It!
OUTPUT
You can try inserting images of different types such as PNG, JPEG, GIF, BMP etc.
with all the attributes of img tag.
1.7 Tables
Tables are defined with the <table> tag. A table is divided into rows (with the <tr>
tag),and each row is divided into data cells (with the <td> tag). The letters td stands
fortable data, which is the content of a data cell. A data cell can contain text, images,
lists,paragraphs, forms, horizontal rules, tables, etc.
To display a table with borders, you will use the border attribute.
There are various tag, which help us in enhancing the appearance of a web page. Using
<audio> and <video> tags, you will be able to incorporate Multimedia in your webpage and
can make your webpage more alive.
Inserting Audio
To insert an audio<AUDIO>tag is used in a web page.It can be used for any file format like .
MP3 e,.ogg, .wav etc.
Syntax:
Inserting Video
To insert video in the HTML pages video tag is used it supports file formats like .MP4,
.webm, .ogg etc.
Syntax
Try it!
<HTML>
<Head>
<Title> My first page </Title>
</Head>
<Body>
Check the video clip.
<video controls src = “ videofilename.mp4 “ width = 720 height= 540 autoplay>
please check your browser settings </video>
</Body>
</HTML>
Note:
If the browser does not support audio in video tag, then any text placed between
<audio></audio> and <video></video> tag will be displayed in the browser.
1.8 Frames
Syntax
<iframe src= “ “ height=200 width = 200 style= “ border- width: ;border- style:
, Border- color: “></iframe>
Example
<HTML>
<Head>
<Body>
</Body>
</HTML>
Output:
1.9 Forms
Syntax:
1. NAME -This specifies the name of the form. But this name will not be displayed on
the
form. As there can be more than one FORMs in an HTML document, a name is
required to differentiate one form from another. The NAME attribute is
optional if there is only one FORM on the web page.
NAME = "FormName"
2. ACTION - This specifies the URL where the form-data is sent when the form is
submitted.This URL is also called the destination of the form.
ACTION = "URL"
Syntax:
<INPUT TYPE = “FIELD TYPE” NAME = “FIELD NAME” VALUE = “FIELD TEXT”>
Attributes of INPUT element are discussed below:
Attribute:
TYPE
Use: The TYPE attribute determines the field type of input field to be provided in the
form.
Syntax:TYPE = "FieldType"
NAME
Use: Specifies the name of the field. This name does not appear on the FORM. It is
required for the identification/ differentiation as there can be more than one fields in a single
FORM.
VALUE
We will now discuss different field types (values of TYPE attribute) relevant to our syllabus.
1. FieldType: TEXT
Use: It provides a single line text input field where the user can enter text. Additional
Attributes:SIZE = "n" - Sets the visible size of the text field to n characters.
MAXLENGTH = "n" - Set the maximum number of characters that
can be input in the text field to n.
2. FieldType: PASSWORD
Use: It provides a single line text input field where the user can enter password.
A password field is different from a text field because a text field displays
whatever characters are entered by the user whereas a password field shows
one dot for each character input by the user. This is to prevent others from seeing the
password.
3. FieldType: RADIO
Use: It provides a radio button on the form. More than one radio buttons can have
(and in general have) the same name. All the radio buttons that have the same name
constitute a radio group. Only one radio button of a group can be selected at one
time. That is, from a group of radio buttons, if the user selects a button, all the other
buttons in the set are deselected. When a form is submitted, selected radio button's
value (specified by the VALUE attribute) is submitted to the destination.
Additional Attributes:
CHECKED - Indicates that the radio button is selected, which can be deselected
when another choice is made. At one time, only one radio button in a radio group can
be specified as CHECKED.
4. FieldType: CHECKBOX
Use: It provides a check box on the form. With checkboxes, we can give the users a
list of items to choose from. The user can choose more than one items from the list.
We can make a group of checkboxes, by giving them the same name. When a form
is submitted, selected cheboxes' values (specified by the
VALUE attribute) are submitted to the destination.
Additional Attributes:
CHECKED - Indicates that the checkbox is to be displayed with a tick mark to show
selection. This attribute is optional.
5. FieldType: SUBMIT
Use: This provides a button on the form. When this button is clicked, the form is
submitted to the destination.
6. FieldType: RESET
Use: This provides a button on the form. When this button is clicked, the input fields
on the form are reset to their default state.
Example:
TRY IT!
<html>
<b>Gender </b>
<Br>
Comment<Br>
</Form>
</body>
</html>
Points to Remember:
Exercise
Practical Work:
1. Create a website for “Tour and Travel” company.
2. Create a website on the topic – “Digital India”.
3. Create a website on famous Sports of the World.
Note: A website must contain at least 4-5 webpages.
Section-2: Basics About CSS
Cascading Style Sheets (CSS) describe how documents are presented on screens,
in print, or perhaps how they are pronounced. W3C has actively promoted the use of
style sheets on the Web since the Consortium was founded in 1994. Cascading
Style Sheets (CSS) provide easy and effective alternatives to specify various
attributes for the HTML tags. Using CSS, you can specify a number of style
properties for a given HTML element. Each property has a name and a value,
separated by a colon (:). Each property declaration is separated by a semi-colon (;).
Pages load faster – If you are using CSS, you do not need to write HTMLtag
attributes every time. Just write one CSS rule of a tag and apply to all the
occurrences of that tag. So less code means faster download times.
Easy maintenance – To make a global change, simply change the style, and
all elements in all the web pages will be updated automatically.
Superior styles to HTML – CSS has a much wider array of attributes than
HTML so you can give far better look to your HTML page in comparison of
HTML attributes.
Global web standards – Now HTML attributes are being deprecated and it is
being recommended to use CSS. So it’s a good idea to start using CSS in all
the HTML pages to make them compatible to future browsers.
Example First let’s consider an example of HTML document which makes use of
<font> tag and associated attributes to specify text color and font size:
<!DOCTYPE html>
<html>
<head>
<title>HTML CSS</title>
</head>
<body>
<p><font color=“green”size=“5”>Hello, world!</font></p>
</body>
</html>
We can re-write above example with the help of Style Sheet as follows:
<!DOCTYPE html>
<html>
<head>
<title>HTML CSS</title>
</head>
<body>
<p style=“color:green;font-size:24px;”>Hello, World!</p>
</body>
</html>
Hello, World!
Internal Style Sheet – Define style sheet rules in header section of the HTML
document using <style> tag.
Inline Style Sheet – Define style sheet rules directly along with the HTML
elements using style attribute. Let’s see all the three cases one by one with
the help of suitable examples.
If you need to use your style sheet to various pages, then it’s always recommended
todefine a common style sheet in a separate file. A cascading style sheet file will
have extension as css and it will be included in HTML files using <link> tag.
Example
Consider we define a style sheet file style.css which has following rules:
.red{
color: red;
}
.thick{
font-size:20px;
}
.green{
color:green;
}
Here we defined three CSS rules which will be applicable to three different classes
defined for the HTML tags. I suggest you should not bother about how these rules
arebeing defined because you will learn them while studying CSS.
<!DOCTYPE html>
<html>
<head>
<title>HTML External
CSS</title>
<link rel=“stylesheet”
type=“text/css”href=“/html/stml
/style.css”>
/head>
<body>
<p class=“red”>This is red</p>
<p class=“thick”>This is
thick</p>
<p class=“green”>This is
green<p>
<p class=“thick green”>This is
thick and green</p>
</body>
</html>
If you want to apply Style Sheet rules to a single document only then you can include
those rules in header section of the HTML document using <style> tag.
Rules defined in internal style sheet override the rules defined in an external CSS
file.
Example
Let’s re-write above example once again, but here we will write style sheet rules in
the same HTML document using <style> tag:
<!DOCTYPE html>
<html>
<head>
<title>HTML Internal CSS</title>
<style type=“text/css”>
.red{
color: red;
}
.thick{
font-size:20px;
}
.green{
color:green;
}
</style>
</head>
<body>
<p class=“red”>This is red</p>
<p class=“thick”>This is thick</p>
<p class=“green”>This is green</p>
<p class=“thick green”>This is thick and green</p>
</body>
</html>
This is red
This is thick
This is green
You can apply style sheet rules directly to any HTML element using style attribute of
the relevant tag. This should be done only when you are interested to make a
particular change in any HTML element only.
Rules defined inline with the element overrides the rules defined in an external CSS
fileas well as the rules defined in <style> element.
Example
Let’s re-write above example once again, but here we will write style sheet rules
alongwith the HTML elements using style attribute of those elements.
<!DOCTYPE html>
<html>
<head>
<title>HTML Inline CSS</title>
</head>
<body>
<p style=“color:red;”>This is red</p>
<p style=“font-size:20px;”>This is thick</p>
<p style=“color:green;”>This is green</p>
<p style=“color:green;font-size:20px;”>This is thick and green</p>
</body>
</html>
This is red
This is thick
This is green
This is thick and green
A CSS comprises of style rules that are interpreted by the browser and then applied
to the corresponding elements in your document. A style rule is made of three parts:
Selector: A selector is an HTML tag at which style will be applied. This could
be any tag like <h1> or <table> etc.
Property: A property is a type of attribute of HTML tag. Put simply, all the
HTML attributes are converted into CSS properties. They could be color or
border etc.
Value: Values are assigned to properties. For example, color property can
have value either red or #F1F1F1 etc.
Here table is a selector and border are a property and given value 1px solid #C00 is
the value of that property. You can define selectors in various simple ways based on
your comfort. Let me put these selectors one by one.
h1 {
color: #36CFFF;
}
{
color: #000000;
}
This rule renders the content of every element in our document in black.
ul em {
color: #000000;
}
The Class Selectors
You can define style rules based on the class attribute of the elements. All the
elements having that class will be formatted according to the defined rule.
.black {
color: #000000;
}
This rule renders the content in black for every element with class attribute set to
blackin our document. You can make it a bit more particular.
For example:
h1.black {
color: #000000;}
The ID Selectors
You can define style rules based on the id attribute of the elements. All the elements
having that id will be formatted according to the defined rule.
#black {
color: #000000;
}
You have seen descendant selectors. There is one more type of selectors which is
very similar to descendants but have different functionality. Consider the following
example:
body > p {
color: #000000;
}
This rule will render all the paragraphs in black if they are direct child of <body>
element.
Other paragraphs put inside other elements like <div> or <td> etc. would not have
any effect of this rule.
input[type=“text”]{
color: #000000;
}
The advantage to this method is that the <input type=“submit” /> element is un
affected, and the color is applied only to the desired text fields.
p[lang=“fr”] - Selects all paragraph elements whose lang attribute has a value
ofexactly “fr”.
p[lang =“fr”] - Selects all paragraph elements whose lang attribute contains
the word“fr”.
You may need to define multiple style rules for a single element. You can define
these rules to combine multiple properties and corresponding values into a single
block as defined in the following example:
h1 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
Here all the properties and value pairs are separated by a semi colon (;). You can
keep them in a single line or multiple lines. For better readability we keep them into
separate lines.
Grouping Selectors
You can apply a style to many selectors if you like. Just separate the selectors with a
comma as given in the following example:
h1, h2, h3 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
This define style rule will be applicable to h1, h2 and h3 element as well. The order
of the list is irrelevant. All the elements in the selector will have the corresponding
declaration sapplied to them.
We have discussed four ways to include style sheet rules in a HTML document. Here
is the rule to override any Style Sheet Rule.
Any inline style sheet takes highest priority. So, it will override any rule
defined in<style>...</style> tags or rules defined in any external style sheet
file.
Any rule defined in external style sheet file takes lowest priority and rules
defined in this file will be applied only when above two rules are not
applicable.
CSS Comments
Many a times you may need to put additional comments in your style sheet blocks.
So, it is very easy to comment any part in style sheet. You simply put your comments
inside /*this is a comment in style sheet*/.
You can use /* ....*/ to comment multi-line blocks in similar way you do in C and C++
programming languages.
Example
A hexadecimal value can be taken from any graphics software like Adobe
Photoshop, Jasc Paintshop Pro or even using Advanced Paint Brush.
Each hexadecimal code will be preceded by a pound or hash sign #. Following are
the examples to use Hexadecimal notation.
This colourr value is specified using the RGB(( ) property. This property takes three
values, one each for red, green, and blue. The value can be an integer between 0
and 255 or a percentage.
Note: All the browsers do not support RGB() () property of color so it is recommended
not to use it. Following is the example to show few colors using RGB values.
Following is the example which demonstrates how to set the background image for
an element.
<table style=“background
style=“background-image:url(/https/www.scribd.com/images/pattern1.gif);”>
<tr><td>
This
Set thetable has background
background image set.
image position
</td></tr>
</table>is the example which demonstrates how to set the background image
Following
position 100 pixels away from the left side.
<table style=“background
style=“background-image:url(/https/www.scribd.com/images/pattern1.gif);
background-position:100px;”>
position:100px;”>
<tr><td>
Background image positioned 100 pixels away from the left.
</td></tr>
</table>
Set the background attachment
<p style=“background-image:url(/https/www.scribd.com/images/pattern1.gif);
background-attachment:scroll;”>
This parapgraph has scrolling background image.
</p>
This will teach you how to set fonts of a content available in an HTML element. You
can set following font properties of an element:
The font-family property is used to change the face of a font.
The font-style property is used to make a font italic or oblique.
The font-variant property is used to create a small-caps effect.
The font-weight property is used to increase or decrease how bold or light a
font appears.
The font-size property is used to increase or decrease the size of a font.
The font property is used as shorthand to specify a number of other font
properties.
Following is the example which demonstrates how to set the font family of an
element.
Possible value could be any font family name.
<p style=“font-family:georgia,garamond,serif;”>
This text is rendered in either georgia, garamond, or the default
serif font depending on which font you have at your system.
</p>
Following is the example which demonstrates how to set the font style of an element.
Possible values are normal, italic and oblique.
<p style=“font-style:italic;”>
This text will be rendered in italic style
</p>
Set the font variant
Following is the example which demonstrates how to set the font variant of an
element.
<p style=“font-variant:small-caps;”>
This text will be rendered as small caps
</p>
Following is the example which demonstrates how to set the font size of an element.
The font size property is used to control the size of fonts. Possible values could be
xx-small, x-small, small, medium, large, x-large, xx-large, smaller, larger, size in
pixels or in %.
<p style=“font-size:20px;”>
This font size is 20 pixels
</p>
<p style=“font-size:small;”>
This font size is small
</p>
<p style=“font-size:large;”>
This font size is large
</p>
This tutorial will teach you how to manipulate text using CSS properties. You can set
following text properties of an element:
Following is the example which demonstrates how to set the text color. Possible
value could be any color name in any valid format.
<p style=“color:red;”>
This text will be written in red.
</p>
Following is the example which demonstrates how to set the direction of a text.
Possible values are ltr or rtl.
<p style=“direction:rtl;”>
This text will be renedered from right to left </p>
Following is the example which demonstrates how to set the space between
characters. Possible values are normal or a number specifying space.
<p style=“letter-spacing:5px;”>
This text is having space between letters.
</p>
Following is the example which demonstrates how to align a text. Possible values
are left, right, center, justify.
<p style=“text-align:right;”>
This will be right aligned.
</p>
<p style=“text-align:center;”>
This will be center aligned.
</p>
<p style=“text-align:left;”>
This will be left aligned.
</p>
CSS – Images
Images are very important part of any Web Page. Though it is not recommended to
include lot of images but it is still important to use good images wherever it is
required.
CSS plays a good role to control image display. You can set following image
properties using CSS.
The border property of an image is used to set the width of an image border. This
property can have a value in length or in %. A width of zero pixels means no border.
Here is the example:
Exercise Question
2. What are the ways in which you can use CSS in your HTML document?
(a) ____________ Defines style sheet rules in a separate .css file and then include
(c) A cascading style sheet file will have extension as __________ and it will be
included in HTML files using ____________ tag.
Practical Work:
The Domain Name System (DNS) is the directory that maps domain names to IP
addresses. DNS is built around the hierarchical domain namespace that we dis-
cussed earlier. DNS is a distributed directory and serves as enabling infrastructure
for a single, global directory of domain names. This directory is built from
thousands of servers owned by thousands of organizations around the world.
Host aliasing:
A host with complicated hostname can have one or more alias names. DNS can be
invoked by an application to obtain the canonical hostname for a supplied alias
hostname as well as the IP address of the host.
DNS can be invoked by a mail application to obtain the hostname for a supplied alias
hostname as well as the IP address of the host.
Name spaces are of two types: Flat name spaces and Hierarchical Names. The
name assigned to machines must be carefully selected from a namespace with
complete control over the binding between the names and IPaddresses.
Hierarchical names:
The partitioning of a namespace must be defined in such a way that it: Supports
efficient name mapping and Guarantees autonomous control of name assignment.
Hierarchical namespaces provides a simple yet flexible naming structure. The
namespace is partitioned at the top level. Authority for names in each partition are
passed to each designated agent The names are designed in an inverted-tree
structure with the root at the top.
The Doman Name System (DNS) is used to map a name to a static IP address.
Computers use these to communicate with themselves using aa name. When a
computer requests a URL the DNS translates that name into the corresponding IP
address.
When you sign up for a Web site, one of the first things you ’il have to do is determine
a domain name for your site. Then, you register your domain name with n domain
registrar.
Domain registrars register your domain name and hook you up to the Internet by
making sure your domain name is added to a huge database of domain names that
are mapped to specific IP addresses.
Some Web hosting companies actually take care of this process for you, so you
may be able to skip these steps. Some registrars also act as hosting services, and
will try to sell you a hosting plan. Keep in mind that you’re under no obligation to host
your site using the services of the registrar you use to register your site.
The Final phase of creating a web site is publishing your pages. To place your pages
on the web you need a web server. Commonly called hosts, web servers allow you
to transfer and store files including HTML documents, images and multimedia files.
Unless you have your own web server, you need to find a server to host your pages.
http://www.godaddy.com/
http://www.1and1.com
http://www.virtualempre.com
But of course there are many more, Make sure you choose a webhost which
supports FTP, which makes it much easier to publish your pages from web builder.
Page to publish
In this section of the publish window you can select which pages to publish.
Entire website
Publishes all pages of the website (except the pages which have enabled ‘Don’t
publish this page’ in page properties)
Publish the select page, click ‘select’ to specify the page to be published. Note
that you can also select a folder.
Select this option if you do not want to upload images or other components along
with the HTML file.
Select this option if you want to publish the files that were changed since the last
time you’ve published your web site.
What to do in case of publishing errors?
Make sure your ftp address (host), username and password is valid.
Use ‘Test connection’ to verify the specified data.
Make sure you the remote folder is correct! Consult the documentation of your
host for this value!
Use of ‘Explore’ button to browser to the remote folder.
If the pages don’t show up on your website you’ve probably specified the
wrong remote folder.
Does your firewall block the FTP connection of WYSIWYG Web Builder?
Enable ‘Use passive mode for transfers’
If the transfer takes a long time then you’ve probably used very large images.
More details.
Increase the connection timeout to 120 seconds or longer (Menu(Menu->Tools-
>Options->publish)
If you website doesn’t look to be updated, select ‘Refresh’ in your browser
multiple times!
Enable the publish log in Menu
Menu->Tools->Options->Publish
>Publish and make
mak note of
the error message.
For a list of all possible error codes and their descriptions go
here : http://support.microsoft.com/default.aspx?scid=kb;EN
http://support.microsoft.com/default.aspx?scid=kb;EN-US;193625
US;193625
May be there is a temporary problem with your host? Check if you can
connect using a FTP client.
99.99% of all publishing errors are the result of an invalid configuration,
please verify the specified Data!
Points to Remember:
Exercise Questions
Q. 1: What do you understand by website and webpage publishing?
Q. 2: Explain webpage, website and webserver?
Q. 3: In how many ways you can publish your web pages?
Q. 4: How many types of files you can publish on webserver?
Q. 5: State five errors which are commonly occur during publishing of any
website?
Further Readings
Book-1 Kogent Learning Solutions, “HTML BLACK BOOK,” 4th Edition,
DreamtechPress, 2012
Book-2 Elisabeth R, Eric F, “Eric f, “Head first HTML and CSS,” 2nd Edition,
O’REILLY ,2013
Website 1: www.w3schools.com
Website 2: www.thenewboston.com
Website 3: www.godaddv.com
Website 4: www.freeserver.com
UNIT-3
MULTIMEDIA DESIGN – GIMP
SESSION 1: MULTIMEDIA DESIGN TOOLS
SESSION 4 : FILTERS
● Text
● Graphics and Images
● Audio
● Video
● Animation
Multimedia design is an art that integrates multiple forms of media for designing various
applications such as video games, educational software, navigation systems, entertainment, and
hospital information systems. Multimedia Systems encompass computer and software systems
which could easily be used in an interactive manner. Multimedia development incorporates
rendering the input to multimedia design tools for processing to achieve the final product
Open source multimedia design tools are gaining importance in today’s world as not only open
source software is freely available, its source code is also freely available, and we can develop
new features to enhance its capability.
Adobe Photoshop software has been used predominantly over the years for image editing.
But now various open source tools for image editing are available. We list below a few of them
and mention the operating environments that support them against their names in parentheses:
GIMP is multimedia software having a variety of powerful tools for image editing and
manipulation. We will take a tour of GIMP and discuss its important features in the following
sections.
The first version of the GIMP (x0.54) was written by Peter Mattis and Spencer Kimball, students at
Berkeley, back in 1996.Gimp 1.0, an enhanced version, was released in 1998 and an official
website was established for the tool usage. It had extensive functionality for image manipulation
from its earlier versions itself.
Gimp is extensible. Nowadays, prevailing Gimp 2 series (version 2.8) is under use for image
manipulation, with enhanced interfaces and design tools. The software suite is available for
download at http://www.gimp.org/. It is supported on operating systems such as UNIX/LINUX,
Windows, and MacOSX.
Few attractive features of GIMP
● Software suite of painting and drawing tools with various brushes, a pencil, an airbrush,
cloning, etc.
● Paint tools supporting high-quality anti-aliasing.
● Multiple Layers and channels for image manipulations.
● Transformation tools including rotate, scale, shear and flip.
● A procedural database for calling internal GIMP functions from external programs such as
Script-Fu and Python-Fu.
● Advanced scripting capabilities.
● Multiple undo or redo effects on images if sufficient disk space available.
● Support for various file formats, including GIF, JPEG, PNG, TIFF, TGA, PS, PDF, PCX, BMP,
XPM, and MPEG etc.
● A variety of Selection tools, including rectangle, ellipse, intelligent scissors etc.
● Plug-ins supporting easy addition of new file formats and filters.
Installing GIMP
Installing GIMP is similar to installing any other software package. In the case of Windows, we
download the installer and execute it. In Linux environment (platforms like Ubuntu or Debian), it
could simply be installed by running the following commands in the terminal window:
Installation on Windows
1. Download the Installer: It is downloadable from http://www.gimp.org/downloads/.
2. Execute the Installer: The installer is usually saved in the Downloads folder. Run the
installer.
Figure 3.2: Execute Installer
3. Select the Language for Installation: The “Language” is selected as “English” by default.
6. Finish Installation: GIMP will be launched just after the click on Finish button.
It detects and uses the system language by default and configures various directories and
options on start-up. The configuration information is stored in .gimp-version directory for
initialization, recovery or backup. It supports a variety of image file formats. GIMP startup
screen appears as follows:
The first thing we are going to do is to open an image file in GIMP. For opening a file we need
to go to:
Then a dialogue box with Open Image will be displayed. The folders are displayed on the left
hand side of the dialogue box and image fil1e to be opened, is selected. A preview will appear
on the right- hand side of the dialogue box (Figure 3.9)
Figure 3.9: Open Image Dialogue
To search an image file manually, “Pencil” icon in the “Open Image” box is clicked and a user may
type the location of a file in the “Location” column and then opens the image file (Figure 3.10).
If an image is too big, such that it does not fit to file window, then window may be resized by
dragging the mouse. After resizing the window, “Zoom to Fit Window” may be chosen from the
“View” menu, and the image will be resized to fit the window (Figure 3.11).
Figure: 3.11 Zoom Settings
The image may be cropped using “crop” tool in Toolbar (Transform tools) or by going to the
“Image”” menu and choosing “Crop
“ to content.”
The creation of the new file is also one of the initial steps in GIMP which helps users to create a
new image file by setting up height and width properties.
The dialogue “Create a New Image” displays the default image size (Figure 3.14 b). A user can
alter the size either manually or through the up and down arrow keys. A user can also set the
type/nature of picture file size by clicking pixels.
After setting these features and finally we can click the Ok button to create a new image box.
Now the new file has been created. A sample new file created has been shown below
Figure: 3.14(b)
Finally, the file is saved by choosing “Save” or “Save as” in “File” menu.
On clicking the “Save” button, modifications are done on the current image will be saved
whereas on clicking “Save as”, a dialogue box pops up to indicate , where a user wants to save
file, maybe with a different extension or on a different path (Figure 3.15).
i) The Toolbox: A comprehensive set of icons/buttons for selecting tools for image manipulation.
ii) Tool Options:: The docked window renders
renders options or features available for currently selected tool.
iii) An Image Manipulating Window: An image to be modified in GIMP; is opened in the image
manipulating window. Many images could be opened in parallel for processing.
ows multiple images to be stacked over each other in layers for manipulations.
iv) Layers Dialog: This allows
sub layers known as Channels. Mostly layers consist of RGB (Red,
Layers can be decomposed into sub-layers
Green, and Blue) channels.
Paths are arcs or curves, and the path tool is powerful for performing the selection or to paint on an
image in the desired area with the help of arc curves.
v) Brushes/Patterns/Gradients: The docked dialogue for selecting brushes, patterns, or gradients allows
us to colorize an image or fill it with some pattern. Brushes are pixmaps used for painting,
erasing, copying, smudging, lightening or darkening etc. Patterns are small images used forf filling
regions of original images or for changing the background of an image. Gradients are set of colors
arranged in linear ordering and control the way colors could be filled or modified within the
image.
GIMP is flexible in arranging dialogues which are actually the windows containing options for a tool or
are dedicated to special purpose tasks.
The persistent dialogues (Tool Options, Layers/Channels, Brushes/ Patterns/ Gradients) are dockable.
non persistent dialogues such as an Image-
The docks are thus containers for persistent dialogues. The non-persistent Image
Window, Preferences dialogues, etc. are not the part of docks.
Session 3 : GIMP TOOL BOX
GIMP has an encircling tool suite, to perform a variety of image manipulations, selection and
enhancement operations.
a. Selection Tools
b. Paint Tools
c. Transform Tools
d. Color Tools
e. Others
The above-mentioned
mentioned tools are described as follows:
Selection Tool
i) Introduction
Selection tools form an essential part of GIMP. Often a user wants to operate on a portion of
an image instead of using the whole image. Selection tools (Figure 3.19), support the
functionality of selecting portions/regions from the current layer of an image, for
manipulation.
nipulation. Once a selection is made, anything the user does will apply only to the
area that the selection covers. The selection tools may be accessed in different ways
via:
− Clicking tool icon in the Toolbox
− Tool Menu Bar (Tools Selection Tools Rectangle Select/or any other select)
− Shortcut keyboard key
The selection area is drawn with left click mouse button, stretching downwards.
The selection could be deleted by clicking anywhere outside the selection area.
Tool Options
The most commonly associated features with selection tools are modes, antialiasing and feather
edges
Mode governs the interaction of new selection with the already existing selection. Various modes
available with Selection tools are Replace, Add, Subtract, and Intersection
Figure 3.21 Mode options
The behavior of selection tools could be altered, if a user presses and holds down the Ctrl, Shift,
and/or Alt keys. These keys and/or combinations of these keys are known as key modifiers that
could be associated with a mode.
Antialiasing makes the edge boundaries of the selected image smoother. Various selection tools
create sharp selections with selected pixels inside the boundary and unselected pixels outside the
boundary.
An option on Feather Edges makes the boundary of selection blur, faded or fuzzy. It also
smoothens the sharp image selections with outside graduated ones like antialiasing. But it works
by setting the radial distance from the selection edge.
Figure : 3.22: Antialiasing/ Feathering
Feathering edges of an image helps to integrate the image into the background or to tone down a
harsh outline of the image for merging it with the background. This feature is also useful in
cutting and pasting operations.
Step 1 : Click “File” then “Open” to open an image from the computer drive.
Step 2 : Click on the selection tool icon in GIMP’s toolbox. Alternatively, the selection tool could
be chosen by selecting “Tools” from the program’s menu, and thenthen clicking the desired “Selection
tools”. The chosen tool is dragged over the current image to select the desired area.
Step 3 : Once the area has been selected, a boundary (rectangle/ellipse/marquee/ etc.) is visible
around the selected portion.
Step 4 : Selected portion is used for further image manipulations and other operations.
Rectangle Select
The rectangle is the most commonly used tool that creates a rectangular or square selection
select rectangular regions of the
frames with small squares in each corner around the image to select
active layer.
The steps for rectangular selection are listed below:
1. Select the tool, click on its tool icon or use the Keyboard shortcut “R”.
2. Draw the rectangle/square selection by placing the Rectangle Selection tool icon at the top left
corner of where you want to initiate your selection and then dragging over the area to be
covered.
3. When the tool is released the rectangular outline is replaced by a marquee i.e. the little dash
lines moves around the active selection.
4. Once drawn, the Target icon changes to the “Move” icon indicated by the four directional
arrows. The Move icon allows the selection to be moved anywhere.
The selection will be constrained to a “square” if a user holds down the Shift key while drawing
the selection. It will draw from the center outwards if Alt Key is pressed while selection.
The selection boundary can be expanded or contracted through the corner are as indicated by
small rectangles/squares. Dragging the corner area upwards or outwards (diagonally) expands
the selection and dragging down or inwards (diagonally) contracts the selection.
An illustration of rectangle selection is shown in Figure 3.24. As the yoga figure in the image has
been selected, any action like manipulation/enhancement on the image will only apply to the
selected portion of the house.
For example, if we use a Brush tool or adjust colors, it would only affect
Figure 3.24: Rectangle Tool
A few of the other options available with this tool are listed below:
Rounded Corners:: It is used to make the corners of the current selection, round. A slider appears
for adjusting the radius of the selection on enabling this option.
Expand from Center:: The point where the selection is started by clicking the mouse button is
used as the center of the image.
Fixed:: This enables the option for constraining the shape of image selection.
Aspect Ratio:: This enables a user to resize the selection by changing or inverting the default
aspect ratio of 1:1(square).
Highlight:: It enables the selected area to be emphasized. If the Highlight box is checked, the
image will darken except for the selection area. This enables us to see exactly what is selected.
Guides: It creates a compositional grid. It has a variety of guides to make selection easier in the
form of center lines, rules of thirds, the rule of fifths, golden lines, diagonal lines, no guides etc. it
is highly useful in cropping an image.
Auto Shrink: It intelligently makes an image to shrink to fit the nearest rectangular selected
shape available over the layers.
Sample Merged: It helps Auto Shrink to extract pixel information directly from the visible display
of an image.
Ellipse Select
The Ellipse Selection tool is used to select circular or elliptical regions by rendering circular or
elliptical boundary on an image.
It functions majorly like Rectangle Select but only the shape of selection is different. To select the
tool, we click either on its icon or press the keyboard shortcut “E”. We draw out the
elliptical/circular selection by placing the Ellipse Selection Tool icon at the top left corner of
where we need to begin (can be any corner) and drag over the area to be covered as shown in
Figure. 3.25 When the tool is released the elliptical/circular outline is replaced by the marquee.
Figure : 3.25
It has mainly the same options as those in Rectangle select discussed above in section.
Free Select
The Free Select (Lasso) tool uses mouse clicking and dragging in the image window to trace the
selection shape. The action is completed with the release of the mouse button and the selection
is shown by Marching Ants ((Figure 3.26).
It works by choosing tool icon for Free Select, or by using the Keyboard shortcut “F”.
It functions in two modes: Straight Line mode or Free Drawing mode as listed in Table
Straight Line Free Drawing
1. Click to create a starting control 1. Click to create a starting point,
point (represented by a yellow but keep the mouse click (left)
circle) and release the mouse button pressed to start drawing the
button. line. A yellow circle will appear
indicating the first starting control
point
2. Move the mouse downward 2. Keep the mouse button pressed and
along the image to be selected trace the path of selecting the portion
and the line follows the mouse of an image.
movement (Don’t press the
mouse click button down as by
doing this we will go into the
Free Drawing mode).
3. Click to set another point 3. Keep the mouse button pressed and
indicated by the yellow circle to trace the path of selecting the portion
change direction and move of an image.
further around the selection
4. The process is continued until 4. The line will turn into the selection
we return to the first point. boundary.
5. Click back on the first point. 5. Press ENTER key to complete the
selection at any time.
6. The line segments will turn into
the selection boundary
7. Press ENTER key to complete
the selection at any time.
The main advantage of Lasso is that it can be used to select arbitrarily number of complex
objects. The disadvantage is that it is difficult to use this tool for precision work as it is dependent
on mouse clicks (which cannot be released in between of any selection). The predominant
options available with this tool are antialiasing and feather edges.
Intelligent Scissors
Intelligent Scissors selects a part of an image automatically by high contrast or differences in
colors, with constant-valued color contours. It is inspired by the features of Lasso and path tools.
The region to be selected is surrounded by boundary created by joining the nodes or anchor
points clicked by mouse at the edges.
1. Click and select Intelligent Scissors tool icon or use the Keyboard shortcut “I”.
2. Point and click at various points around the edge of the input image.
3. As the anchor points are marked on the edges with this point and click technique, the tool
automatically draws the selection line around the edges that it detects.
The advantage that this tool has for detecting edges is that as we point and click, it automatically
redraws the selection line around the edges for tracing. Hence, we can edit the current selection
line by just adding or repositioning the control points.
Also, keeping the anchor points close will aid in more accurate boundary detection for an image.
This tool also supports the option Interactive boundary, besides antialiasing and feather edges.
Foreground Select
It works on selection by extracting foreground from the current image. This tool works better
when the foreground and background are highly contrasting in color saturation. It is basically a
combination of two different tools:
Lasso tool: used to select a foreground area (similar to the Free Select tool)
Paintbrush tool: used to paint over selection to indicate the foreground color
1. The lasso tool is used to draw around an area that user wants to select.
3. Then the paintbrush tool is used to paint a brushstroke over the foreground area so that the
tool can differentiate the foreground colors from the background colors.
4. Once it determines the boundary difference between foreground and background colors, a
“mask” i.e. a bluish marker is placed over the foreground area to mark it.
Besides mode, antialiasing and feather edges, it has the following tool option settings:
Step 4: Step 5:
Fuzzy Select
Fuzzy Select is a color based tool. Fuzzy selection (also called ‘magic wand’) is used for selecting
areas in an image with the similar color component (Figure 3.29). The functionality of this tool is
based on examining the RGB color components of the pixels that it clicks on. It is very important
to pick the starting point correctly.
1. We first have to click on an image at a point that is the color you want to select.
2. The pixels immediately surrounding the selected pixel and falling within the threshold of
similarity will be included in the selection.
3. The size of the selection could be adjusted by holding the mouse click button down and
dragging downwards or to the right-hand side to increase the size or dragging upwards or to the
left-hand side to decrease it.
Select transparent areas : To select transparent pixels within the set threshold.
Threshold : It determines the basic range of colors. Increasing the threshold (either by clicking on
the number in a box or by dragging the blue slider), increases the range of colors to be selected.
Most of the color variations in the image will be selected if a threshold is too high. The maximum
value is 255.
u Select by : To select the color component for calculating the similarity. It has following
available basic options:
By Color Select
The selection by color also considers all the pixels with similar color component, but regardless of
where they are located in the image. The similar pixels automatically get selected, even if they
are trapped by other colors, unlike fuzzy tool. As illustrated in Figure 3.30, the blue
blu pixels are
selected in the whole image. It has the same tool options as that of fuzzy select.
Figure 3.30: Color Selection Tool
PAINT TOOLS
A paint tool is a comprehensive suite consisting of 13 basic paint features as shown in Figure 3.31:
Tool Options
The most common tool options available in paint tools are as follows:
- Mode : The Mode drop-down list provides various application modes such as
Dissolve, Hue, Behind, Soft Light, and Hard Light, supporting a variety of special
effects. The Mode option is suitable for tools that aid in adding color to the image:
the Pencil, Paintbrush, Airbrush, Ink, and Clone tools. The option is usually grayed out for
rest of the paint tools.
- Opacity : The Opacity option is responsible for setting the opacity of the brush stroke to
be applied and hence controls the strength for brush operations in paint tools. The tool
creates a transparent layer above the active layer and acts on that layer for operations.
- Brush : GIMP allows a user to use various kinds of brushes for all brush tools except the
Ink tool. The Pencil, Paintbrush, and Airbrush tools support the use of colors in brushes
and rest of the tools see intensity distribution by brushes.
- Scale : The Scale option is used to modify precisely the size of the brush.
- Brush Dynamics : It majorly considers three dynamics: pressure, velocity, and random to
map brush parameters.
- Rate : This option is applicable to the Airbrush, Convolve tool, and Smudge tool, for
rendering time-based effects.
- Size : If enabled, it increases the size of an area affected by the brush.
- Color : It supports higher gradient colors and is applicable to painting tools such as pencil,
paint brush, air brush.
- Fade Out : It causes a fade out over the specified distance of a stroke and behaves
equivalently to gradually reduce the opacity along the trajectory of the stroke.
- Apply Jitter : It controls the spacing in brush stroking to make lines continual or jittery on
shaking of brush strokes.
- Incremental : This is selected if a user does not want to enhance color strokes while
reducing opacity settings.
- Color from Gradient: This allows the usage of gradient color in brush strokes.
- Hard Edge : This places colors in a rough manner when it is applied to a selected portion
of an image.
- Source : This determines the source of the image which needs to be copied for cloning.
- Alignment : This determines the relation between brush position and the source image
that needs to be cloned.
The varieties of brushes (for paint tool), with following setting attributes, are available in GIMP.
Key Modifiers
The Key Modifiers associated with Paint tools are:
Ctrl : The ctrl key has a special effect on every brush tool. It acts as “color picker” mode and sets
the foreground to the active layer’s color for the Pencil, Paintbrush, Airbrush, Ink Tool, and Eraser
tools. It switches between the reference point of copy and the actual image in the clone painting
tool. For the Convolve tool, the ctrl key toggles blur and sharpen mode and it toggles between
dodging and burning for the Dodge/Burn tool.
Shift : Shift key renders an effect of placing the tool into straight line mode especially with brush
tools. First the starting point is chosen and clicked, and then Shift key is pressed continuously to
create line segments.
Ctrl + shift : It renders the tool into constrained straight line mode to create perfect horizontal,
vertical or diagonal lines over the image objects. It can be used to constrain the angle between
two successive lines.
Step 1 : Click on the paint tool icon in GIMP’s toolbox. Alternatively, the paint tool could be
chosen by selecting “Tools” from the program’s menu, and then clicking the desired “Paint tool”.
Step 2 : To create a canvas, choose “File” and then “New” from the GIMP menu. One can also
paint over an existing image. Click “File” then “Open” to open an image from the computer drive.
Hold the left mouse button and drag the paint tool icon on the GIMP canvas. A small circle will
occur above your mouse cursor over the GIMP canvas to create strokes of tools like pencil, brush,
eraser, etc.
Step 3 : The color for your paint tool could be chosen by clicking on the color box, which is
located just under the tool icons on GIMP’s toolbox. The color is black by default but can be
changed by clicking any of the square color samples or by adjusting the gradient sliders.
Step 4 : The paint tool options could be adjusted to customize pencil, brush, eraser, etc. These
options appear on the lower half of the GIMP toolbox when the paint tool is selected. Slide the
“Opacity” slider to determine the translucency of the painting brush. One can adjust parameters
like size, aspect ratio and angle for various paint tools. Click on the icon next to “Brush” and
choose a brush shape and size that alters the shape of the stroke of paint tools on the canvas.
Several other options could be set according to the chosen paint tool. For example; “Apply Jitter”
is used to change the stroke of brushes from a continuous line to a broken-up, scattered line.
A sample image is pictured in Figure 35. We will apply few of the paint tools on sample image and
the results are demonstrated in Figure 35 (a-d)
Smudge tool , is used for smearing color pixels on a selected layer. Smudging is used to soften
color transitions, make the image blurry, hide objects, and to create textures. smudge When a
smudge tool is applied on an image, it selects the available color and merges it with the other
colors present on the image.
How to use the Tool To use smudge tool, firstly a brush type is chosen from the toolbox options
and then the mouse cursor is clicked and dragged over the selected image portion
Clone Tool
Clone tool (Figure 3.36) is used for copying the pixels from selected portions of an image to a
destination area, the user wants to cover, or for reproducing the selected portions of an image. It
uses the current brush to copy from a source image. It has a variety of applications and the
famous one is to repair digital pictures or images by painting them with cloned pixels from the
selected area
Tool Options - The options available with Smudge tools are: Mode (disabled), Opacity, Brush,
Scale, Brush Dynamics, Rate, Fade out, Apply Jitter, Hard Edge, Source and Alignment
i) “Clone” tool from the toolbox menu is selected. Its icon is shaped like a traditional
stamp.
ii) One of the brush types is selected from brush Menus in GIMP.
iii) Ctrl key is pressed while using mouse to click and select the area of the source image
for pixel extraction.
iv) The selected pixels are applied by left click of a mouse in the destination areas.
v) The process is repeated if necessary. For example select a sta
starr brush; Press the ctrl key
is over a red tile region of the HUT appearing in the image. The selected tile colour
pixels are stamped on the walls of HUT by left clicking of the mouse.
Stamping may occur across the layers as shown in Figure3.36 . The imag
image e of parrot could also be
cloned onto an image having a tree with the house. The brush size is set according to the size of a
selection of parrot. Ctrl key is pressed over the image of parrot and it is released with a left click
of the mouse, on the image having a tree (to clone parrot on the tree).
An interesting feature here is to explore and set up different opacity or transparency levels while
cloning. If we change the opacity level, the clone stamp also changes the brush stroke intensity
over the image.e. One cannot clone from a fully transparent source. If a user tries to clone from a
partially transparent source, the effect is weighted by the opacity of the source as shown in
Figure 3.3.
1. Cloning
ing translucent black onto white produces gray
2. Cloning translucent white onto black produces gray
3. Cloning translucent black onto black produces black
4. Cloning translucent white onto white produces white
Figure 3.36 cloning and Stamping
Transform Tools
Transform tools tend to modify the presentation of an image or a particular element in an image.
There are 9 such tools (Figure 3.37), each having a variety of features and tool options.
GIMP offers three buttons which let the user select portion of an image on which transform tool
will be applied.
⮚ If the first button is activated, then the tool works on the active layer. If no
selection exists in this layer, the whole layer will be transformed.
⮚ If the second button is activated, then the tool works on the selection
contour only (the whole layer contour if no selection).
⮚ If the third button is activated, the tool works on the path only.
Align tool
Relative To : It allows modification of the edges w.r.t. the left, right, center, top, bottom and
middle of the selected target by applying Selection option. The rest of the options are used to
align the layer, path, and channel.
Distribute : It distributes the left, right, center edges, top, bottom and middle edges of the
chosen target.
MoveTool
Move : It allows the image to be transformed or moved.
Crop
Current layer only : It is utilized only for the current layer.
Highlight : It highlights the marked selection, by darkening everything that lies in the
background of the image.
Guides : It chooses the types of guides available within the marked portion.
Rotate
Direction : It enables turning an image either in the Normal or Corrective manner.
2) Corrective Rotates the image in the opposite direction i.e. towards backward,
against the option set in the box.
Interpolation : It aids in curving the image and choosing the quality of transformation. It
takes samples from a grid of pixels from known image areas, and then fits the curve.
Opacity : It makes the background of an image to be unclear or vague when the image is
filled with color.
Grid lines : We set the Grid option in the preview to enable this option. This option lists
the Grids which are placed on the image while making changes.
You will observe the area not selected is removed and only selected area remains in the window.
The tool acts on a selection (if there is no selection, on the whole layer). The active handle is
bigger than the others. When the mouse pointer is on a handle, it goes with a small icon that
represents the active action.
When you click and drag a handle, a transformation is applied, and the other handles stay at their
place:
Figure 3.44: To illuistrate ‘Handle Tool’
Color Menu:
Color Menu offers a number of options to change the colour settings of an image.
Color Balance
It modifies and maintains the color balance of the current image by adjusting color levels of cyan,
magenta, yellow and ranges of red, green and blue.
Color Temperature
It can be used to correct the bluish cast in overcast photos, or even (to some extent) the red cast
in photos taken under incandescent light with the camera set to daylight.
Exposure : It is used to edit the blackness and brightness of an image as shown below :
Figure 3.49 to illustrate Exposure
Colorize Tool : The Colorize tool renders the active layer or selection into a greyscale image seen
through a colored glass.
Threshold : Threshold transforms the image into a black and white image.
Levels : It adjusts the intensity range w.r.t. the image in every channel.
Curves : It modifies the color, brightness, contrast or transparency of the image.
Dither : It is used to reduce the number of colours in the image by reducing the levels per
channels of colours.
Colors of images could also be manipulated from Colors pallet. Some more options like Color to
Alpha that converts specific color to transparency, Maximize RGB (Reduces image to Red, Green
and Blue composition), Info, Map, and Filer Pack are also available in Colors Menu for changing
color composition.
A step by step procedure to create a polygon using the path tool is as follows (Figure 6.50):
Other tools
The other miscellaneous tools in GIMP are listed as:
Color Picker: The Color Picker Tool is used to select a color from an image opened on the screen,
by clicking on the particular color of the image. Both the foreground and background color can be
selected by this tool.
Zoom : The Zoom Tool enables the user to expand or compress the entire portion or the selected
part of an image. A user can simply click the Plus & Minus button to increase and decrease the
image.
Measure : It calculates the distance, angle, height, and width of the selected portion of the
image. It is used to see the measurement information of the selected part of the image.
Creating and Editing Images Now that, we have studied the basics of the Tool Box, let’s take a
tour of Image Menu that forms part of GIMP interface.
Image menu supports various operations for image manipulations as listed in Figure 51. We may
create a new image or open an existing image for manipulation which has been discussed till
now.
Creating Images in GIMP Let’s explore how to create an image in GIMP. We create a sample
image of the rectangular window giving a view of moon and stars. For creating images, we need
to use File Menu and Edit Menu. A step by step procedure for creating a sample image is
illustrated below
v) Draw a thick line around the selection using Edit Stroke Selection
Figure 3.56: Using Stroke Style
vi) Use paint tool brushes to draw stars and circles effect
Figure 3.57: Drawing Stars in Selected Window with Paint tool in GIMP
The above-discussed procedure is one only one of different ways in which an image could be
created in GIMP. File Menu plays an important role for handling images such as opening an image
file, exporting images, setting page, saving a file, printing, and closing files.
iii) Use Dodge tool to draw the clouds and smudge tool may be used to give the little hazy
appearance.
Editing Images
The commonly used functionalities related to image editing are cut, copy, paste, foreground,
background color, pattern, and stroke selection as shown in Figure3.64
Figure 3.64: Image edit tools
Foreground Color
It fills the image with the default foreground color. A user may select any part of an image and fill
it with the foreground color by following the steps given below:
Background Color
It fills the image with the default background color. A user may select any part of an image and fill
it with the background color.
A user may select any part of an image and fill it with the desired pattern by following the steps
given below:
Stroke Selection
It aids in striking the selected portion of the image. The steps are as follows:
The Antialiasing option softens the curved strokes drawn over an image and makes it smoother.
i) Customize Environment: It enables a user to modify and set the amount of system
memory allocated for various purposes.
ii) User Interface: It enables a user to set the layer or channel previews and keyboard
shortcuts in GIMP.
iii) Change theme: It enables a user to select a theme which determines the appearance of
GIMP.
iv) Modify Help System: It helps a user to modify help feature of GIMP.
v) Customize Tool Options: It lets a user change the way the tools function in GIMP.
vi) Customize toolbox appearance: It enables a user to modify the appearance of the
Toolbox.
vii) Customize Default Image size: It enables a user to customize the default image size. The
user can alter the default screen size in the “Default New Image” dialog box.
viii) Configure Default Image Grid: It allows altering the default properties of GIMP grid. This
feature is enabled using View Show Grid from the image menu.
ix) Change Image Window: It enables a user to change and set features related to Mouse
Pointer, Space Bar, Zoom, and Resize effects of an image.
x) Set Display Mode: It enables a user to set the display modes for customizing the visible/
transparent portion of an image.
xi) Color Management: It enables a user to modify the features of the GIMPs Color Profile.
xii) Configure Input Devices: It enables a user to manage and control the input devices
connected to your computer system.
xiii) Configure Window Management: It allows a user to customize the appearance of various
windows in GIMP.
xiv) Folder Options: It enables a user to change and set new location/path for two main
folders utilized by GIMP to store the temporary files.
Session 4: FILTERS
Applying Filters
Gimp has various powerful graphical features and may render diversified effects or textures to
images.
A filter tool (Filters) in GIMP is one such special plug in feature that may modify the image
plug-in
appearance on the current layer by running
algorithms. These algorithms support activities like
inserting lightening effects on the image, distorting an
image etc. and generate a modified image.
Blur Filter It provides a set of filters to make a whole image or a part of an image blurry with
various parameter settings like defining magnitude or type of blurring.
The three most commonly used Blur filters are illustrated below :
Gaussian Blur
Figure 3.68 : Image before and after applying Gaussian Blur
Circular Blur Filter : It Blurs the image in a circular motion as shown below in the figure:
Pixelize Blur Filter : It simplifies image into an array of solid coloured squares/rectangles.
squares/rectangle
Antialias : It smoothens the edges by removing artifacts from an image while converting it to a
comparatively lower resolution.
Deinterlace : It removes extra and undesired image information from interlaced image frames. It
does have an option for keeping odd and even fields of image interlacing.
Despeckle : It removes small defects such as noise particles from the current image area. Median
could be set to Adaptive which works by analyzing the histogram of the surrounding region of
selected image or ‘Recursive’ which renders repeated actions for an image enhancement. Radius
size could be set to remove imperfections. There also exists an option to set Black level and
White level for brighter and darker pixels of the image.
Destripe : It removes the vertical stripes in an image, caused by poor quality scanners. It works by
adding a pattern which interferes with the image to remove strips. The strength of the filter is set
using “Width” option, available with this filter.
Distorts Filter
These filters may transform the shape of an image in several ways. Following are the Distort filter
supports in GIMP. Click on Filters and then select option Distort to apply Distort Filters.Following
is the menu for Distort :
Emboss : It simulates embossing on the image. It sets azimuth (lighting component), elevation
and depth of an image using option settings.
Engrave : It produces an engraving effect, like one found on coins. The image is simulated with
black and white horizontal lines of varying height based on the value of underlying pixels.
Lens Distortion : It allows correcting distortion effect occurred due to the camera lens
Mosaic : It cuts the image into various squares or polygons tiles which are slightly raised and are
joined with each other, thus giving an appearance of mosaic. It allows option setting like Tile size,
Height, Direction, Color Variation etc.
Polar Coordinates: It gives a circular or a rectangular representation of the image with all the
possible polar coordinates and intermediates.
Ripples: It displaces pixel in ripple pattern. It has various options like Edges, Orientation, and
Wrap Type.
Spherize : This filter creates a kind of bubble whose size is that of the image or selection, as if the
content was wrapped around a sphere.
Value Propagate: It works on color borders by spreading pixels that differ in a specified way from
their neighboring pixels and setting mode and propagate options.
Waves,Whirl and Pinch, Wind : It distorts an image with waves, whirling and pinching and wind-
blow effects
Curve Bend: It is useful for changing the shape of any layer and usually simulates by setting up
the bending curve to distort an image. The distortion is applied gradually from an image or
selection border to the other in layers. Curve bending may be controlled by available option
settings. One can adjust the top of the layer by setting upper and bottom by clicking on lower.
Mirror will give a lower curve as the mirror image of the upper curve and Swap will exchange
lower and upper curves. Reset will flatten to the original image
Emboss(legacy): This filter stamps and carves the active layer or selection, giving it relief with
bumps and hollows. Bright areas are raised and dark ones are carved.
Figure 3.73(a)
Supernova: Supernova tries to create a flare with long lines of light that originate from the
center. The predominant settings available in this filter are color, the radius of the center, the
number of rays or spokes, and a random hue setting that generates a rainbow kind of effect in
the light ray.
Lens Flare & Gradient Flare: They simulate the sun like flares in images by putting a lens like
effects in gradients
Lighting Flare: Lighting Flare is a powerful tool for creating effects similar to of studio lighting.
One application of such tool is to put spot lights to emphasize certain parts of the image. The
basic settings consider both directional lights and point lights. Other settings include precise
positioning and glowing settings, intensity settings, and bump & environment map settings.
Sparkle : It creates a sparkle-like effect by using a sequence of tiny flare effects for highlighting
areas of the current image. This tool has options for adjusting the threshold, intensity, spike
length, points, and angle direction with hue, saturation, and transparency.
drop shadow to the current selection or to the image if there's no
DropShadow : This filter adds a drop-shadow
active selection.
Long Shadow : It is used for creating long shadows in several visual styles.
Drop Shadow (legacy): if Drop Shadow does not works I a system then Drop Shadow Legacy
works perfectly.
Xach –Effect:: This filter adds a subtle translucent 3D effect to the selected region or alpha
channel.
Figure 3.75(a)
Figure 3.75(c) Applying Default and Distant Sun Gradient Flare Filters
Sparkle Filter
Noise Filters
Noise filters add noisy pixels/disturbance to the current image. “HSV noise” creates disturbances
in hue, saturation or luminosity value of an image under consideration. “Hurl” as a Noise filter,
adds random pixels to the image, making it look disturbed. “Slur” makes a ragged edge to all of
the elements in an image by sliding the pixels downwards. “Pick” interchanges few of the pixels
with neighboring ones. RGB noise behav
behaves
es as “Hurl”, besides it also allows selecting pixel colors.
The “Spread” works by swapping pixel in one place with a randomly chosen pixel from another
source considering color transitions. The Figure below demonstrates the application of various
noise filters.
One of the famous tools is Difference of Gaussians, which can detect salient details of a
photographed figure with an important feature of controlling edge thickness.
“Edge” detects edge boundaries. “Neon” simulates the glowing boundary on edges, “Laplace”
resolution edges and “Sobel” simulates direction dependent edge detection.
detects high-resolution
Neon Filter
Sobel Filter
Generic Filters
Generic Filters are divided into three main categories:
Combine Filter
It groups different images of the same size to a single image by: i) Depth Merge : It combines two
images by comparing and joining depth map of each image. It is best suitable for black, gray or
white scale images. ii) Filmstrip : It combines layers in the image into a single image that seems
like a 35mm film strip.
Artistic Filters
These filters enhance the image with impressionist work of art such as sketches, paintings,
making cartoons etc. Figure shows the options
available under Artistic filters:
Décor Filters
This filter provides borders to the selected image. The three main filters under this category are
as follows:
Round Corners It makes corners of the current image smoother by curving them.
The two filters: Add Border and Round Coroners are illustrated in Figure:
Original Image :
Under “Décor” there are various features filters like Coffee stain, Fuzzy Border, Old Photo,
Slide that you may like to explore/
MAP Filters
Map filters simulate 3D effects in an image by mapping the image into an object. It has the
collection of various filters listed as follows :
Little Planet: This filter converts a panorama into a small planet. All images don't fit this filter.
The ideal image is a 360° x 180° image, also known as equirectangular image
Panorama Projection: This filter converts a 360° x 180° image, also known as equirectangular
image, into a panorama
Paper Tile: It cuts and breaks the image into the paper tile-like structure
Tile Seamless: It makes an image seamlessly tileable.
Fractal Trace: This filter transforms the image with the Mandelbrot fractal: it maps the image to the
fractal.
Map Object: This filter maps a picture to an object (plane, sphere, box or cylinder)
Tile: This filter makes several copies of the original image, in a same or reduced size, into a
bigger (new) image
Figure 3.94: Applying Tile Filter
Render :
This class of filters behaves differently, as they may overwrite a current layer by applying the
effect from scratch. It is, therefore, safe to duplicate layer while working with these filters. It has
various filters as listed as follows:
Flame: It creates cosmic recursive frames. With the Flame filter, you can create stunning,
randomly generated fractal patterns.
Cell Noise: Generates a cellular texture. Results don't depend on the image you opened.
Perlin Noise: This filter generates a noise texture using the Perlin Noise algorithm. Results
don't depend on the image you opened.
Plasma : It generates colorful clouds which can be used for textures.
Simplex Noise : This filter generates a noise texture using the Simplex Noise algorithm. Results
don't depend on the image you opened.
Patterns : It renders various patterns to images from check-board, grid, jigsaw, maze, qbist, Sinus, CML
explorer and diffraction patterns.
Line Nova: It uses foreground color to generate rays from the center, spreading in an outward direction.
i. “Image Map”, which runs a javascript engine and allows the user to quickly divide the
image and creates a hyperlink kind of area; where a user can click and reach the
various links,
ii. “Semi-Flatten” renders semitransparent levels with the background color.
iii. “Slice” generates tiled table of the current image for use in Web pages.
Animation
Animation filter renders a sequence of images, with timing information attached to each frame of
the image. The GIMP considers each layer in an image as an animation frame. It supports the
conversion of layered images to Indexed format and outputs as GIF files. It has the following
emphasizing effects:
Blend : It creates an intermediate layer to blend two or more image frames over the background.
Rippling : It applies Ripple effect to the current image to create a multi-layer effect.
Waves: It creates an animation via an effect which appears as if the stone was thrown on the
image. One can choose the number of frames required for animation. The amplitude and
wavelength for the animation could be adjusted.
Optimize Difference & GIF: They help in reducing the size of animation via optimization (reducing
the size of layers by saving only the changes made with time in layers instead of saving again the
whole image).
When applying animation is finished, one will see a still image of the effect, in the image window.
But to view the animated effect, FILTERS/ANIMATION and PLAYBACK option may be selected.
The steps to make a sample wave animation in GIMP are listed below:
Alpha to Logo
This filter is useful in the creation of logos and also in adding special effects to alpha channels
that represent the degree of transparency of the color (majorly red, green and blue channels) in
an image. Alpha channels define transparent areas. The various effects in this filter are listed
below:
3D Outline : It outlines the non-transparent areas of the active layer and adds a drop shadow.
Basic I and II :They add gradient effect, drop shadow and highlighting effects.
NOTE: Alpha to Logo filter needs to be explicitly imported for Gimp2.10.12. it is present in GIMP
2.8 in Filters Menu
This filter is very useful in adding effects to text in GIMP . The steps for adding effects to text are
as follows:
i) Use “File” from the menu bar to select “New” for creating a new document or “Open”
if the text is to be added to an existing image.
ii) Click “Tools” from the menu bar and then click “Text.”
iii) Left-click the canvas to type the text. It might be customized with Tool Options.
iv) “Filters” from the menu bar is clicked to select “Alpha to Logo.”
v) Select one of the preset effects.
vi) The selected effect is customized by adjusting the parameters on the Script-Fu
window. For example, when applying the “Alien Glow” effect, a user can adjust the
glow size and color while for the “Bovination” effect one can specify the spot density
and background color.
vii) Click “OK” to apply the selected effect to your text.
Layers at the top of the layer stack will appear in the foreground of the image whereas layers at
the bottom make up the background.
Figure 3.97: Layer Menu Options in GIMP
Layer Dialogue has many options available to perform various functionalities. They are listed as
follows :
A. Adding a new layer: It allows the user to add a layer by naming the layer, setting up width and
height, and choosing whether it should be transparent, white, or black in the background.
B. Create New Layer Group: It creates a new layer group and adds it to an image.
C. Move the layer up: It simply moves the layer up in the stack of layers for processing.
D. Move layer down: It moves the layer down and the layer would be placed underneath the
background layer.
F. Anchor the layer: It merges the image on current layer to another image on the layer below
Gimp creates a “floating layer” and this layer contains what a user wants to copy to other layers.
Pressing the anchor option will make floating layer disappear, the contents of the floating layer
are transferred to the destination layer.
G. Delete the layer: It removes the currently selected layer.
Lock: A locked layer prevents modification of the Layer’s pixels. ‘Lock Alpha channel’ feature is to keep
nd confines editing to only opaque portions of the layer.
transparent regions intact and
Layers are important to make up an image composition if a bunch of different images from different files
are combined into one image. While creating an image composition in this manner, one could ccopy and
paste images from different files into his/her file but keep them on separate layers. An image on each
re colored, etc., without affecting the images on the other layers.
layer can be scaled, moved, enhanced, re-colored,
3. We open the image of HUT in another layer by using File Open as Layers.
5. Select
ct option Copy from the Edit Menu.
6. The selection is pasted as a Layer into the tree image (Edit Paste As New Layer).
The steps
teps are as follows (Figure 6.78 aa-b):
i) Open GIMP.
ii) Launch a new image file
iii) Click Layer New Layer or press Shift+Ctrl+N to create a new layer in an image.
iv) The new layer window opens as follows :
v) Fill in the parameters like Layer name, Color, width, height, Fill Type etc as per your
requirement.
vi) Save the file.
Besides New Layer we have the following options available with Layers in GIMP:
- Edit Layer Attributes: It allows the user to enter a new name for the layer.
- New Layer from visible: It creates a new layer comprising of all the elements of the
currently visible layers, merged into one layer.
- Duplicate/Anchor/Delete Layer: These are similar functions to their icon counterparts.
- Merge Down: It merges the currently selected layer with the next visible layer below it.
- Layer Boundary Size: Every layer has its boundary and this option adjusts the layer
dimensions making it easier for you to demarcate selected and non-selected layers.
- Layer to Image Size: It resizes the layer boundary to the image size.
- Scale Layer: It changes the size of layer content.
- Auto crop: It removes empty borders from the image layer.
- Stack: It supports selecting previous, next, top and bottom layers.
- Add Layer Mask: It adds a layer mask to the selected layer to avoid destructive changes in
editing transparency. This option lets you choose the type of mask you want to apply on
the particular layer.
- Apply/Delete Layer Mask: Apply layer mask appends the changes done in the mask to the
current layer and Delete layer removes the mask.
- Show Layer Mask: It reflects the changes done in the applied mask.
- Edit Layer Mask: It allows switching between the layer and its applied mask by either
using it or by clicking on the preview.
- Mask to Selection: It replaces the selection with the mask layer.
- Add Alpha Channel: It adds transparency to the selected layer. It is a very handy tool for
creating quick animation with the GIMP.
- Alpha to Selection: An Alpha channel encodes information about how transpar ent a
selected layer is at each pixel. This option replaces the selection with layer’s alpha
channel.
- Merge Visible Layer: It merges all the active visible parts of a layer, in the image.
- Transform: It transforms an image on selected layer by applying rotation by 90 or 180
degrees (clockwise or counterclockwise) and flipping horizontally or vertically. It also
supports arbitrary rotation.
On changing the opacity to 50 percent the layer below the selected layer starts appearing as shown below:
On changing the opacity level to zero the layers does not appear and the layer below the selected layer appears as
shown below :
GIMP Choose the layer Tools Text Write the desired text
Image Rotation :
transform rotate 1800.
Select the layer in menu bar->> select transform->
i) Right Click on the layer needed to be masked and Click on Add Layer Mask
ii) A mask layer option is chosen and thumbnail will appear in right layers window with the
image.
iii) Now all the operations performed on the canvas will be on the mask.
iv) Operations like selection; paint etc. could be applied to the mask.
v) After operations, setting the transparency levels will generate an effect in which layer below
epending on transparency from black to light gray gradients.
the mask is visible depending
The steps to Add Alpha Channel to a sample image are given below and their use is
demonstrated in Figure
i) The default layer i.e. background layer opens up in the editor layers dialogue.
ii) Give this layer a color, say, sea blue.
iii) Add another layer and let us call it HotEarth. Paste an image of Hot Earth on this layer.
iv) Drag the background layer above the HotEarth. It may be observed that the Earth is
hidden in the background.
v) Right-click
click on the background layer and click on Add layer Mask.
vi) A window pops up with several options. Select white (full opacity).
vii) A thumbnail mask, indicated by a white box in front of the background layer in the layers
stack, is created.
viii) Select the rectangle tool and draw a rectangle via selection on the background layer.
ix) Change the color to black from foreground and background color option at the end of the
toolbox.
x) Select edit menu and click on fill with FG (foreground) color. This will show the se
selected
portion of the tree with full transparency.
xi) Repeat the steps with some dark shade of gray color, light shade of gray color, and light
shade of white color.
Note: Black will mean full transparency and white will mean full opacity. The colors lying in
between will act as translucent according to the shades.
Make a selection and select option ADD Layer Mask option form the pop up menu.
Figure 3.110(c) : Select elliptical area to show the background layer area
Fill the selection with black colour using the bucket tool. The selected area will become
low the current layer appears as shown below :
transparent and the layer below
Alpha Channels
Alpha channels underder Layers Menu are used to signify transparency within an image and are
created automatically while creating a new layer in GIMP. The painted black areas within the
alpha channel indicate that transparency should appear at that part of the image. The creative
crea
use of alpha channels allows partial transparency or fading effects due to the inclusion of a
gradient design in the alpha channel.
The steps to Add Alpha Channel to a sample image are given below and their use is demonstrated
in Figure 3.111:
ault Background layer will appear in the layers dock with a default color white. Change its
1) Default
color to Yellow.
3) Let us name this layer as House and paste the image of some house
7) The selected portion will get a yellow color similar to the background.
8) Transparency tool has various other options like removing alpha channel which will remove
this yellow color and the house will revert to its normal color.
Figure 3.111 Appl;ying Color to Alpha
Channels in GIMP are very similar to layers; however, each layer corresponds to a particular level
in the color model of the image (RGB, HSV or CMYK). Channels dialogues can be selected in any
combination, and appear as gray shaded, if currently active.
The purpose of ‘Channels’ is to process color channels (applied to images) and maintain selection
masks. And the ‘Path’ dialogue with layers and Channels is used to manage paths of images for
creation, deletion, saving, converting to or from selections etc.
GIMP is versatile image manipulation software packed with various attractive features, many of
which are explored in this chapter. It can be explored for other aspects too for image
manipulations and making images more attractive.
Points to Remember
● GIMP is an acronym for GNU Image Manipulation Program.
● It is a freely distributed, versatile image manipula tion software package with a
manipulation
customizable interface.
● It has support for multiple platforms including Windows and Linux.
● It supports various file formats including .gif, .jpeg, .png, .tiff etc.
● It is a full suite of painting tools including a variety of brushes, pencil etc.
brushes,
● It has selection tools (Rectangle, Eclipse, free lasso, fuzzy etc., for selecting portions of an
image.
● It has transformations tools like rotate, flip, scale and shear.
● It has support for high-quality
high antialiasing.
● It also supports a varietyety of Filters for image enhancement or modification in appearance.
● It has full Alpha Channel Support.
● It has the functionality of Layers and Channels.
● It has the functionality of masking of images.
● It also has Plug-ins for easy addition of new file formats, filters and scripting capabilities.
Exercises
Create a file in GIMP and demonstrate the purpose of paint tools and selection tools.
Open an image of human eyes with red eyes effect in GIMP and perform red-eye correction.
i) Resize-Crop
ii) Brightness/Contrast
iii) Colorize with Hue and Saturation
iv) Zoom
v) Add a border to an image
vi) Add text to an image.
vii) Rotate an image by 90 degrees
Objectives
After studying this section the students will be able to:
Use a text editor such as notepad to publish an HTML document
Recall the HTML concepts
Learn the history, uses and limitations
Role in Web Development
Understand the JavaScript syntax and structures.
Learn, how JavaScript programs are used in a web pages including the use of
event handlers and the document object Model (DOM
insert JavaScript into a web page using various approaches including inline
code, internal scripts and external JavaScript files
Write and use simple JavaScript programs, that reflect common applications
of JavaScript
History
JavaScript was developed in 1995 by Brendan Eich, at Netscape, and first released
with Netscape 2 early in 1996. it was initially called LiveScript, but was renamed
JavaScriptto capitalize the popularity of sun Microsystems’s Java language. the
basic purpose ofJavaScript language was to enable web authors to design
interactive sites. JavaScriptcan interact with HTML source code, enabling web
authors to modify their sites with dynamic contents. JavaScript is supported by a
number of software companies and is an open language that anyone can use
without purchasing a license. JavaScript language is interpreted and executed by the
browser.
What is JavaScript?
JavaScript is an interpreted computer programming language.
it was originally implemented as a part of web browser so that client-side
scripts
could interact with the user, control the browser, communicate
asynchronously, and alter the contents of the document.
It is tightly integrated with HTML code but executed by the JavaScript
Interpreter built into the browser.
JavaScript contains a core set of objects such as array, date, Math, and a
core set of language elements like operators, control structures, and
statements.
Standards
In November 1996, Netscape announced JavaScript to European computer
Manufacturers association (ECMA) for consideration as on industry standard and
subsequent work resulted in the standardized version named ECMAScript. ECMA is
an international standard organization for information and communication system.
In June 1997, ECMA International published the first edition of ECMA-262
specification.
A year later, in June 1998, some modifications were made to adapt it to the
ISO/IEC-16262 standard, and the second edition was released.
The third edition of ecMa-262 is the version most browsers are currently using
Fourth edition of ECMAScript standard was not released and does not exist in
practice.
Fifth edition of the ECMAScript standard was released in December 2009.
The current edition of ECMAScript standard is 5.1 and it was released in June
2011.
This way, JavaScript has become one of the most popular programming language
on the web. JavaScript was formalized in the ECMAScript language standard and
primarily used as a part of web browsers (client-side JavaScript). this enables
programmer to access the computational objects within a host environment.
JavaScript gained widespread success instantly/quickly as a client-side scripting
language for web pages. Microsoft introduced JavaScript support in its own web
browser, internet explorer, inversion 3.0, released in August 1996.
Features
JavaScript can handle simple as well as complex tasks that makes it a robust
language. it is also a good language for web designers & learners who wish to learn
computer programming as it supports both Object Oriented and function-oriented
concepts and to use it, you just need a browser and a text editor. Some specific
features of JavaScript are discussed below.
1. Browser Support: all browsers accept JavaScript as a scripting language
and provide integrated support for it. For example, to access flash content,
you need to install flash and plug-in in your browser. But to use JavaScript,
you don’t have to use any plug-in at all.
2. Client and Server-Side Support: JavaScript can be used on client side as
well as on server side: JavaScript has access to Document Object Model
(DOM) of the browser. You can change the structure of web pages at a
runtime. Thus, JavaScript can be used to add different effects to web pages.
on the other hand, JavaScript can be used on the server side as well.
3. Functional Programming Language: in JavaScript, a function can be
assigned to variables just like any other data types. a function can accept
another function as a parameter and can also return a function. this provides
you the ability to code in functional programming style.
4. Support for Objects: JavaScript is an object-oriented language. However,
the way JavaScript handles objects and inheritance is a bit different from the
conventional object-oriented programming languages like c++/ Java.
JavaScript supports most of the object-oriented concepts while being simple
to learn and use.
5. Run-Time Environment: JavaScript typically relies through upon a run-time
environment (e.g., in a web browser) to provide objects and methods by which
scripts can interact with the outside world. in fact, it relies upon the
environment to provide the ability to include/import scripts (e.g. HTML<script>
elements).
6. Vendor-specific extensions: JavaScript is officially managed by Mozilla
Foundation, and new language features are added periodically. however, only
some JavaScript engines support these new features.
7. Object based features Supported by JavaScript: JavaScript supports
various features of object-based languages and JavaScript is sometimes
referred as an object-based programming language
Advantages of JavaScript
1. JavaScript gives HTML designers a programming tool with a very simple
syntax. Sothat the designers can put small “snippets” of code into their HTML
pages.
2. JavaScript can put dynamic text into an HTML page.
3. JavaScript can react to events. For eg. a JavaScript can be set to execute
when
something happens, like when a page has finished loading or when a user
clicks on an HTML element.
4. JavaScript can read and change the contents of an HTML element.
5. JavaScript can be used to validate data of the form before it is submitted to a
server. It saves the server from extra processing.
6. JavaScript can be used to create cookies. For example, a JavaScript can be
used to store and retrieve information from the visitor’s computer.
7. JavaScript is widely used for developing modern web applications with the
capabilities of desktop applications.
8. JavaScript supports the best practices for code organization, modularization,
and reuse.
9. Using JavaScript, you can divide your application into different layers of
responsibility.
10. JavaScript build efficient, self-describing hypermedia Application
Programming
interface (APIs) with node.js.
11. JavaScript can be used to test, integrate, and deploy software updates in
rapid
cycles.
12. JavaScript control resource access with user authentication and authorization.
Applications/Uses of JavaScript
1. Developing Multimedia Applications: the users can use JavaScript to add
multimedia elements. With JavaScript you can show, hide, change, resize
images and create images rollovers. you can create scrolling text across the
status bar, thus making multimedia applications more interactive.
2. Create Pages Dynamically: based on the user’s choice, JavaScript can
generate pages that are customized by the user.
3. Interact with the user: JavaScript can do some processing of forms and can
validate user input when the user submits the form.
4. JavaScript objects are similar to dictionaries: in JavaScript, objects are
just
a collection of name-value pairs. JavaScript objects are considered as a
dictionary with string keys. The users can get and set the properties of an
object using either the familiar “.” (dot) operator, or the “()” operator, which is
typically used when dealing with a dictionary.
5. Extension: JavaScript can be extended for different purposes by
supplementing it with additional objects.
6. Client-Side JavaScript: It extends the core language by supplying objects to
control a browser (navigator or another web browser) and its document object
Model (DOM). For example, client-side extensions allow an application to
place elements on an HTML form and respond to the user events such as
mouse clicks, form input and page navigation.
7. Server-Side JavaScript: extends the core language by supplying objects
relevant to running JavaScript on a server. For example, server-side
extensions allow an application to communicate with a relational database,
which provide continuity of information from one invocation to another of the
application, or perform file manipulations on a server.
Limitations of JavaScript
JavaScript has some limitations which are natural and unavoidable.
1. JavaScript works in the browser and having less communication with the
webserver. For this reason, it cannot handle some server tasks if it is required
to do in the browser.
2. JavaScript has not any method or way to create the graphic or picture. It can
manipulate the existing pictures.
3. Core JavaScript works somewhat differently in different browsers.
4. JavaScript is not used to read or write the files on client machines.
5. It does not support inheritance, public, private and protected terms hence do
not follow the object-oriented concept completely.
Following steps show how JavaScript works with the web page.
1. When user type address or URL on the browser then a request is transmitted
to the server.
2. Server accept the browser request and returns the page to the browser.
3. Browser render the page for HTML tags and display the contents.
4. If page contains the JavaScript code, which are surrounded by <script> and
</script> tag generally then JavaScript interpreter handle the code.
5. This code can handle user-initiated event like click on the button, rolling
mouse or form submitting etc.
6. It makes the webpage interactive by detecting what is happening on the page
and responds it.
7. It can dynamically change the look of web page or contents
8. It can read the cookies and validate them
Note: Although number of handy tools are available but it is advised for the
beginners that write the code by hand which helps you the fundamentals of
the language and then you can attempt advance logic by using other tools.
Web Browser
A browser is an application program with a graphical user interface for displaying
HTML files, used to navigate the World Wide Web which provides a way to
look at and interact with all the information on the World Wide Web. the two
most popular browsers are Microsoft internet explorer and Firefox. other major
browsers include google chrome, apple safari and opera.
JavaScript is integrated into the browsing environment, which can get information
about the browser and HTML pages, and can modify this information to, thus
changing how things are presented on your screen.
<!DOCTYPE>
<html>
<head><title></title></head>
<body >
<script type="text/javascript">
Add javascript code here
</script>
</body>
</html>
Example explained
1. The do type is the first tag in a HTML document. It describe the version of
markup language used in the page which in turn help the browser to render
the HTML code.
2. Then starting code is the HTML page.
3. <head> tag contains the title of the page, other information which is not
belongs to body tag. It can also contain the JavaScript code as well.
4. <body> tag contains the JavaScript code written between <script></script>
tag along with other codes. This tag separates the JavaScript code from other
HTML data.
5. Then <body> and <html> tags ends the HTML document respectively.
JavaScript Syntax
JavaScript syntax is the set of rules that define a structured JavaScript. Here are
sometips to remember when writing your first JavaScript program.
Case Sensitivity: JavaScript is case sensitive i.e., upper case letter and lower-case
letter has differentmeaning. For example, the word “alert” has a lower case “a”. so, if
we type the wordwith an uppercase “a” then JavaScript will show an error and the
alert box will not be displayed.
Whitespace & Semi Colon: JavaScript ignores spaces, tabs, and newlines that
appear in JavaScript programs. You can use spaces, tabs, and newlines freely in
your program and you are free to format and indent the programs in a neat and
consistent way that makes the code easy to read and understand. The following
code could be written without semicolons.
But when formatted in a single line as follows, you must use semicolons -
Example explained
Whitespaces (usually spaces & tabs) are used for the better understanding & read
ability of the code to the user. Therefore, it is a good programming practice to leave
spaces and write code legibly. a semicolon is a line or statement terminator in
JavaScript. It is optional and you may skip to use semicolons in your program.
JavaScript will not show an error unless two statements are merged into a single
line.
Comments
Comments, written by preceded with two forward slashes are used to improve the
readability of program and will be ignored by the interpreter. there are two kind of
comments in JavaScript: Single line and Multi line comments.
1. single line comment begins with two forward slashes // this is a single line
comment
2. Multiline comments begin with /* and ends with */
e.g., /* this is a multiline comment and may continue across multiple lines */
comments are ignored by the interpreter and are not executed. comments
play an important role in helping the programmer to understand complex logic
while writing JavaScript code.
Line Break
line breaks are ignored except when it is used within a statement.
JavaScript Code
Note: // the comments in the above example, preceded with two forward slashes,
are used to improve the readability of program and will be ignored by the interpreter.
The write()Method
This method is used to write a string value to the page. Following code write the
“Hello JavaScript” in the body o HTML document.
<body>
<script type="text/javascript">
document.write("Hello JavaScript");
</script>
</body>
<body>
<script type="text/javascript">
document.writeln("Hello");
document.writeln(" JavaScript");
</script>
</body>
There are four different place in the HTML document where scripts can be used.
1. Body of the page: In this case when page is loaded in the browser then
output is displayed as the part of the HTML document.
2. Header of the page: In this case code is written in the form of function
(groups of JavaScript statement but treated as single unit) and referred in the
other script in the same page.
3. Within HTML tag: When JavaScript is used as a event handler (will be
discussed later) then it work with HTML elements.
4. As external file: In this case JavaScript code is written in another file having
.js extension. This file is included in a script tag by specifying the file name.
Form the above discussion first three types are treated as internal files whereas last
type is termed as external file. You will see the example of internal file in the
following section example.
In JavaScript scripts are also classified as inline, internal and external script.
Here, we consider a simple example with an embedded script. this will simply
display
a text Hello World on the screen.
<script type=“text/javascript”>
<!—
document.write(“<i>hello World!</i>”);
//My First JavaScript Program to print Hello World on the screen
</script>
When you place this in your code the text hello World will appear on the screen i.e.,
Hello World!the ‘script’ tag encloses any script code you want to use. the ‘type’
attribute is used toalert the browser to the type of script it is about to deal with, and
so helps it to interpretthe JavaScript code.consider another example:
<html>
<head>
<title>My Javascript Page</title>
</head>
<body>
<script type=“text/javascript”>
document.write("Hello"); (“Welcome to my world!!!”);
</script>
</body>
</html>
Following are the steps to add the external file in the HTML document.
1. Open the notepad editor and type following commands
function disp() { document.write(“Hello JavaScript”);}
2. Save the file with the name demo.js in the same folder where HTML
document is saved in which this file will be embedded.
3. Now open the new file in the notepad editor and add the following code
<html>
<head>
<script type="text/javascript" src="demo.js"></script>
</head>
<body>
<p>Welcome to JavaScript</p>
disp();
</body>
</html>
4. Save the file as msg.html in the same folder where .js file is saved.
5. Execute the msg.html in the browser.
Summary
JavaScript language has no concept of input or output. it is designed to run as a
scripting language in a host environment. it is up to the host environment to provide
mechanisms for communicating with the outside world. The most commonly used
host environment. is the browser. JavaScript interpreters can also be found in other
formats such as adobe acrobat, Photoshop, yahoo!’s Widget engine, and server-side
environments.
JavaScript programs manipulate values, and all these values belong to a type.
different JavaScript’s types include number, string, Boolean and objects. There is no
built-in i/o functionality in JavaScript. it is the runtime environment which provides i/o
functionality to the user. however, most runtime environments have a
console object that can be used to print output.
Further Readings
1. http://www.javascriptkit.com
2. https://developer.mozilla.org/en/docs/Javascript
3. http://www.dynamicdrive.com
Section-2: Data Types and Variables
This section deals with different Datatypes, creating variable, naming, types of
variables supported by JavaScript and how to use them.
2.2 Variables
Variables can be thought of as named containers in the computer’s memory.
You can place data in these containers and refer to the value using the name.
A variable consists of an identifier, a scope and a specific data typ
An Identifier is the name of a variable.
Usefulness of Variable
When code is written they can be used in place of unknown value.
When script is written or updated then it saves the time
Then clearer the purpose of code because you can give the meaningful name
which make the code easy to read.
Examples of variables
var X; //defines a variable X, and by default no value is assigned to this
variable
var y = 100; //defines a variable Y and assigns the value of 100 to it
var customer // declare the variable using the var keyword
X = 10; // use the = operator to assign a value
var x = 10; //assigning a value to a variable declaring it
var y=5; //y is a variable that holds a value of 5
var sum = x + y ; // sum is a variable that stores the sum of variables x and y
Variable Scope
The scope of a variable refers to the area of a program in which it can be accessed.
Variables have two types of scopes -global scope and local scope.
The global scope: consider the example while handling the rate of sugar, we can
declare a variable Sugar Rate at global. It is fixed in the fair price shop by the
government and is same throughout the state in all the fair price shops. This is an
example of a variable named sugar rate being declared globally.
The local scope: in case of local scope the rate of sugar in different retails shops
will
be specific to the rating norms of each shop. This is an example of a local variable. It
is specific within the scope of each shop.
Concatenation of variables
To concatenate variables and strings together on the same line, the + sign is used.
Addition is performed when both of the operands are numbers. In expressions
involving numeric and string values with the + operator. For example, consider these
statements:
var temp = "The temperature is " + 100;
// returns "The temperature is 100"
var message = 20 + " days till New Year";
// returns "20 days till New Year"
But, if both operands are numbers, then addition is performed:
var a= 34;
Var b = 5;
var sum = a + b; // sum is 39
Declaring Constants
A constant is a special variable with a value that cannot be changed during program
execution. JavaScript declares constants with the const type and the name of the
constant is in uppercase by convention only. Many browsers support the JavaScript
constant variable. Following statements declare the PI and INTEREST constant
variable.
const PI = 3.14;
const INTEREST = 3;
Further readings
1. http://www.javascriptkit.com
2. https://developer.mozilla.org/en/docs/Javascript
3. http://www.dynamicdrive.com
Section-3: Operators
3.1 Operators
An operator is a symbol that is used to perform an operation. in this section we
will learn how to use JavaScript operators.
Assignment Operators
Assignment operators help in assigning values to a variable. the following table
shows
how assignment operators work in JavaScript.here we consider two variables x and
y assuming x=90 and y=20. upon execution, theassignment operator will generate
the following results.
operator example Same as result
= x=y x=90
+= x+=y x=x+y x=110
-= x-=y x=x-y x=70
*= x*=y x=x*y x=1800
/= x/=y x=x/y x=4.5
%= x%=y x=x%y x=1
Arithmetic Operators
There are following arithmetic operators supported by JavaScript language: assume
variable a hold 10 and variable b holds 20 then:
operator description example
+ adds two operands a + b will give 30
- Subtracts second operand from the first a - b will give -10
* Multiply both operands a * b will give 200
/ divide numerator by denominator b / a will give 2
Modulus operator and remainder of after an integer
% b % a will give 0
division
++ increment operator, increases integer value by one a++ will give 11
decrement operator, decreases integer value by
-- a-- will give 9
one
Comparison Operators
There are following comparison operators supported by JavaScript language.
Assume variable a hold 10 and variable b holds 20 then
operator description example
checks if the values of two operands are equal or
(a == b) is not
== not,
true.
if yes then the condition becomes true.
checks if the values of two operands are equal or
!= not, (a != b) is true.
if values are not equal then condition becomes true.
checks if the value of left operand is greater than
> the value of right operand, if yes then the condition (a > b) is not true.
becomes true.
checks if the value of left operand is less than the
< value of right operand, if yes then the condition (a < b) is true.
becomes true.
checks if the value of left operand is greater than or
(a >= b) is not
>= equal to the value of right operand, if yes then the
true.
condition becomes true.
checks if the value of left operand is less than or
equal
<= to the value of right operand, if yes then the (a <= b) is true.
condition
becomes true.
Logical Operators
There are following logical operators supported by JavaScript language. assume
variable a hold 10 and variable b holds 20 then:
operator description example
called logical and operator. if both the operands are
&& (a && b) is true.
non-zero then condition becomes true.
called logical or operator. if any of the two operands
|| (a || b) is true.
are non-zero then the condition becomes true.
called logical not operator. use to reverse the
! logical state of its operand. if a condition is true then ! (a && b) is false.
logical not operator will make it false.
Bitwise Operators
There are following bitwise operators supported by JavaScript language. assume
variable a hold 2 and variable b holds 3 then:
Special Operator
Conditional operator (? :)
This operator first evaluates an expression for a true or false value and then execute
one of the two given statements depending upon the result of the evaluation.
operator description example
if condition is true? then value X : otherwise
?: conditional expression
value y
typeof operator
the typeof is a unary operator that is placed before a single operand, which can be of
any type. its value is a string indicating the data type of the operand.
the type of operator evaluates to “number”, “string”, or “Boolean” if its operand is a
number, string, or Boolean value and returns true or false based on the evaluation.
here is the list of return values for the type of operator:
Operator Precedence: It refers to the way in which the operator binds to its
operand. It determines the what operation is done first over the another. In
precedence operator’s hierarchy is formed and operator with highest
precedence stood at the top. Forexample, multiplication operator has the
higher precedence than addition so multiplication bind tightly than addition
with operand.
The increment and decrement operators, are represented by two plus signs (++) and
two minus signs (--), respectively.
Using the increment and decrement operators shortens this to
myVal++;
myVal -- ;
The result is the same — the value of myVal is increased or decreased by
one
When the ++ and -- are used on their own, as they usually are, it makes no
difference where they are placed, but it is possible to use the ++ and --
operators in an expression along with other operators. For example:
myVar = myVal ++ - 30;
This code takes 30 away from myVal and then increments the variable myVal
by one before assigning the result to the variable myVar.
If instead you place the ++ before and prefix it like this:
myVar = ++ myVal - 30;
First, myVal is incremented by one, and then myVal has 30 subtracted from it.
Search(): It returns the starting location of passing string otherwise returns -1.
var str = “This is my first script in JavaScript”
str.search(“script”); //returns 17
Substring(): It extract the substring by taking the starting and ending position as
argument. You can omit ending position then it will extract the string from starting
position to end of the string.
var str = “This is my first script in JavaScript”
str.substring(7,16) // returns “my first” as substring
Converting Number
Number(): This method is used to convert any type to number type.
For example,
Number (“40”) convert string value “40” to 40.
Number (null) convert null to 0
Number (“”) convert empty string to 0
Number(false) convert false to 0
Number(“type”) it cannot be converted so return NaN
parseInt(): This method returns the integer value by accepting two argument.
First argument is string having numeric value.
Second argument is radix which specify the returning value presentation in a
specific number system.
If radix is omitted then either it checks the beginning of string for radix. For
example, if string begins with “ox” then radix is 16 (Hexadecimal), if string
begins with “o” then radix is 8 (octal) otherwise radix is taken 10 (decimal).
For example:
parseInt (“10”) returns 10
parseInt (“40.33”) returns 40
parseInt (“19 Covid”) returns 19
parseInt (“Covid 19”) returns NaN
parseInt (“15”, 8) returns 13
parseInt (“0x16”) returns 22
parseFloat(): This method returns the integer value by accepting one string
argument. It parses the string for conversion for number. If number exists up to end
then it converts the number and return otherwise returns NaN. For example:
parseFloat(“23”) returns 23
parseFloat(“23.55”) returns 23.55
parseFloat( “23 yard”) returns 23
parseFloat( “yard 55”) returns NaN
Converting Boolean
Boolean() method convert any type to Boolean type which is supported.
<!DOCTYPE>
<html>
<head>
<title> Example of confirm box </title>
</head>
<body>
<script type="text/javascript">
var ans =confirm("Are you really want to cancel the order?");
if (ans == true) {
alert("Order has been canceled!");
}
else{
alert("WOW! You have change the mind ");
}
</script>
</body>
</html>
S. no. Activities
Create a JavaScript program that prompts the user for a phone number and
1.
thenasks the user for confirmation.
Write a program to ask user to input two values and then perform the
2.
arithmetic operation and display the result.
Write a program to calculate the simple interest by inputting the values from
3.
the user.
Write a program to display a confirmation box which says “Did you enjoy
4.
learning JavaScript session?”
Write a program to display a prompt box which says “Please give your
5.
feedback here”
Answer the following questions
Q.1: What is a dialog box?
Q.2: What is Window object?
Q.3: What is alert() method?
Q.4: What is prompt() method?
Q.5: What is confirm method()?
Q. 6: What happens when user click the cancel button of prompt dialog box?
Q. 7: What is the difference between confirm and alert method?
Q. 8: Why you don’t specify the name of the object with these methods.
Q. 9: When you would use the confirm() dialog box
Q. 10. Fill in the blanks
(a) A(n) __________ object is created for each window that appears on the screen.
(b) The __________ method pops up a message to the viewer, and the viewer has
to click anOK button to continue.
(cThe prompt() method is used to __________ the viewer to enter information.
(d) Second argument in prompt method is _____________
Further Readings
1. http://www.javascriptkit.com
2. https://developer.mozilla.org/en/docs/Javascript
3. http://www.dynamicdrive.com
Section-5: Decision Making using if and switch
5.1Block and Compound Statement
A statement in a code which states that something will happen with this line is called
the single statement. A simple expression, assigning value or check the condition
are the example of single statement.
When we want to execute the more than one statements in response of the condition
which is true then these types of statements are surrounded by curly braces. The
effect of wrapping which wrap the many statements as a single statement is called
the compound statement.
The decision-making construct like if, else, switch executes the blocks once if
condition is true or skip the block. The looping construct repeatedly executes the
block until condition is false or loop is not terminated.
Fig. 5.1
Example: Make a “happy day” greeting if the hour is less than 18:00:
<!DOCTYPE>
<html>
<head></head>
<body>
<p>Display Good Day! if the hour is less than 18:00: </p>
<script type="text/javascript">
var d = new Date();
var hr = d.getHours();
if (hr < 18) {
document.write("Good Day! ");
}
</script>
</body>
</html>
Output: display “happy day!” if the hour is less than 18:00:
happy day!
The else statement can be used to specify a block of code to be executed if the
same
condition is false.
syntax: else statement
if (condition) {
block of code to be executed if the condition is true
} else
{
block of code to be executed if the condition is false
}
Example: if the hour is less than 18, create a “good day” greeting, otherwise “good
evening”:
<!DOCTYPE>
<html>
<head></head>
<body>
<p>Display Good Day! if the hour is less than 18:00: otherwise Display Good
Eveening</p>
<script type="text/javascript">
var d = new Date();
var hr = d.getHours();
if (hr < 18) {
document.write("Good Day! ");
}
else
{
document.write("Good Evening! ");
}
</script>
</body>
Output: the above script will display “good day or good evening” depending upon
the current time of the day
The ‘else if’ Statement is used to specify a new condition if the first condition is false.
syntax:
if (condition1)
{
block of code to be executed if condition1 is true
} else if (condition2) {
block of code to be executed if the condition1 is false and condition2 is true
} else {
block of code to be executed if the condition1 is false and condition2 is false
}
Example: if time is less than 10:00, display a “good morning” greeting, if not, but
time is less than 20:00, display a “good day” greeting, otherwise a “good evening”:
greeting
<!DOCTYPE>
<html>
<body>
<p>Display Greeting Hours Entered by User </p>
<script type="text/javascript">
var hr =prompt("Enter Hour", "23");
if (hr < 10) {
document.write("Good Morning! ");
}
else if (hr < 20) {
document.write("Good Day! ");
}
else {
document.write("Good Evening! ");
}
</script>
</body>
</html>
Output: Display “good morning or good day or good evening” depending upon the
current time of the day
Example: Calculate discount price base on total amount. If amount is less than
10000 then no discount. If amount is less than 20000 then discount is 5%. If amount
is less than 30000 then discount is 10%. If amount is more than 50000 then discount
is 15%.
<!DOCTYPE>
<html>
<body>
<p>Calculate Discount Total Amount Entered by User </p>
<script type="text/javascript">
var tamt =prompt("Enter Total Amount", "0");
if (tamt == 0) {
document.write("Invalid Amount");
}
else if (tamt < 10000) {
document.write("No Discount");
}
else if ( tamt < 20000) {
disAmt = tamt - (tamt *.05);
document.write(" Total Amount after Discount = " + disAmt) ;
}
else if ( tamt < 30000) {
disAmt = tamt - (tamt *.1);
document.write(" Total Amount after Discount = " + disAmt) ;
}
else {
disAmt = tamt - (tamt *.15);
document.write(" Total Amount after Discount = " + disAmt) ;
}
</script>
</body>
</html>
The switch statement is used to select one of many blocks of the code to be
executed
in a program described below. the switch expression is evaluated once and the value
of the expression is compared with the values of each case. if there is a match
found,
then the associated block of code is executed otherwise default code block is
executed.
Syntax: switch statement (as defected in figure 3.2)
switch (expression){
case n:
code block
break;
case n:
code block
break;
default:
default code block}
Fig. 3.2
Example: Use the weekday number to calculate weekday name with the help of
getday() method.the getday() method returns the weekday as a number between 0
and 6. (Sunday=0,Monday=1, Tuesday=2 ..)
<!DOCTYPE>
<html><body>
<p> Display Day of Week</p>
<script>
var d = new Date();
var n = d.getDay()
switch(n){
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";}
document.write("Today is "+ day);
</script>
</body>
</html>
Output: today is Sunday (from Sunday to Saturday each single day will be displayed
depending upon current day of the week.
Example: This example is same as the above but it asks the day from the user and
check for invalid day values as well. It also use the parseInt() method as well.
<!DOCTYPE>
<html><body>
<p> Display Day of Week Day Entered by User</p>
<script>
d =prompt ("Enter Number of the Day to Find name the Day of The Week");
da= parseInt(d);
switch(da){
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday"; }
document.write("Today is "+ day);
</script>
</body>
</html>
Section-5: Exercise Questions
S. no. Activities
Write a program to:
1. Determine if a student has passed in his exam or not. if the marks are
greater than 40 then he has a passed else he has a failed.
1.
2. Determine what grade he has obtained based on the marks obtained if
90-100 is a+; 80-90 is a ;70-80 is b+; 60-70 is b ; 50-60 is c; 40-50 is d
and below 40 is fail [hint : use the if-else if..-else]
Write a program using the switch statement to print the names of class
2. teacher of all grades from 1 to 10. hint: let the grade be a variable.
depending on its value, print the names of the class teacher.
if a student has an amount greater than rs 50 he uses an auto , else if he
has an amount between rs 20 to rs 50 he uses the shared auto else if he
3.
has between rs 5 to rs 20 he uses the public bus or else he walks to his
school. Write this using the if-else if -else condition
Write a JavaScript program where the program chooses a random integer
between 1 to 10, then the user is prompted to input a guess number. if the
4.
user input matches with the guess number, the program will display a
message“good Work” otherwise it will display “not matched”.
Write a JavaScript conditional statement to find the sign of product of three
numbers. Display an alert box with the specified sign such as:
5.
Sample Input numbers : 3, -7, 2
Output : the sign is: -
Write a JavaScript conditional statement to sort three numbers in
descending
6. order. display an alert box to show the result.
Sample Input numbers: 0, -1, 4
Output: 4, 0, -1
Write a JavaScript conditional statement to find the largest of five numbers.
display an alert box to show the result.
7.
Sample Input numbers : -5, -2, -6, 0, -1
Output: 0
Further Readings
1. http://www.javascriptkit.com
2. https://developer.mozilla.org/en/docs/Javascript
3. http://www.dynamicdrive.com
Section-6: Looping Structure
6.1 Loops
Loops can be used to execute the same code over and over again, particularly
useful
when dealing with arrays as shown in figure 3.3. JavaScript supports different kinds
of
loops described below:
for - loops through a block of code a number of times
for/in - loops through the properties of an object
while - loops through a block of code while a specified condition is true
do/while - also loops through a block of code while a specified condition is true
For Loop
The for loop is best suited when you already know the number of times the
statements
should be executed. the loop executes until the condition becomes false.
Syntax:
for(initialization; condition; increment)
{//statements }
Fig. 6.1
When a for loop executes
1. The initializing expression is get executed and this expression usually initializes
one
or more loop variables.
2. The condition expression is evaluated. if the value of condition is true, the loop
statements are executed. if the value of condition is false, for loop terminates.
3. The increment expression executes and increments the value by the specified
step
value.
4. The statements execute, and control returns to step 2.
Example
<!DOCTYPE html>
<html>
<body>
<p> For loop Example</p>
<script>
for (i = 0; i < 5; i++) {
document.write("Hello Life! You are so Good" +"<br>"); }
</script>
</body>
</html>
Output:
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Example explained
From the above example we can notice that statement 1 sets a variable before the
loopstarts (var i = 0). Statement 2 defines the condition for the loop to run (i must be
less than4). statement 3 increases a value (i++) each time the code block in the loop
has beenexecuted. in JavaScript, we normally use statement 1 to initiate the variable
used in theloop (i = 0). although, this is not always the case, JavaScript doesn’t care.
statement 1is optional. We can initiate many values in statement 1 (separated by
comma):
Example
for (i = 0, y=5; i <y; i++)
{
document.write("Hello Life! You are so Good" +"<br>");
}
Note: We can omit statement 1 when the values are set before the loop starts:
Example:
var i=0;
for (; i <5; i++)
{
document.write("Hello Life! You are so Good" +"<br>");
}
Statement 3 can be used for negative increment (i--), positive increment (i = i + 15),
oranything else.
Example:
for (i=5; i >0;i--)
{
document.write("Hello Life! You are so Good" +"<br>");
}
Statement 3 can also be omitted when we increment the values inside
the loop such as:
Example:
var i=0;
for (; i <5;)
{
document.write("Hello Life! You are so Good" +"<br>");
i++
}
For..in Loop
The for/in loop: the JavaScript for/in statement loops through the properties of an
object explain below.
Example
<!DOCTYPE html>
<html>
<body>
<p> For..in Loop Example></p>
<script>
var person = {fname:"Aman", lname:"Maan", age:35};
var text = "";
var x;
for (x in person) {
text += person[x] + " ";
}
document.write(text);
</script>
</body>
</html>
var i = 1;
while (i < 10) {
alert(i);
i = i + 1;
}
// At this point the value of i is 10
We can write the same program which was discussed in For Loop section with the
While loop. Major difference is For loop is easy to write with one line syntax whereas
in while loop the parts of loop are written separately.
Example: This is the same example of For Loop Section but executed with while
loop rather than for loop.
<!DOCTYPE html>
<html>
<body>
<p>While loop Example</p>
<script>
var i=0;
while( i < 5)
{
document.write("Hello Life! You are so Good" +"<br>");
i++;
}
</script>
</body>
</html>
After the loop has finished, the code keeps on running from just after the closing
brace(“}”) of the loop’s block
Output:
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Example: This example calculates the table up to 10. Table value is asked from the
user.
<!DOCTYPE html>
<html>
<body>
<p> While loop Example</p>
<script>
var t = prompt("Enter Table to calculate up to 10");
x = parseInt(t);
var i=1;
while( i <= 10)
{
value = x *i
document.write( x +" * " + i + " = "+value +"<br>");
i++;
}
</script>
</body>
</html>
This is another kind of loop and different from the for loop and the while loop. this
loop will execute the statement at least once that is the statements inside the loopwill
always get executed at least once, even if the condition is false. the condition is
checked happens after the loop has been executed. the loop will continue to execute
orwill terminate according to on the condition as shown in figure 6.3.
do while syntax:
var i = 1;
do {
alert(i);
i = i + 1;
} while (i<10)
// At this point the value of i is 10
Fig. 6.3
Example: This example shows the difference between while an do-while. We use
the condition which Is false initially. If you use this condition in while loop it won’t be
executed but in do-while it will execute at least once.
Using While Loop
<!DOCTYPE html>
<html>
<body>
<p> Do-While loop Example</p>
<script>
var i=1;
while( i < 0)
{
document.write("Hello Life! You are so Good" +"<br>");
i++;}
</script>
</body></html>
Output:
No Output
Using Do-While Loop
<!DOCTYPE html>
<html>
<body>
<p> Do-While loop Example</p>
<script>
var i=1;
do
{
document.write("Hello Life! You are so Good" +"<br>");
i++;
}while( i < 0)
</script>
</body>
</html>
Output:
Hello Life! You are so Good
Example: This is the same example of For Loop Section but executed with while
loop rather than for loop.
<!DOCTYPE html>
<html>
<body>
<p> Do-While loop Example</p>
<script>
var i=0;
do
{
document.write("Hello Life! You are so Good" +"<br>");
i++;
}while( i < 5)
</script>
</body>
</html>
After the loop has finished, the code keeps on running from just after the closing
brace(“}”) of the loop’s block
output:
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Try the given examples using different loops i.e. programs written in for loop
try these programs in while and do-while. In the same do with other loop
programs. You will get better idea.
<!DOCTYPE html>
<html>
<body>
<p> For loop with break Example</p>
<script>
for (i = 0; i < 5; i++)
{
if( i==3)
break;
document.write("Hello Life! You are so Good" +"<br>");
}
</script>
</body>
</html>
Output: this loop will stop when i ==3 , with a break.
Hello Life! You are so Good
Hello Life! You are so Good
Hello Life! You are so Good
Continue statement skip the statement(s) below when condition is true which
enables the continue statement to be executed.
Example: This example shows the working of continue statement
<!DOCTYPE html>
<html>
<body>
<p> For loop Example</p>
<script>
for (i = 1; i <= 5; i++)
{
if( i==3)
continue
document.write("The number is " + i+ "<br>");
}
</script>
</body>
</html>
Output: this loop will skip the documents.write() statement when i ==3 set to true.
The number is 1
The number is 2
The number is 4
The number is 5
You can execute continue and break statement without if condition but it may cause
to diverse effect in the code because continue statement may fall the loop into
infinite loop if it is placed in a wrong in the code.
Example: This example shows how continue statement convert the while loop into
infinite loop.
<!DOCTYPE html>
<html>
<body>
<p> While loop becones infinite loop Example</p>
<script>
var i=1;
while(i <= 5)
{
if( i==3)
continue
i++
document.write("The number is " + i+ "<br>");
}
</script>
Output: this loop will skip the i++ and documents.write() statement when i ==3 set
to true and becomes infinite
The number is 1
The number is 2
S. no. Activities
Write a JavaScript program using for loop that will iterate from 0 to 15. For
each iteration, it will check if the current number is odd or even, and display
amessage on the screen.
Sample Output :
1. “0 is even”
“1 is odd”
“2 is even”
----------
----------
Write a JavaScript program which compute the average marks of the
following students.
Further Readings
1. http://www.javascriptkit.com
2. https://developer.mozilla.org/en/docs/Javascript
3. http://www.dynamicdrive.com