Logo Library Help

Logo Library Introduction and Setup
Logo Default Settings
Pen and Colour Commands
Draw and Move Commands
Turtle and Position Commands
Save Screen Command
Programming Commands
Logo Colours
Speed up your Programs
Using Fill

Logo Library Introduction and Setup

 LogoLib is a library to add Logo commands to RFO-BASIC!
All the commands are documented below and there is a Quick Reference Guide.

There are four demos included. 'LogoDemo1.bas, LogoDemo2.bas, LogoShortDemo1.bas'
and LogoShortDemo.2.bas. Each Logo command has a short cut, Logo_Forward(100) is the same as FD(100)
In the demos I haven't used any short cut commands, so that the listings are easier to read.

LogoShortDemo1.bas is also listed below.

 
LogoLib is at:

For LogoLib to work correctly setup your opening code as shown, in the short demo, below. NOTE where the LogoLib.bas is placed.

Rem Logo Library Short Demo

di_height = 1120 % set to my Device
di_width = 720

gr.open 255,0,0,0 % Black
gr.orientation 1
pause 1000
WakeLock 3

gr.screen screenWidth,screenHeight
scale_x=screenWidth/di_width
scale_y=screenHeight/di_height
gr.scale scale_x,scale_y

!------------------------------------------------
! Setup screen for drawing
!-------------------------------------------------
gr.bitmap.create screen, di_width, di_height
gr.bitmap.draw nn, screen, 0, 0
include LogoLib.bas % *** IMPORTENT include 'LogoLib.bas' here ***
gr.bitmap.drawinto.start screen
!----------------------------------

gosub Functions % Let Basic see the Functions before they are called

!------------------------------------------------
! Draw a box, then change the angle (360 / 10). Do this 10 times
!-------------------------------------------------
for x = 1 to 10
    call Box(200)
    Logo_LeftTurn(360 / 10)
next
do : until 0

onBackKey:

end "End of LogoLib short demo"

Functions:

fn.def Box(size)
    for x = 1 to 4
        logo_Forward(size)
        Logo_RightTurn(90)
    next
fn.end

return

Back

Logo Default Settings

