Beginning SVG: A Practical Introduction to SVG Using Real-World Examples Alex Libby 2024 scribd download
Beginning SVG: A Practical Introduction to SVG Using Real-World Examples Alex Libby 2024 scribd download
com
https://textbookfull.com/product/beginning-svg-a-
practical-introduction-to-svg-using-real-world-
examples-alex-libby/
https://textbookfull.com/product/introducing-dart-sass-a-practical-
introduction-to-the-replacement-for-sass-built-on-dart-1st-edition-
alex-libby/
textbookfull.com
https://textbookfull.com/product/consumers-and-nanotechnology-
deliberative-processes-and-methodologies-2nd-edition-pal-strandbakken/
textbookfull.com
Woman Enough How a Boy Became a Woman and Changed the
World of Sport First Canadian Edition Kristen Worley
https://textbookfull.com/product/woman-enough-how-a-boy-became-a-
woman-and-changed-the-world-of-sport-first-canadian-edition-kristen-
worley/
textbookfull.com
https://textbookfull.com/product/textiles-and-fashion-materials-
design-and-technology-1st-edition-rose-sinclair/
textbookfull.com
https://textbookfull.com/product/until-you-re-mine-hayes-samantha/
textbookfull.com
https://textbookfull.com/product/cannabis-in-medicine-an-evidence-
based-approach-kenneth-finn/
textbookfull.com
https://textbookfull.com/product/decode-and-conquer-answers-to-
product-management-interviews-lewis-c-lin/
textbookfull.com
Handbook on Marine Environment Protection Science Impacts
and Sustainable Management 1st Edition Markus Salomon
https://textbookfull.com/product/handbook-on-marine-environment-
protection-science-impacts-and-sustainable-management-1st-edition-
markus-salomon/
textbookfull.com
Alex Libby
Beginning SVG
A Practical Introduction to SVG using Real-World
Examples
Alex Libby
Rugby, Warwickshire, UK
Trademarked names, logos, and images may appear in this book. Rather
than use a trademark symbol with every occurrence of a trademarked
name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark. The use in this publication
of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of
opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true
and accurate at the date of publication, neither the authors nor the
editors nor the publisher can accept any legal responsibility for any
errors or omissions that may be made. The publisher makes no
warranty, express or implied, with respect to the material contained
herein.
1. Introducing SVG
Alex Libby1
Let me start with a question – which image format should I use: bitmap
or vector, PNGs, JPEGs…?
If you spend any time developing content for the web, then I am
sure you’ve asked yourself this question countless times: there is a
whole array of different formats that we can use, all of which have their
own particular qualities! There isn’t a single image format that is ideally
suited to the web, which encompasses the best qualities of all image
types, although Google has tried to push this with the WebP format,
which hasn’t received widespread adoption among other browser
providers.
In many cases, I suspect that either JPEG or PNG images would be
favored; these are perfect for complex images where detail is essential
(such as photographs). However, if you need to display clear line
drawings, or 2D images, for example, then these formats aren’t ideal.
There are several reasons why, but one of the key weaknesses is
maintaining quality – try resizing a schematic saved as a PNG, and the
quality soon becomes very poor! There has to be a better way surely…?
Indeed there is – let me introduce you to the world of SVG, or
Scalable Vector Graphics. Some people might associate them with
applications such as Adobe Illustrator – it’s a perfectly valid
assumption; Illustrator is a market-leading product, even if it is
something of a heavyweight application. However, there is a whole lot
more to working with SVG images – over the course of this book, we’ll
see how easy it is to manipulate them using nothing more than just a
text editor and a browser. There’s lots to cover, so without further ado,
let’s make a start on exploring the benefits of using SVG images in our
projects.
<img class="mama"
src="https://s.cdpn.io/3/kiwi.svg">
4. Save the file, then preview the results in a browser – if all is well,
you should see something akin to the screenshot shown in
Figure 1-3.
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Figure 1-3 Updated image of a kiwi bird
See how easy it was? Yes, the code may look archaic, but don’t worry –
as we go through some of the elements in more detail throughout this
book, things will become clearer and easier to understand.
Try running through the steps again, but this time choose different
colors – you will see that the image is updated but will also retain
the same level of clarity throughout.
Okay – let’s change tack: now that we’ve completed our first edit, it’s
time we took a look at how the SVG format stacks up against other
image formats and see why there are occasions where SVG images will
give a superior result compared to standard images.
Comparing Formats
When working on the web, we have a number of image formats we can
choose from to display visual content. In many cases, it’s likely that
JPEG or PNG will be selected – these formats represent the best choice
for size and support in today’s modern browsers, when working with
photo-based imagery. However, in a world where websites must be
accessible on different devices, these formats do not scale well if we
need to use line-based drawings; we’ve already covered how SVG can
help in this respect.
To really understand how it can benefit us, it’s worth taking a
moment to see how the format compares to standard images; the key
benefit is the ability to manipulate, but there are other reasons why SVG
should be considered as a format:
Resolution independence – with many image formats, we might have
to download extra data or assets to fix resolution-based issues. A
great example is when using retina screens, which require us to apply
a @2x hack to force higher-resolution images to be displayed. This
isn’t the case with SVG images; these can be fully resized, irrespective
of device or resolution used, and without the need for additional tags.
Accessible DOM API – SVG elements can be manipulated using
nothing more than standard JavaScript or CSS; this could be as simple
as changing colors (as we saw back in the exercise “Changing a Color
in an SVG Image”) or as complicated as attaching event handlers to
perform specific events.
No unnecessary HTTP requests – unlike standard images, SVG images
are created using XML and CSS. This avoids the need for the browser
to request an image from the server, making it faster and more user
friendly.
Content can be indexed, scaled, searched, scripted, and compressed.
We can create images using nothing more than a text editor – yes, it
might be easier to create them in a suitable graphics application.
However, let us not forget that the key principle I outlined earlier:
Why download and install a graphics package if we can achieve the
same result in a text editor that we already have?
With this in mind, it’s worth summarizing what we should use SVG
for – in summary, they are perfect where we need:
Logos and icon with strong, geometric, vector-friendly designs;
Graphics that need to be displayed in multiple sizes and screens;
Graphics that respond to their device;
Graphics that need to be edited, updated, and redeployed.
In comparison (and as a reminder), we can see how this stacks up
against other image formats, as outlined in Table 1-1.
Table 1-1 Comparison of Image Formats and Their Uses
PNG-8 Lossless Maximum Similar to GIFBetter transparency but no animationGreat for icons
256 colors
WebP Lossless Unlimited Similar to PNGs, but typically 26% smaller in size – take-up isn’t
colors so extensive, with only Chrome and Opera supporting the format
at present
Okay – enough theory , methinks! Let’s move swiftly on, and turn our
attention to more practical matters.
We’re at the point where we need to ensure we have the right tools
in place – some of you may think this requires an array of different
applications to be set up: as some might say, not if we can help it! True,
there are some tools we can install if we decide to develop more
advanced solutions, but for now, there is very little that we need to
install. Let’s take a look at what we do need, in more detail.
And under the capital of one of the doorway pillars is the line, rather
difficult to construe, but in beautiful lettering:—
The severe three-light east window has good glass by Kempe. The
spire, a very good one, is later than the tower, and built of squared
stones, different in colour from the small stones of the tower. Two
half figures incised in bold relief on fourteenth century slabs, are
built into the north wall, opposite the south door.
Keeping along the Lincoln road the next place we HONINGTON AND
reach is Honington. The Early English tower of the CAYTHORPE
church is entered by a very early pointed arch, the
nave being of massive Norman work with an unusually large corbel
table. There are the remains of a stone screen, and a canopied
aumbry in the chancel was perhaps used as an Easter sepulchre.
The chantry chapel has monuments of the Hussey family, and one of
W. Smith, 1550, in gown and doublet. An early slab, with part of the
effigy of a priest on it, has been used over again to commemorate
John Hussey and his wife, he being described on it as “A professor of
the Ghospell,” 1587. To the south-east of the village is what was
once an important British fort with a triple ditch, used later by the
Romans whose camp at Causennæ on the “High Dyke” was but four
miles to the east. Less than two miles brings us to Carlton Scroop,
with a late Norman tower and Early English arcade, also some good
old glass and a Jacobean pulpit. The remains of a rood screen and
the rood loft steps are still there.
A mile further on is one of the many Normantons, with Early
English nave, decorated tower, fine west window, and Perpendicular
clerestory.
Two miles on we come to Caythorpe, which is FULBECK AND
built on a very singular plan, for it has a double LEADENHAM
nave with a buttress between the two west
windows to take the thrust of the arches which are in a line with the
ridge of the roof. This forms the remarkable feature of the church
interior. There are short transepts, and the tower rises above the
four open arches. Over one of these there is a painting of the Last
Judgment. There are fine buttresses outside with figures of the
Annunciation and the Coronation of the Virgin, and one of our Lord
on the porch. The windows are large. The spire is lofty but
unpleasing, as it has a marked “entasis” or set in, such as is seen in
many Lincolnshire and Northamptonshire spires, which hence are
often termed sugar-loafed. Before its re-building, in 1859, after it
had been struck by lightning, the entasis was still more marked than
it is now. The singularly thin, ugly needle-like spire of Glinton, just
over the southern border of the county near Deeping, has a slight
set in which does not improve its appearance. A mile to the north
the road passes through the very pretty village of Fulbeck. The dip
of the road, the charming old houses, grey and red, the handsome
church tower with its picturesque pinnacles, and the ancestral
beauty of the fine trees, make a really lovely picture. Fine iron gates
lead to the Hall, the home of the Fanes, an honoured name in
Lincolnshire. Many of the name rest in the churchyard, and their
monuments fill the dark church, which has a good Norman font. The
tampering with old walls and old buildings is always productive of
mischief, and, as at Bath Abbey, when, to add to its appearance,
flying buttresses were put up all along the nave, the weight began to
crush in the nave walls, and the only remedy was to put on, at great
expense, a stone groined roof, which is the real raison d’être of
flying buttresses, so here at Fulbeck, when they pulled down the
chancel and built it up again with the walls further out, the
consequence was that the east wall of the nave, missing its
accustomed support, began to lean out eastwards.
Another mile and a half brings us to Leadenham, where the east
and west road from Sleaford to Newark crosses the Great North
road. The fine tall spire is seen from all the country round, for it
stands half way up the cliff. But this and the rest of the road to
Lincoln is described in Chapter XIII.
If you go out of Grantham by the south-west, HARLAXTON AND
you should stop at a very pretty little village to the DENTON
south of the Grantham and Melton road, from
which a loop descends to an old gateway, all that is left of the old
Harlaxton Manor, a pretty Tudor building now pulled down, the stone
balustrades in front of it having been removed by Mr. Pearson
Gregory to his large house a mile off, built on the ridge of the park
by Salvin in 1845. The Flemish family of De Ligne lived in the old
Hall in Jacobean times, and their predecessors are probably
represented by the fine but mutilated alabaster recumbent effigies
now in the northern, or Trinity, chapel of the church. In the north-
east angle of this chapel is a very graceful canopied recess on a
bracket, much like those at Sedgebrook, about five miles off on the
border of the county.
The north aisle and nave are older than the tower and south aisle;
and a curious staircase ascends at the east of the south aisle wall,
from which a gangway crossed to the rood loft.
There are many aumbries in various parts of the church, and a
tall, Decorated font, with grotesque faces in some panels, and in
others sacred subjects oddly treated, such as our Lord crowned and
holding a Chalice. In the south aisle is an old oak post alms-box
resembling one at Halton Holgate.
A doorway leads out from the south side of the east end, an
entrance probably to an eastern chapel. The two doorways, one on
each side of the altar, at Spalding may have led to the same, or
possibly to a vestry, as in Magdalen Chapel, Oxford.
The spire has a staircase, passing curiously from one of the
pinnacles. A very massive broken stone coffin, removed from a
garden, lies in the south chapel. The fine row of limes, and the ivy-
grown walls of old Harlaxton Manor, add to the beauty of this quiet
little village, and a group of half-timbered brick buildings, said to be
sixteenth century, though looking more modern, which are near the
church, are a picturesque feature.
Denton Manor, the seat of Sir C. G. E. Welby, BELVOIR CASTLE
Bart., is just beyond Harlaxton, and there one
might once have seen a fine old manor house, now replaced by a
large modern hall of fine proportions; the work is by Sir A. W.
Blomfield, good in design and detail, and containing a notable
collection both of furniture and pictures. St. Christopher’s Well, a
chalybeate spring, is in the park, and in the restored church are a
good recumbent effigy of John Blyth, 1602, and a figure of Richard
Welby, 1713, with angels carefully planting a crown on his wig. After
this the road passes into Leicestershire, so we turn to the right and
in less than four miles, halfway between the Melton road and the
Nottingham road, and more in Leicestershire than in Lincolnshire, we
come to Belvoir Castle. The mound on which it stands is over the
border and is not a natural height, but was thrown up on a spur of
the wold as early as the eleventh century by Robert de Todeni, who
thence became known as Robert de Belvedeir. Certainly the pile is
grandly placed, and has a sort of Windsor Castle appearance from all
the country round. It has been in possession of the Manners family
now for four hundred years. The celebrated Marquis of Granby, a
name well known in all the neighbourhood as a public-house sign,
was son of the third Duke. He was “Col. of the Leicester Blues” in
1745, and General and Commander-in-Chief of the British contingent
at Minden, where the English and German forces, under the Duke of
Brunswick, defeated the French in 1759, and he distinguished
himself in battle in each of the three following years. The castle,
destroyed by order of Parliament in the civil wars, was rebuilt in
1668, and again in 1801, but a fire having destroyed part of it in
1816 it was restored at the worst of all architectural periods, so that
at a near view it does not fulfil the expectation raised by its grand
appearance when seen from a distance. As at Windsor there is a
very fine “Guard Room,” and many large rooms hung with tapestry
or pictures, and a picture gallery of unusual excellence. The
Duchess’s garden in spring is one of the finest horticultural sights in
the kingdom. The greater part of the castle is most liberally thrown
open daily to the public.
Returning from Belvoir we can pass by Barrowby to join the
Nottingham and Grantham road, which leaves the county at
Sedgebrook, on either side of which are seen the churches of
Muston and East and West Allington, where Crabbe, the poet, was
rector 1789-1814. West Allington church stands in Mr. Welby’s park,
and close by, a salt well is marked on the map. At Sedgebrook is a
farm house which was built as a manor-house by Sir John Markham
in the sixteenth century, when he was Lord Chief Justice of the
King’s Bench. He it was who received the soubriquet of “The upright
Judge,” on the occasion of his being turned out of office by Edward
IV., because of his scrupulous fairness at the trial of Sir Thomas
Coke, Lord Mayor of London.
From Sedgebrook to Barrowby is three miles of level ground, and
then the road rises 150 feet to the village, which commands a
splendid view over the vale of Belvoir. Leaving this you descend a
couple of miles to Grantham.
At the outskirts of the town the road meets two GONERBY HILL
others, one the northern or Lincoln road, and the
other the north-western or Newark road. This is the Great North
Road, and it starts by climbing the famous Gonerby Hill, the terror
and effectual trial ground of motors in their earliest days, and
described by “mine host” in The Heart of Midlothian as “a murder to
post-horses.” The hill once gained affords a fine view eastwards,
Foston and Long Bennington (which has a large church with a
handsome porch, a good churchyard cross, and a mutilated market
cross), are the only villages, till the road crosses the county
boundary near Claypole, and runs on about four miles to Newark,
distant fifteen miles from Grantham. Long Bennington is a mile
north-east of Normanton Lodge, where Lincolnshire,
Nottinghamshire, and Leicestershire touch.
Stubton, a couple of miles to the east, has a fine group of yew
trees growing round the tomb of Sir George Heron, one of the family
from Cressy Hall, Gosberton, I suppose, who built the hall now
occupied by G. Neville, Esq.
Between Stubton and the Grantham-and-Lincoln road are many
winding lanes, by a judicious use of which you may escape the fate
that overtook us of landing after a steep and rather rough climb
from Barkstone at two farms one after the other, beyond which the
road did not even try to go. If you have better luck you will reach
the out-of-the-way parish church of Hough-on-the-Hill.
This, the last resting-place of King John, when HOUGH-ON-THE-
on his journey to Newark where he died, has a HILL
church whose tower is singularly interesting, being akin to St. Peter’s
at Barton-on Humber, and the two very old churches in Lincoln, and
one at Broughton, near Brigg, and we may add, perhaps, the tower
at Great Hale.
The work of all these towers is pre-Norman, and it is not unlikely
that the church, when first built, consisted of only a tower and two
apses. At Hough, as at Broughton, we have attached to the west
face of the tower a Saxon circular turret staircase, built in the rudest
way and coped with a sloping top of squared masonry, of apparently
Norman work. The tower has several very small lights, 12 to 15
inches high, and of various shapes, while the west side of the south
porch is pierced with a light which only measures 8 inches by 4, but
is framed with dressed stone on both the wall-surfaces. The two
lower stages of the square tower, to whose west face the round
staircase-tower clings, are all of the same rough stone-work, with
wide mortar joints, but with two square edged thick string-courses
of dressed stone, projecting 6 inches or more. The upper stage is of
much later date. The Early English nave, chancel, and aisles are very
high, and are no less than 20 feet wide, mercifully (for it was
proposed to abolish them and substitute a pine roof) they still retain
their old Perpendicular roofs with the chancel and nave timbers
enriched with carving. The sedilia are of the rudest possible
construction.
Hough-on-the-Hill.
And in 1686:—
A good, sound method of dealing with “Vagrom men,” but for the
women and children one wonders the parson or churchwardens
were not ashamed to make the entry.
Great Hale.
Helpringham.
We will now go back to Sleaford and trace out the course of its
other western road to Newark, leaving the north or Lincoln Road to