Changeable pen

neilnapier

Active Member
Licensed User
Longtime User
I have been working on a Burning Sand PPPC Program (that is on the program forum) and I am stuck with quite a few problems. Could anyone help me to figure out how to sort this peice of coding:

B4X:
Sub BurningSand_MouseMove (x,y)
If circle.Enabled = true Then
If blnDRAG = 1 Then
      If ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
         BurningSand.FCircle(x, y, PenSize, DrawColor, F) 'Filled circle
         
         Else if Circle2.Enabled = true Then
      If   blnDRAG = 1 Then
      If ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
         BurningSand.ForeLayer = True
         BurningSand.FCircle(x, y, PenSize, DrawColor) ' circle
         End if
         End if
         End if
         End if
         End if
End Sub

The problem is I am trying to get a choice of either having a filled circle or a normal circle as a pen, using buttons to choose. However i can't figure out how to do it.

Could someone please help me,

neilnapier
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You should set the ForeLayer property only once (you could do it in Sub App_Start).
I think that you've confused the If...End If blocks.
B4X:
Sub BurningSand_MouseMove (x,y)
    If circle.Enabled = true Then
        If blnDRAG = 1 AND ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
            BurningSand.FCircle(x, y, PenSize, DrawColor, F) 'Filled circle
        End If
    Else If Circle2.Enabled = true Then
        If blnDRAG = 1 AND ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
            BurningSand.FCircle(x, y, PenSize, DrawColor) ' circle
        End If
    End If
End Sub
 

neilnapier

Active Member
Licensed User
Longtime User
Thanks but it still doesn't work... The circle and Circle2 are both buttons and so I wasn't sure if the enable thing would work with it. So It might have something to do with them...
 

neilnapier

Active Member
Licensed User
Longtime User
That wouldn't work as it is an image button... I am trying to get it to look like the desktop version as much as possible. Is there a way that it would be possible... I could upload the whole file if you want so you can actually test to see what is wrong with it?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The solution is to use a global variable (I've named it filled):
B4X:
Sub Globals
    blnDRAG = 0
    MinX = 30
    MaxX = BurningSand.Width - 33
    MinY = 25
    MaxY = Burningsand.Height - 45
    PenSize = 2
    DrawColor = Rgb(80,0,0)
    filled = true
End Sub

Sub circle_Click
    filled = true
End Sub

Sub Circle2_Click
    filled = false
End Sub

Sub BurningSand_MouseMove (x,y)
    If blnDRAG = 1 AND ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
        If filled Then
            BurningSand.FCircle(x, y, PenSize, DrawColor, F) 'Filled circle
        Else
            BurningSand.FCircle(x, y, PenSize, DrawColor) ' circle
        End If
    End If
End Sub

Note that for boolean values you can just write: If filled then (instead of If filled = true then).
 

neilnapier

Active Member
Licensed User
Longtime User
Thanks!!! That really helped a lot!

I have a few other questions however...

Is it possible to add a FPS counter to my program (frames per secend)

Would it be possible to have it so that each of the pixels that you draw move down the forelayer at a set speed (like a liquid) or up (like a gas)

Is there a way that I could have a indecator that is at the bottom that states which colour the cursor is going to create (or a name that the colour has been named (ie Water for blue)

Anyway thanks again Erel. When I release the updated version then I will put you in the thanks section.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is it possible to add a FPS counter to my program (frames per secend)

Would it be possible to have it so that each of the pixels that you draw move down the forelayer at a set speed (like a liquid) or up (like a gas)

There are no built-in methods for these features.
You will need to implement them.
About the color, you could draw a circle or some other figure with the selected color.
 

neilnapier

Active Member
Licensed User
Longtime User
But would there be a way using something like...

B4X:
Do
Something.Top = Something.Top + 1
Loop
 

neilnapier

Active Member
Licensed User
Longtime User
I have updated my page in Open Source. I have 4 different pens now.

Erel do you have any idea how I would possibly be able to make a liquid or gas. I was thinking perhaps using the the FErase function along with having something like x, y + 1, so that it moves but I'm not entirely sure how I would do this.
 
Top