Logo starts off from the centre of the screen.
The angle is set to 0 pointing straight up.
Pen is down.
Pen size is 2
The turtle stays as is (if the turtle is down he stays down, if he's up he stays up)
Pen colour is white.
Background is black.
Rendering is on.

Back

Pen and Colour Commands

Logo_Pen() or PU()
Lifts the "pen" from the screen so that moving the turtle doesn't draw a line.
Example: PU()

Logo_PenDown() or PD()
Puts the pen down so that moving the turtle draws a line
Example: PD()

Logo_SetPenSize(n) or PS(n)
Sets the width of the pen to n pixels.
Example: Logo_SetPenSize(5)

Logo_SetPenColour(c) or SC(c)
Sets the pen colour to one of the 18 Logo colours.
Example: Logo_SetPenColour(5) Set colour to Red

Logo_SetPC(Alpha, Red, Green, Blue, Style) or PC(Alpha, Red, Green, Blue, Style). (All numbers must be entered).
Sets the pen colour to the appropriate RGB (Alpha, Red, Green, Blue) values,
where Alpha, Red, Green, Blue are numbers that range from 0 to 255. Style as a number range between 0 and 2
Alpha sets the transparency.
Example: Logo_SetPC(255,255 0 0, 1) (Sets pen colour to red)

Logo_SetBG(Alpha, Red, Green, Blue, Style) or BG(Alpha, Red, Green, Blue, Style).(All number must be entered).
Clears the screen to the colour set by (Alpha, Red, Green, Blue, Style) values,
where Alpha, Red, Green, Blue are numbers that range from 0 to 255. Style as a number range between 0 and 2. Alpha sets the transparency.
Logo will be set to it’s default settings, with the exception of the pen colour, and the turtle, they will stay the same as they are.
Example: Logo_SetBG(255,0 0 255, 1) (Clears screen to Blue)

Logo_SetBgColour(c) or BC(c)
Clears the screen to one of the 18 Logo colours and reset Logo to its default settings,
with the exception of the pen colour, and the turtle, they will stay the same as they are.
Example: Logo_SetBgColour(14) Clears the screen to the colour Purple.

Logo_ClearScreen() or CS()
Clears the screen and reset Logo to its default settings
Example: Logo_ClearScreen()

Logo_Fill() or FL()
Floods the area bounded by lines with whatever colour was specified in the Logo_SetPenColour(c) or Logo_SetPC(Alpha, Red, Green, Blue, Style) command.
Example: FL()

Back

Draw and Move Commands

Logo_Forward(x) or FD(x)
Draw forward x pixels
Example: FD(100)

Logo_Back(x) or BK(x)
Draw Backward x pixels
Example: BK(100)

Logo_MoveForward(x) or MF(x)
Move forward x pixels (Does not draw)
Example: MF(100)

Logo_MoveBack(x) or MB(x)
Move back x pixels (Does not draw)
Example: MB(100)

Logo_Dot() or DT()
Puts a dot on the screen at the current position in the size of the current pen size.
Example: Logo_Dot()

Logo_Circle(radius) or CL(radius)
Draws a circle on the screen at the current position in the size of radius
Example: Logo_Circle(100)

Logo_LeftTurn(x) or LT(x)
Rotate the turtle x degrees left
Example: LT(45)

Logo_RightTurn(x) or RT(x)
Rotate the turtle x degrees right.
Example: RT(45)

Back

Turtle and Position Commands

Logo_TurtleHide() or TH()
Hides the turtle. (arrow)
Example: Logo_TurtleHide()

Logo_TurtleShow() or TS()
Shows the turtle. (arrow)
Example: TS()

Logo_Jump(x, y) or JP(x, y)
Jumps to a position on screen
If the pen is down a line will be drawn to x and y.
If the pen is up, no line will be drawn.
Example: Logo_Jump(200, 300) Sets the turtle x = 200 and y = 300

Logo_ReSetAngle() or RA()
Resets the angle to 0, pointing straight up
Example: Logo_ReSetAngle()

Logo_GetPosX() or GX()
Returns x position of the turtle.
Example: x = Logo_GetPosX()

Logo_GetPosY() or GY()
Returns y position of the turtle.
Example: y = Logo_GetPosY()

Logo_SetPosX(x) or SX(x)
Sets the absolute x position of the turtle.
If the pen is down a line will be drawn to x.
If the pen is up, no line will be drawn.
Example:Logo_SetPosX(250) Sets the turtle x = 250.

Logo_SetPosY(x) or SY(y)
Sets the absolute y position of the turtle.
If the pen is down a line will be drawn to y.
If the pen is up, no line will be drawn.
Example: Logo_SetPosY(350) Sets the turtle y = 350.

Logo_TurtleHome() or TM()
Sends the turtle to the centre of the screen,
and resets the angle to 0, pointing straight up
If the pen is down a line will be drawn to the center of the screen,
If the pen is up, no line will be drawn.
Exampl: Logo_TurtleHome()

Logo_TurtleReSet() or TR()
To speed up drawing, calls to Logo_LeftTurn(n), Logo_RightTurn(n),
Logo_MoveBack(n) and Logo_MoveForward(n), does not move the turtle (arrow).

This means that if your last command to the LogoLib where any of the above,
the turtle will still be in the place it was before the last commands.
You can use Logo_TurtleReset() to place the turtle in the right position.
Exampl: Logo_TurtleReset()

Back

Save Screen Command

Logo_SaveScreen() or SS()
Saves the screen to a file, in folder "LogoDrawings".
The file will have a unique name, chosen by using the time function and as the "png" extension.
Example: Logo_SaveScreen()

Back

Programming commands

Logo_Wait(n) or WT(n)
Pause for the specified amount of time, measured in 1/60 seconds,
before executing the next command. So, if n is 60, the program will pause for 1 second.
Example: Logo_Wait(30) (half a second)
   
Logo_RenderOff() or RF()
Turns off graphic rendering.
Drawings will be done much faster, but you will not see anything until you use Logo_Render() or RD()
Example: Logo_RenderOF()

Logo_RenderOn() or RN()
Turns on graphic rendering.
See your drawing as it is drawn.
Example: RN()

Logo_Render() or RD()
Renders drawings to screen.
Use after Logo_RenderOff() when you want to show your drawings.
Example: Logo_Render()

Back

Logo Colours

The Logo colours are:
0 = Black, 1 = Grey, 2 = Silver, 3 = White, 4 = Maroon, 5 = Red, 6 = Olive, 7 = Yellow,
8 = Green, 9 = Lime, 10 = Teal, 11 = Aqua, 12 = Navy, 13 = Blue, 14 = Purple,
15 = Fuchsia, 16 = Brown, 17 = Gold.

Black: 0
Grey: 1 
Silver: 2
White: 3
Maroon: 4
Red: 5
Olive: 6
Yellow: 7
Green: 8
Lime: 9
Teal: 10
Aqua: 11
Navy: 12
Blue: 13
Purple: 14
Fuchsia: 15
Brown: 16
Gold: 17

 

 

 

 

 

 

 

 

 

 

 

 

Back

Speed up your programs

To speed up your drawing turn off rendering with Logo_RenderOff() and
hide the turtle with Logo_TurtleHide()
To see your drawing in steps use Logo_Render() every so often, say at the end
of a for next loop. There are many examples of using this method in the demos.
To turn rendering back on use Logo_RenderOn().
To show the turtle use Logo_TurtleShow().

Back

Using Fill

When using the Logo_Fill() command, if you are not sure your calculations are correct, then use Logo_Circle(5) to show a dot where the fill will start. If it’s not in the right place then recalculate. When you’ve got it right, comment out Logo_Circle(n) and put in the Logo_Fill() command.

There is an example of using this method in LogoShortDemo2.bas

The gr.set.AntiAlias command is set to on by default and the drawing of lines is smoother with it on, however Logo_Fill() fills an area better if it has been drawn with gr.set.AntiAlias 0 (off). It is up to you to decide which to use. To turn gr.set.AntiAlias on, use gr.set.AntiAlias 1 and off with  gr.set.AntiAlias 0.

Back