Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Drawing lines

2009-11-06

The basic syntax for drawing lines is this: Use the Line instruction, pass a start coordinate (X1 and Y1) and an end coordinate (X2 and Y2) and a color. This example draws a line across the picture:

//Set image size and background color.
Clear 400x300 #ffffff

//Simple line.
Line #000000 X1:0 Y1:0 X2:400 Y2:300

The coordinates can be given in an alternative nameless format. This is useful when drawing multiple lines with one single line instruction. This code draws a red U-shape.

//Set image size and background color.
Clear 400x300 #ffffff

//Polyline
Line #ff0000 (10,10) (10,290) (390,290) (390,10)

To close this shape,  you can add the (10,10) coordinate to the end of this line, telling Monkeybone to draw a line from (390,10) to the startpoint at (10,10), or you can add the AutoClose argument. This code draws a red rectangle:

//Set image size and background color.
Clear 400x300 #ffffff

//Polyline
Line #ff0000 (10,10) (10,290) (390,290) (390,10) AutoClose

To draw a filled rectangle instead of a rectangle contour, use the Filled argument instead of the AutoClose argument. This code draws a yellow box with black outline:

//Set image size and background color.
Clear 400x300 #ffffff

//Polyline
Line #ffff00 (10,10) (10,290) (390,290) (390,10) Filled
Line #000000 (10,10) (10,290) (390,290) (390,10) AutoClose

Categories: General

Tags: Monkeybone

Leave a Reply

Your email address will not be published. Required fields are marked *



En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!

Om...

Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   linktr.ee/hesselbom   |   winsoft.se   |   80tal.se   |   Filmtips