A special Webbed Briefs

Excuse me, while I draw a line onto your computer screen.

In the immortal words of Jonathan Cash.

Okay.

So fine.

I've drawn a line.

A line is a kind of an emaciated rectangle joining two points in space.

In this case point A and point C where's point B you might ask point B is somewhere over here, off screen because points B forgot to bring their [beep] release form and cannot therefore take part in this video.

Sorry.

The question is, how did I draw this line onto your screen? How did I make all the right pixels light up to form that line like shape? And the answer is, none of your [beeping] business.

Seeyalater yeah? If you're still there.

I suppose I can tell you how I might have drawn my line.

Number 1 the Horizontal Rule HTML doesn't have a l element because if it did people, wouldn't be able to tell if it was l for line or capital I for, uh, I am a line instead there's the verbosity and officiously named horizontal rule La De Dah.

The horizontal role is a semantic element representing a thematic break in your content.

For example, you might use a horizontal rule to separate to the long rambling travelogue part of your recipe page from the actual recipe, it's arguably more helpful to use an h2 heading with the actual text, the actual cooking recipe, but I digress.

By default, browsers give horizontal rules their lineishness using the border property.

You'll notice there's what appears to be a shadow cast by the line, which really makes it pop.

But what the lame stream media doesn't tell you is that this shadow isn't really a shadow, but the effect of using a border style of inset on all sides of an elements with no height, if you want to remove this thing, that isn't really a shadow there is a property for the horizontal rule.

Curiously named no shade.

The no shade property is what's called deprecated.

