B4J Question B4XTurtle draw to Canvas ? [SOLVED]

Magma

Expert
Licensed User
Longtime User
Hi there,

First of all i know that b4xturtle is for learning but actually can be a nice tool for vectors drawing :)

i want to ask where the b4turtle draws - on a canvas, direct on form ?

is it possible to draw directly at a canvas, bitmapcreator or reverse that grab the result of turtle as a picture - someway?

I can get a screenshot with commands - i know how - but i ask - if there is a special command to do that or somehow to draw on canvas ?
 

William Lancee

Well-Known Member
Licensed User
Longtime User
Turtle draws on its own internal set of canvases. When the turtle is done, the image is available from Turtle.TurtleLayer

Note: In B4Xpages it is also possible to load the Turtle layout to any page and panel in your app, so that you can see its action as well as the final product.

B4X:
Sub Turtle_Done
    Dim ivx As B4XView = Turtle.TurtleLayer
    Dim bm As BitmapCreator
    bm.Initialize(ivx.width, ivx.height)
    bm.CopyPixelsFromBitmap(ivx.GetBitmap)
  
    'the pixels are there
    For i = 0 To ivx.width - 1
        For j = 0 To ivx.height - 1
            Dim c As Int = bm.GetColor(i, j)
            If c<>0 Then Log(c)
        Next
    Next
End Sub
 
Last edited:
Upvote 0
Top