drawLine

Built-ins

Canonical ID: graphics.line. Nederlands: tekenLijn.

Draws a line between two logical-pixel endpoints using a positive width. Coordinates may be outside the scene; the renderer clips visible work. It is an immediate 2D command, independent of turtle position and heading. Drawing a line does not move the turtle.

Signature

drawLine(x1, y1, x2, y2, width, color)

Arguments

Parameter Type Requirement
x1 Number Finite starting x.
y1 Number Finite starting y.
x2 Number Finite ending x.
y2 Number Finite ending y.
width Number Finite and greater than 0.
color Text Nonempty; use portable English/Dutch names or #RGB/#RRGGBB.

Return value

None.

Example

# language: en
clearCanvas("white")
drawLine(80, 280, 560, 80, 6, "purple")

A diagonal purple line.

Notes and common mistakes

Use the function name for your source language. Its canonical ID is a shared documentation label; you do not type that ID as a call. Giving your own variable or function the same name can hide the built-in. Supply the documented arguments and value types. Pliro reports mismatches when checking can detect them, or when the call runs.

A host is the app or environment running your program. To see a drawing, it needs a renderer, the part that draws on screen. The command-line command pliro run shows text but does not draw these graphics. The host support table explains which effects work in the IDE, browser, native app, and phone preview. A native build reports an unsupported capability instead of leaving it out.

2D uses a 640 × 360 scene with a top-left origin, +X right and +Y down. Both English and Dutch portable color names work in either syntax locale, as do #RGB and #RRGGBB. Other nonempty 2D color text is host-dependent.

clearCanvas · rectangle · circle · drawText · Programming guides · Host support · Calls and arguments