Tag Archives: line

Extruding along a curve

This video explains how to extrude a circle along a curve and then animate an extrusion. When we ‘extrude’ a 2D shape such as a circle, it means that we will push that shape out. By using a curved line, we can push the shape out so that it follows the line.

An extruded circle along a curve
An extruded circle along a curve

Watch the video below to see how to do this in Maya.

Tip: When selecting the circle and CV curve, select the circle first and then hold down Shift key to select the CV curve. Make sure you select the curve last.

Styling lines on the canvas

In the previous tutorial we looked at how to draw lines on the canvas. In this tutorial we will style lines on the canvas by changing the following properties:

  • colour
  • width
  • line cap (shape on the ends of a line) for a line on the canvas

The line that we will create will look like this:

Screen Shot 2015-05-08 at 6.58.05 pm

Watch the video below and then scroll down the page to see the sample code.

Here is the sample code:

<!DOCTYPE html>
 <title>Styling lines on the canvas</title>
 border: 1px solid #000000;
 function draw(){
 var ctx = document.getElementById("myCanvas").getContext("2d");
 ctx.lineWidth=20; // specify the width of the line
 ctx.lineCap="round"; // lineCap options are square, round, butt
 ctx.moveTo(50,50); // x,y positions - where the line begins
 ctx.lineTo(250,250); // x,y positions - where the line ends
 ctx.strokeStyle="#0000FF"; // specify the colour of the line
 ctx.stroke(); // draw the line
 window.onload=draw; // run the draw function when the page loads
 <canvas id="myCanvas" width="300" height="300">

Next tutorial: Joining lines on the canvas

CSS Font properties

In this tutorial we will look at how to use CSS font properties in an external style sheet. We will look at how to change the font-weight (eg. normal or bold), font-style (eg. normal or italic), font-size (eg. 12pt, 10px, 1em or 100%), font-family (eg. Arial or Tahoma), font-variant (eg. normal or small-caps), and the line-height. We will also look at how to add comments to our CSS.

There are two ways that we can change the values for different font properties:

  • On multiple lines
  • On one line

When we specify the font properties over multiple lines, it will look like this:

Font properties on individual lines in CSS file.
Font properties on individual lines in CSS file.

When we specify the font properties on one line it looks like this (note that there are required property values and some order to the values – watch the video to find out more):

Font property values on one line in a CSS file.
Font property values on one line in a CSS file.

Watch the video below and then scroll down to find out more about web-friendly fonts and to see the sample code.

The sample code below is for a CSS file with the font property values specified on multiple lines:

 font-family: Georgia;
 font-weight: bold;
 font-style: italic;
 font-size: 1em;

Here is the code for a CSS file with the font property values specified on one line – much neater, right? A line of comments has been added to show the order of the values.

 font: italic bold 1em Georgia; /* font-style, font-weight, font-size, font-family */

And here is the code for the HTML file that references the stylesheet.css file:

<!DOCTYPE html>
 <title>CSS font properties</title>
 <meta charset="utf-8"/>
 <link rel="stylesheet" href="stylesheet.css" type="text/css"/>
 <h1>This is a heading.</h1>
 <h2>This is a smaller heading</h2>
 <p>This is a paragraph</p>
 <p>This is a paragraph</p>

Font-size units:

It is important to have an understanding of the four different units for the font-size property. The four different units are:

  • em – the em is scalable and is used in web documents. An em is equal to the current font-size of the web document. For example, if the document size is 12pt, then 1em will be equal to 12pt. 2em would therefore be equal to 24pt. You can also use decimals eg. 1.5 em. Ems are popular on the web because they are mobile-friendly and are used in ‘responsive’ web design.
  • px – Pixels (px) are fixed-size units that are designed for media that will be read on a screen. 1 pixel is the equivalent of one dot on the computer screen. The downside of pixels is that they do not scale to fit mobile devices or screen readers for the visually impaired.
  • pt – Points (pt) are usually used for print media and are also fixed-size units that cannot scale to fit mobile devices. 1 pt = 1/72 of an inch.
  • % – Percent (%) unit is like the em unit as it is also scalable. Eg. the current font size of 12pt = 100%.

In summary, the em and % units are really what you want to use for the font-size property, especially if you wish to develop mobile-friendly or responsive websites.  Stay away from px and pt as they do not scale for mobile devices. Try getting used to using em and % instead. Find out more information on font-size units here.

And lastly, here is an overview of some of the web-safe fonts that you can include in CSS:

Serif fonts:

  • Georgia, serif
  • Palatino Linotype
  • Book Antiqua
  • Palatino, serif
  • Times New Roman

Sans-serif fonts:

  • Arial
  • Helvetica, sans-serif
  • Arial Black
  • Gadget sans-serif
  • Comic Sans MS
  • Impact
  • Charcoal
  • Lucida Sans Unicode
  • Tahoma
  • Geneva
  • Trebuchet MS
  • Verdana

Monospace fonts:

  • Courier New
  • Courier, monospace
  • Lucida Console
  • Monaco, monospace

Text shadows

Another effect you might like to use (not mentioned in the video) is a text shadow using the text-shadow property. The text-shadow property has four different attributes separated by spaces.

The first attribute is the horizontal shadow (how much the shadow is to the left or right of the text). A positive number (eg. 3px) will display a shadow to the right of the text and a negative number (eg. -3px) will display a shadow to the left.

The second attribute is the vertical shadow (how much the shadow is above or below the text – this can also be a positive or negative number).

The third attribute is the blur radius (how much blur you want for the shadow). And the last attribute is the colour for the shadow.

Here is some sample CSS code for a text-shadow with a horizontal shadow of 3px, vertical shadow of 3px, blur radius and 5 and the colour blue for the shadow.

text-shadow: 3px 3px 5px blue;

And this is what it would look like: