Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.
2009-12-29
Regions are used to define a path or an area for later use. The Region instruction takes any number of coordinates (3 or more), and stores them in memory. The region can then be used for drawing. The following example is done in Notepad. I have created a text-file, changed the file ending from .txt to .mob. In the file, I have added these three lines of text:
Clear #ffffff 70x70 Region (10,10) (60,10) (60,60) (10,60) Line Region #ff00ff
When loaded in the Monkeybone viewer, this is the result:
When regions are created using the MonkeyboneWriter class, they are much easier to manipulate. This example defines a shape, writes it, manipulates it, and writes it again.
Module Module1 Sub Main() 'Create a Monkeybone stream. Using W As New Monkeybone.MonkeyboneWriter("C:\regions.mob", 130, 130, System.Drawing.Color.Black) 'Define a region. Dim R As New Monkeybone.Instructions.Region() R.AddPoint(10, 110) R.AddPoint(60, 10) R.AddPoint(110, 110) 'Write the region to the stream. W.WriteLine(R) 'Write an instruction to draw the region outline in green. Dim L As New Monkeybone.Instructions.Line() L.Color = Drawing.Color.Lime L.UseRegion = True W.WriteLine(L) 'Modify the region (move it 10 pixels to the left and 10 pixels down) and write it again. R.Move(10, 10) W.WriteLine(R) 'Write an instruction to draw the region outline in yellow. L.Color = Drawing.Color.Yellow W.Write(L) 'Flush and close the stream. W.Flush() W.Close() End Using End Sub End Module
The code produces the following mob file:
Clear #000000 130x130 Region (10,110) (60,10) (110,110) Line Region #00FF00 Region (20,120) (70,20) (120,120) Line Region #FFFF00
This is the result when it is loaded into the Monkeybone viewer:
Categories: General
Tags: Monkeybone
Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!
Leave a Reply