Back

Tool Authoring for Web Sketchpad

Tool authoring is done in Desktop Sketchpad (GSP). To create a tool, add a page to your GSP document, giving the new tool page a special name that instructs the WebSketchpad exporter to convert the page into a tool.

By default, tools are document-wide: If the document has multiple pages, the tools for that document will be accessible from every page.

  • See WSP Tool Basics for a general description of how tools work in WSP.
  • Go to Create Three WSP Tools to learn how to create and use WSP tools.
  • See Tool Givens and Productions for details about the roles that various tool objects play.
  • See Tool Object Labels for detailed info about using labels to control the appearance and behavior of tool objects.
  • See WSP Preferences below to specify the pages on which each tool should appear.
  • WSP Tool Basics

    When the user taps a WSP tool button, toolplay begins: The entire tool construction appears, with the givens highlighted and the productions faded. One given object glows to indicate that it’s the currently active given ready either to be matched to a sketch object or to be located in the sketch. The user can match the active given in any of these ways:

    For tools with more than one given, you can choose to drag a different given instead of the currently active (glowing) given. Press and drag the given you want to match or plqce, and it immediately becomes the active given, allowing you to place it (by releasing in empty space) or to match it (by releasing on the desired object as described above).

    Create Three WSP Tools

    You can use GSP to create a web page with three WSP tools by following the directions below.

    This tool is similar to GSP’s Compass tool, constructing a circle based on two given points. (Unlike GSP, the WSP tool will show the full construction the moment you activate the tool, with the center point and radius point glowing in turn, to invite you to place or match them.)

    Your tool will measure an angle, serving the same function as GSP’s Measure | Angle command. (Unlike GSP, the WSP tool will show the full construction immediately, with the three given points glowing in turn to designate the initial direction, the vertex, and the final direction of the angle.)

    This tool will measure the circumference of a circle, operating in either of two ways. It can be used directly to measure the circumference of an existing circle, or it can be used parentally to construct a new circle and measure its circumference.

    This type of given object is called a constructible given because you can use it either to match an existing object or to construct a new object by constructing the required parents. (In this example, the required parents are a center point and a radius point. The parents of a constructible given are called given parents. The constructible given must be labeled constructible, but there's no need for its given parents to have special labels.)

    Tool Givens and Productions

    WSP tools perform constructions involving two kinds of objects: givens (the independent objects on which the construction depends) and productions (the constructed objects that are produced based on the givens).

    Specify the Roles of Given Objects

    WSP supports four different roles for given objects. For simple, assumed, and constructible givens, identify the role by assigning a label that starts with one of these three keywords. (The keyword is optional for givenParent objects, which are identified automatically based on their constructible child.)

    As you use a GSP page to define a WSP tool, note that the given objects of the resulting tool will include only independent objects whose role you have determined, either by providing the given object itself with a label that begins with one of the above keywords, or by identifying the given object’s only child as a constructible given. Any other constructions on the GSP page will not be included in the resulting WSP tool.

    Set the Sort Order of Given Objects

    When the user chooses a tool containing more than a single given, the tool’s given objects become active, one after the other. Sometimes (for instance, with a Line Tool), the order may not matter. In other cases (for instance, the Measure Angle Tool) it may be important; you might prefer the three given points to become active in a specific order: first the point-on-initial-side, then the point-vertex, and last the point-on-final-side. As the tool author, you can set this as the sort order by appending a number to each given object’s keyword, labeling the point-on-initial-side as given1, the point-vertex as given2, and the point-on-final-side as given3. [More details…]

    By default, givens are activated in the order in which they were originally constructed

    Set the Displayed Labels of Given Objects

    The keywords you use on the GSP source page for a tool do not appear when the WSP user eventually activates the tool. To specify a label that you want the tool user to see, append a colon to the given keyword (and sort-order number, if present), followed by the label you want to provide. See the section below on Labeling Tool Objects for more details on labeling the givens and productions of a tool.

    Tool Object Labels

    End of Currently Revised Content

    There are four categories of given objects, based on the roles they play. The first three of these are simple givens, assumed givens, constructible givens, and given parents.

    Tool Object Labels

    As you author a tool, you can use the label of each tool object to detrmine both the behavior and the label of that object during toolpLay.

    Determine the Behavior of Given Objects

    You can use the label of a given tool object to determine the behavior of that given object during toolplay. The following methods apply only to given tool objects::

    To be recognized, the tool object’s label must begin with the tool-role followed by the match-order (if any). If you also want to specify a label or any other signal (see below for Label Signals), you must insert a colon immediately after the match-order, or immediately after the tool role if there is no match-order.

    Assign Labels to Tool Objects

    When you create a tool, you can use the labels of the tool’s objects to control the labeling of the resulting objects in the sketch. The following methods apply to all tool objects:

    PICK UP FROM HERE...

    In the source sketch for a tool, you label objects in ways that determine how they will be used, labeled, and formatted during toolplay. Because the tool author seldom knows ahead of time what labels are already in use by the sketch into which the tool is played, tools don’t normally apply specific labels to either their givens or their productions. But you can add certain codes to the labels of tool objects to determine formatting options, visibility, and other features.

    Because it serves multiple functions, the label of a tool object can have multiple elements, ordered as follows:

    1. Given Role (required for given objects): This element specifies the type of a given object of a tool. Possible values are "given", "constructible", and "assumed."
    2. Match Order (optional, applies to given objects only): This element specifies the order in which given objects become active during toolplay. Values are integers.
    3. Colon (optional, applies to given objects only): A colon is required to separate a given object’s role (and match order if present) from any subsequent elements, and can be omitted if there are no subsequent elements.
    4. Label (optional): >The label of this object in the tool’s source sketch. (This label isn’t normally used in the target sketch, where new unique labels are generated during toolplay. If your tool needs to define the label to be used in the target sketch, use the _apply_ code described below.)
    5. Label Codes (optional): You can use these codes to determine the way an object’s label is formatted and displayed. Each code begins with a space to separate it from any previous label element and is surrounded by underscores. Here are the codes you can use.
      • Visibility: The _hide_ and _show_ codes determine whether the label in the target sketch will be hidden or shown. Without a visibility code, the target sketch object will display a label if the source sketch object has a label, and will not display a label if the source object is unlabeled.
      • Format: The format codes determine the formatting of transformed images. See Specifying Label Formats below for details.
      • Label Use: The _apply_ code applies this object’s source-sketch label to the constructed object in the target sketch.

    Label a Given Object

    1. Identify:Each given object of your tool must be identified by a label that begins with given, constructible, or assumed. There’s no need to identify the parents of a constructible given; they are automatically identified as given objects.
    2. Set the Matching Order: Once the user activates a tool, each given object of the tool glows when it’s ready to be matched. The default matching order of the givens is the order in which they were created in the original sketch, but you can explicitly set the matching order by appending a number to the label. Thus parameter given1 will be matched before line constructible2, and both will normally be matched before point given3. (If for some reason you wanted a segment to be constructible but to have its given endpoints become the active givens before the segment, you could label the endpoints given1 and given2, and the segment constructible3. More typically you would just label the segment constructible and not bother to label the endpoints.)
    3. If a given uses a specific label or any of the codes below, append a colon immediately after the matching order (or after the given/constructible/assumed if there is no matching order). At this point a label might show “given3:” or “constructible:”

    Specify the Object Label

    For an assumed given you must indicate the label of the sketch object to which it will be matched; for instance, “assumed: Center” to automatically match this assumed given to a sketch object labeled “Center.”

    You might want to use a label to help you keep track of the roles of particular objects in the source sketch. If you specify the label of a given, the label must follow the colon. If you specify the label of a production, the label should start at the very beginning.

    Examples: “assumed: Center”, “given3: A”, “P”

    Note that only the “assumed: Center” example represents an actual label in the sketch. When the tool with point “P” as one of its productions is used in a sketch, the point it creates will be unlabeled. (But see the _apply_ code described below.

    Format Object Labels

    You can label any tool object in ways that affect the visibility and format of the label. Below are the codes you can use. Note that each code begins and ends with an underscore, and that one code must be separated from another by a space.

    Labels of Given Objects

    The label of any given object starts with given or constructibleGiven optionally followed by a number defining its sort order, optionally followed by a colon (“:”) and its desired user-facing label. Thus a given object labeled given3: Center is a simple given, has a sort order of 3, and will appear to the user with the label “Center”. To provide this label without making it visible during toolplay, hide the entire label. If you hide the label given3: Center, the label will not appear during toolplay, but if the user reveals it later it will appear as “Center.”

    Specifying Label Formats

    You can specify the format to use in labeling certain objects (such as transformed objects) created by tools. To apply a specific format in the source GSP sketch, label the object this way: "nameOrigin: format", replacing format> with one of the formats listed below. (In both GSP and WSP, labels can include subscripts by enclosing the subscript in square brackets.)

    Matching a Given Parameter

    You can match a parameter to any compatible value in the sketch, where “compatible” means having the same kind of units: distance, angle, or scalar (without units). A parameter or measurement in radians can be interpreted either as an angle or as a scalar (in its sense as the ratio between arc length and diameter), so radian values are considered to be compatible with both angle values and scalar values.

    Matching a parameter to “any compatible value” means that the user of the sketch can match not only another parameter, a measurement, or a calculation, but can also match any text object in the sketch that contains or refers to a compatible value. This includes both pegged text—text attached to a point—and composite text—text that includes values and/or labels of other objects in the sketch. (Composite text is sometimes referred to as “hot text.”) In such cases, the pegged text or composite text must have exactly one value-containing ancestor. It doesn’t matter whether the actual value or only the label of the value-containing ancestor appears in the pegged or composite text; in either case the given parameter will be matched to that ancestor’s value.

    Order of Given Objects

    When creating tools, it’s often desirable to specify the order in which the given objects become active. This order is determined as follows:

    1. Matching Order is an integer appended to the label “given” or “constructibleGiven” that determines the order in which the tool’s given objects become active. Thus “given2” becomes active after “given1” and before “given10”. Avoid using the same number for multiple objects; if a tool contains both “given3” and “constructibleGiven3” the resulting order may be unpredictable.
    2. Label following a colon (“:”). Given objects that don’t specify a sort order (for instance, given: A and given: B) are sorted in alphanumeric order. The object labeled given: A9 precedes the object labeled given10.
    3. Type of given. If an object labeled constructibleGiven has its three parents labeled given (with no sort order specified) the constructibleGiven object precedes its parents.

    Below are some examples of these rules in action.

    One Given LabelAnother Given LabelOrder of Active GivensNote
    given11given9given9, then given11
    given2: Agiven1: Bgiven1: B, then given2: AExplicit sort order takes precedence
    given: Bgiven: Agiven: A, then given: B
    givengivenThe first, then the second
    given3given3?Undetermined; don’t duplicate sort values
    givengiven3given3, then given Explicit sort order takes precedence
    given3: ygiven3: xgiven3: x, then given3: y Bad form; don’t duplicate sort values
    givengiven: xgiven: x, then given Label takes precedence over empty
    given: 1given1given1, then given: 1 Sort order takes precedence over label

    Constructible Givens

    Simple givens have no parents; they are free points, parameters, or functions. Point givens can be matched only to points; parameter givens can be matched only to values (including parameters), and functions can be matched only to functions. But it’s often desirable to have a tool with givens that can be matched to other objects such as segments, lines, rays, circles, or polygons. Constructible givens make this possible.

    A constructible given is a segment, line, ray, circle, or polygon constructed from given points, and with its own label beginning with constructibleGiven. The user can drag or tap to match such an object to a similar existing sketch object, or to locate the object in the sketch; alternatively the user can drag the constructible given object’s parent points to match or locate the parent points in the sketch.

    With certain restrictions (described below), a constructible-given polygon can be matched to an existing polygon with a different number of vertices and sides. Thus you can create a polygon area tool that allows the user to measure the area of any polygon.

    As you drag a constructible given to an existing sketch object, a brief animation occurs, animating the given object’s parent points to the corresponding locations for the existing objects.

    This complex of objects (the constructible given and its parents) is always in one of two states:

    1. Composed: the constructibleGiven is active and its given parents are inactive. The constructible given can be matched by tapping on or dragging to an object of the same kind.
    2. Decomposed: the constructibleGiven is inactive and its given parents are active. These given points can be matched as usual by tapping or dragging.

    When a complex is in a composed state (state 1) and the user drags a parent of the constructibleGiven, we say that the constructibleGiven is “decomposed” and the complex switches to state 2. If the constructibleGiven was matched to an existing sketch object, that match is dissolved.

    When a complex is in a decomposed state (state 2) and the user drags the constructibleGiven, we say that the constructibleGiven is “recomposed” and the complex switches to state 1. Any matches between its parents and existing sketch objects are dissolved.

    Below are some examples of whether a complex of constructibleGiven and its given parents start out in the composed or decomposed state, described in reference to a triangle. The triangle is the constructibleGiven, and the vertices are its given parents.

    Triangle LabelVertex LabelsInitial StateNote
    constructibleGivengiven, given, givenComposedConstructible takes precedence
    constructibleGiven1given2, given3, given4Composed
    constructibleGivengiven2, given3, given4Decomposed2 precedes unnumbered
    constructibleGiven4given1, given2, given3Decomposed
    constructibleGiven2given1, given3, given4DecomposedBad form! But 1 precedes 2
    constructibleGiven: Pgiven: A, given: B, given: CDecomposedA, B, and C precede P
    constructibleGiven1: Pgiven: A, given: B, given: CComposedThe 1 takes precedence
    constructibleGiven2: Pgiven1: A, given: B, given: CDecomposedBad form!
    constructibleGiven1: Pgiven2: A, given: B, given: CComposed1 precedes 2
    constructibleGiven1given1: A, given2: B, given3: CUndeterminedDon’t duplicate sort values!

    Restrictions on Constructible Givens

    [This section is rather technical in nature.] A constructible given can always match any construction defined the same way. For instance, a triangle constructible given can always match any triangle defined by three points; a segment constructible given can always match any straight object defined by two points (though in this latter case, a tool that includes a measurement of the segment’s length would not give meaningful results if the matched object is a line or a ray).

    It’s also possible, with certain restrictions, to match a constructible given to a compatible object defined differently. For instance, a constructible-given triangle (defined by 3 points) can be matched to the transformed image of a triangle only if the given parents of the constructible given triangle don’t define any productions of their own, except for the constructible given triangle itself. If the tool’s given parents define other objects (for instance, the segments that form the three sides of the triangle), those objects cannot be defined based on the transformed image of a triangle, because that transformed image doesn’t have any actual vertex points that could be used to define the sides.

    As a result, the rule is that a constructible given whose parents have no children other than the constructible given itself can be matched to any compatible sketch object (straight object to straight object, triangle to triangle, triangle to quadrilateral, arc to arc, etc.). However, if the constructible given’s parents do have other children (such as the side segments of a triangle), the constructible given can be matched only to a sketch object defined in the same way (such as a triangle defined by three points, but not a triangle defined as the reflected image of another triangle).

    Sequential Snapping

    The term sequential snapping refers to the fact that during toolplay there’s always a single active given object, an object that glows to indicate that the user can either match or locate it by tapping the desired objects or location in the sketch. This is the default mode for toolplay. In the alternative mode, with sequential snapping off, all given objects glow, and the only way for the user to locate or match a given object is to drag it to the desired location or object. This mode is generally less useful, as it’s more user-friendly to give the user the choice of either tapping or dragging to match a given object. To turn off sequential snapping, add a “WSP Preferences” page to your sketch and insert a caption with this text: “sequentialSnapping = false”.

    Per-Page Tools

    You can specify which tools should appear on each page of a websketch. For instance, if your GSP document has three tool pages named WSP Tool: Point, WSP Tool: Segment, and WSP Tool: Circle, you could make the Point tool appear on all pages, make the Segment tool appear on both pages 2 and 3, and make the Circle tool appear only on page 3. To do so, create a WSP Preferences page, and enter the following captions:

    Because the Point tool is not listed, it will appear on all pages of the websketch.

    New Parameter, Calculation, and Function Tools

    You can author a tool that allows the user to create and edit a new Parameter, Calculation, or Function. If your tools has only a single such given, then when that tool is played by the user, the numberpad or calculator will automatically come up. A given calculation of 1+1 is automatically replaced by an empty calculation, and will appear in the sketch in edit mode.

    Auto-Play Tools

    An auto-play tool has only assumed givens, and no other givens that can be matched. When you tap such a tool, it completes its constructions and finishes without any further interaction. [Unfortunately at the current time the Exporter doesn’t support tools without simple givens, so there is a temporary work-around in place to make it possible for you to author such a tool. In desktop Sketchpad, create the auto-play tool with all its assumed given objects, and then add to your sketch a single point labeled "given: delete". This will satisfy the current exporter, and the "given: delete" point will automatically be deleted from your tool when your sketch is loaded.]

    Image Icon

    To identify your tool in the WSP toolbox using an image rather than the tool name, add a free picture to the sketch. If there are multiple free pictures in the sketch, the first one is used, and the others are ignored.

    Tool Look

    There are three skins that determine the appearance of the toolbox: classic, new, or compact. Use Author Preferences to set the desired skin, by placing a caption on the WSP Preferences page. The caption should be of the form "Tool Look = " followed by the name of one of the three skins.

    Incorporating Tool Help in WSP-based Student Activities

    There are two pathways to enabling Tool Help for tools in websketches that you create. Both involve using the Web Sketchpad Tool Library, because all tools in the library’s Basic collection are help-enabled.

    1. Go to the Tool Library and use it to create the websketch. On some pages you may want users to manipulate or add to an initial construction that you create, and you may want to leave some pages empty so that students can create their own constructions. To create an initial construction on a page, you can use any of the tools in the Tool Library. When the initial constructions are finished, drag to the Trash any tools that should not be available to users. If you want users to have different tools available on different pages, use the check boxes in the tool list to indicate which tools will be available on each page.
    2. Create your original sketch using The Geometer’s Sketchpad (GSP) for Mac or Windows. (There is no need to create "WSP Tool" pages in your sketch, unless you decide to create specialized tools not available in the Tool Library.) Use the WSP Exporter to export your sketch in .json form, and upload it into the Tool Library. Use the Tool Library to add whatever tools users will need, and use the checkboxes in the tool list to indicate which tools will be available on each page.

    Once your sketch is finished in the Tool Library, download it in .json format and incorporate it into your webpage.

    Examples