Which means you shouldn't use it anymore, [even though you can] like don't, [but seriously, go ahead.

It's fine].

But for how long? [no you're good].

Or are you?, in any case you can just restart the border using CSS, make the border more permissive with border style, dashed, or use pseudo contents to label the points sh*t like that.

All of this styling we can do to a horizontal rule.

We can just as easily do to a div, but there are reasons why div is short for divisive . Firstly, screen readers do not acknowledge empty divs, meaning screen reader users would be ushered from blah-blah-blah , sunkissed rural Tuscany into one tablespoon toasted Sesame oil, without any kind of warning.

Secondly, divs are not recognized by shorthand syntax, like markdown.

Why should a content editor have to write div class equals horizontal hyphen rule closed div when a horizontal rule in markdown is just three asterisks.

Number two, Scalable Gector graphics Scalable vector graphics, or sverg are named for their incorporation of graphics that are scalable on account of them being vectors like HTML they're a kind of markup and because they can be embedded into HTML, they are a kind of markup that is kind of a part of a kind of markup.

SVG offers a number of ways to draw lines.

If you're interested in being obtuse, you could use a rec elements with a height of one.

Naturally.

The name Rec is short for rectangle from the Latin etymology rectum.

A more on the nose approach would be to use the line elements, whether it's x1 y1 x2 and y2 attributes.

These lines are only ever straight, or at least that's what they tell themselve.

To make your line change direction and create corners you want to polyline which takes a set of points.

By far the most powerful and versatile line thingy in SVG is the path.

The paths d attribute, which stands for dem points can include special commands like M the M command lets you start a new line using the same path beginning at a different position.

Monk is a word that starts with M which is pertinent here because a group of monks from the 12th century, presumably in the early hours, before they got beeped up on monastic beer, invented a numbering system wherein every number between zero and 9,999 can be represented by a single character made of lines.

That rhymes.

Using paths I can quickly and efficiently recreate the first nine monk numbers in SVG for multiples of 10.

I simply take the multiples of one reuse the paths where they use elements, but flip them horizontally and transform them using scale and translate.

For multiples of a hundred, I flipped vertically.

And for multiples of 1000, I flipped both horizontally and vertically.

Now to recreate any number between one and 9,999.

I just need to reference each components by ID inside another SVG.

In this case, the number is 6,969.

Nice knives.

Should you need to calculate the length of your path.

You have a couple of options.

1.

Try to recall all the trigonometric functions you were taught at school, which would be futile because you weren't actually listening where you? Or 2.

Use the built-in get total length method of the SVG geometry element interface, which does all of this for you, thereby coddling you and destroying your capacity for independent thought.

The value returned is not in pixels, but user units, the units you use to draw the path relative to the view box.

One thing this is useful for is knowing how large one of two adjacent circles can be before it starts touching another circle.

Step one, or possibly step zero in a circle packing routine you might use to create a basic generative artwork.

Using the special commands.

C.

S.

Q.

T.

& A.

You can curve your path too.

Exacting curves is difficult, but there are some hacks.

For example, if I take the zigzag path and stick an S before my second point, I go from zigzager to squiggler in a second.

Each curve, the s command produces is a mirror of the previous curve.

Hence the total annihilation of pointy bits.

It should be no surprise then that the S stands for smooth as in operators, baby's bottoms and jazz.

Combine curbs with fills, and you can draw pretty much anything with a single path element.

For example, this picture of Bobby Hill from King of the Hill, as the goat deity Baphomet with the inscription 'that's my purse I don't know you' in gothic script.

Here is another single path.

This time illustrating a skull.

When you include a skull in your artwork, it is sometimes known as a momento mori .A convenient reminder that you will, at some point die.

If you're not an art lover, you can instead set up daily notifications with a calendar app.

The point is though, right? That by converting the d string into an array, mapping it and randomizing the integers.

I could use this image to create randomized glitchy artifacts, which is also fun to do.

Number 3 UTF-8 Encoded SVG Background Images.

If you're a pervert for HTTP requests, you can of course, grab a ropey JPEG image of a line and set it as a background image.

The more cultured among you might prefer to use a UTF eight encoded SVG data URL.

All we need is a one by one SVG with a filled wrecked element.

Drawing a line just requires repeating the SVG in one direction and setting the width of the line using background site.

We can even make it a dotted line by bleep with the view box.

Now the image is twice as wide as the wrecked inside it to leaving gaps.

Repeat this SVG in both directions and , we've got stripes.

If you were to include your UTF-8 encoded SVG data URL in the context of a CSS in JS tool, like styled components.

And if you were to include an inline style on that SVG.

Technically you would be writing.

CSS in SVG and CSS in JS which is three orders of galaxy brain higher than mere CSS in JS Number 4 Linear Gradients.

As versatile as this simple SVG is, one thing you can't easily do is rotate the background to make diagonal stripes, but you can achieve this effect with gradients, unlike with the data URLs, which are strings, we can now interpolate custom properties, giving us easy control over the stripe dimensions and colors.

Notes that line end is a kind of reactive property.

When you change either line, gap or line width, it's value is automatically updated.

JavaScript, doesn't do this reactive thing out of the box.

You need a library like React instead.

That's because unlike CSS, it is not really a grownup programming language.

Hashtag shade, hashtag tea hashtag hashtag hashtag number Number 5 Houdini Paint Worklets Harry Houdini was a famous magician and illusionist who tragically died when he cast a spell on his internal organs and made them disappear.

Jerry Houdini, no relation, was a famous technologist who created a number of methods for writing CSS using low level browser APIs.

Who tragically died when he simultaneously choked on a honeydew melon and spontaneously combusted.

A paint worklet turns any HTML element into your canvas, letting you draw on it like you would a canvas element.

Drawing a line across the middle of an element using a paint worklet is as simple as defining the widths and stroke color, finding the elements middle, then procedurally joining two points.

We moved to the middle of the left hand side, draw a line to the right-hand side, equal to size dot width.

Then apply the stroke.

If you use a Houdini paint worklet to draw a simple line like this, not only will melon averse, Jerry Houdini start turning rapidly in his grave, but I will write to you a very strongly worded letter that will read something like this.

Dear Mr.

Poopy pants, Mc Wrong Brain.

It has come to my attention that you have enlisted a paint worklet and with it, a JavaScript dependency in order to elicit a simple line artifact in your original design, when you could have deferred any number more efficient and well supported CSS techniques, you are a complete and utter parsnip.

Best wishes for the future.

Haydon.

P.s, bye bye.

Bye bye bye bye bye.

Bye bye.

Before you use Houdini, you have to ask yourself what can Houdini do that CSS can't do otherwise? One thing is having access to JavaScript's math objects, which means we can use math dot random to generate to randomized line paths.

What's more by registering the custom properties, amplitude and frequency.

I can control the parameters within which that randomization takes place.

Once these properties are incorporated into the worklets using the input properties method, you can start tweaking the values live in your browser's dev tools.

In practice I can use these scrawlings to stylize my lo-fi mock-ups lorem ipsum text, which not only looks kind of neat, but also saves having to explain to my client why the word cum, keeps appearing in their copy.

Number Six WebGL.

Arguably the pinnacle of over-engineering would be to create this simple line using WebGL, which even just to draw a line, still requires things like vertices and matrices, shader algorithms, and the necessity to commit shameful depraved acts like dynamically generating float 32 arrays and stuffing them inside buffers.

But whatever, this line exists in simulated 3D space now.

You just can't tell because you're looking at it directly side on In Summary Lines are rectangles that are really thin unless they are curved lines, in which case they are not rectangles at all but squigglys, weblers and doodiely dos.

You can make Browsers draw lines in all sorts of different ways.

Always choose the simplest and most efficient way to draw the line for the given purpose or use case.

The Baphomet does not in isolation, represent evil.

It is a composition of supposed opposites, good and evil, man and woman, light and dark.

Eliphas Levi the creator of this depiction of Baphomet refered to it as the sabbatic goat.

It did not invent Levi jeans.

Some lines are decorative and others are meaningful.

If your line means something, make sure that meaning is accessible to everyone, including those that hear, rather than see what the line represents.

The leading cause of death among males in the United Kingdom is choking on an unchewed mellon.

The second most common cause of death is spontaneous combustion.

And the leading cause of spontaneous combustion is informing someone CSS is a programming language.

Animation of a pair of <div> tags sliding toward each other from opposite ends of the screen, dramatic orchestral music plays over top

Image of a pair of briefs fashioned out of a spiderweb

Webbed
Briefs

Presents

HOW DO I
DRAW A LINE?

Animation of arrows appearing from all sides and pointing threateningly at the text

Web Directions Special

Text falls off the screen, animation of the channel being changed, signal being lost, and broadcast interrupted by a voiceover saying "Excuse me while I draw a line onto your computer screen

Groany grunty voiceover from the narrator as he struggles to draw a line on the screen. Animation of a line commensurately struggling

Anime of country music legend Johnny Cash appears saying "ok so fine, I've drawn a line. An animated ball follows the line to the beat of "I'd walk the line"

Animation of a line growing into a rectangle and then shrinking back to a line, with the letter A at the far left end, and point C at the far right end

Point B appears with an arrow pointing offscreen, indicating it is not visible in the demo. Point B interrupts the narrator to apologize

The line is now alone, and a bunch of chin scratchy emojis appear on behalf of our audience, wondering how our narrator drew his magnificent line? Narrator animates the line to become pixelated and flashing, before settling back into being a line, leaving the audience still wondering at the magic of his skills and asking how he did the animation. The narrator implements a drum roll and tells us the answer is….

NONE OF YOUR
F**KING BUSINESS

[Interjection from slide translator bot here - "Is there a generally accepted protocol for translating cusses in the midst of presentations?]

Japanamoji appears waving bye, credits roll

Blank screen. Cricket sounds

Helpful animation of a large cricket running across the screen for those in the cheap seats up the back

Star Wars inspired riff animation of the phrase "#1
THE HORIZONTAL
RULE" hurtling through the galaxy toward us

             NO

         ↙

< | >

A pair of less than/greater than elements attempt to wrap a vertical line tag but are told "No"

Arrows point out at 45 degree angles from each of the tag wrappers indicating that HTML wouldn't know if the "|" tag would represent the letter "l" for "line" or capital "I" for "I am a line"

Animated demo of the horizontal rule tag sprinkling letters all over the place, before disappearing and the animation returning to our lonely, naked horizontal line

Helpful Greek Philosopher popup sketch appears to tell us the horizontal rule is a semantic element representing a "thematic break" in our content. Scroll animation ensues demonstrating how the horizontal rule could be applied to separating the rambly bit of the recipe page from the actual recipe.

Animated demo of swapping out the horizontal rule for an H2 heading titled

The actual f**king recipe

[Slide translator bot again - Srsly, wash that mouth out with soap!]

Demo of the horizontal line rule being defined by an arrow labelled 'border', representing border property, followed by an arrow labelled shadow, and a bunch of floating excited animes exclaiming "Wow!" in superhero style speech bubbles.

Dramatic header and border surrounding the line proclaiming "THE CRAZY TRUTH THEY DON'T WANT YOU TO KNOW

That's it, I'm done! I'm off to have a lie down…enjoy the rest of Heydon's presentation.