Draw a line

micro

Well-Known Member
Licensed User
Longtime User
Hi to all,
how to draw a line touching the screen ?
And how to select the current color?

thanks
 

klaus

Expert
Licensed User
Longtime User
Attached you find a small test program with several graphic functions.
It's just a test program for me to see what can be done and how, but I post it, it could perhaps be helpful for others.

What do you mean with:
And how to select the current color?
Most views have a Color parameter.
But normaly it's up to you to define the color you want to draw with.
There is no ColorSelection function yet: http://www.b4x.com/forum/basic4android-updates-questions/6702-color-selection.html

Best regrads.
 

Attachments

  • Draw.zip
    114.5 KB · Views: 427
Upvote 0

derez

Expert
Licensed User
Longtime User
The attached code is something I used in a program, to select colors for several display items.
It has four preset colors and three seekbars, and a label to show the selected color.
touching any of the buttons on the top part paint them with the selected color and select this color for the display item.
I hope it helps.

B4X:
Sub Globals
...
Dim BlueSB, GreenSB, RedSB As SeekBar
Dim .... buttons.....
Dim Rcolor,Gcolor,Bcolor,selected_color,circle_color,HDG_color,BRG_color,WPT_color,Route_color,Target_color As Int
end sub

Sub WPTbtn_Click
WPTbtn.Color = selected_color
WPT_color = selected_color
End Sub

Sub Targetbtn_Click
Targetbtn.Color = selected_color
Target_color = selected_color
End Sub

Sub Routebtn_Click
Routebtn.Color = selected_color
Route_color = selected_color
End Sub

Sub HDGbtn_Click
HDGbtn.Color = selected_color
HDG_color = selected_color
End Sub

Sub Circlebtn_Click
Circlebtn.Color = selected_color
Circle_Color = selected_color
End Sub

Sub BRGbtn_Click
BRGbtn.Color = selected_color
BRG_color = selected_color
End Sub

Sub Colorsbtn_Click
colorspanel.Visible = True   
End Sub

Sub return_from_colors_Click
colorspanel.Visible = False   
save_ini_file
End Sub

Sub Redbtn_Click
RedSB.Value = 255
GreenSB.Value = 0
BlueSB.Value = 0
End Sub

Sub Greenbtn_Click
RedSB.Value = 0
GreenSB.Value = 255
BlueSB.Value = 0
End Sub

Sub darkbluebtn_Click
RedSB.Value = 0
GreenSB.Value = 0
BlueSB.Value = 255
End Sub

Sub yellowbtn_Click
RedSB.Value = 255
GreenSB.Value = 255
BlueSB.Value = 0
End Sub

Sub RedSB_ValueChanged (Value As Int, UserChanged As Boolean)
Rcolor = value
selected_color = Colors.RGB(Rcolor,Gcolor,Bcolor)
selected_color_label.Color = selected_color
End Sub

Sub GreenSB_ValueChanged (Value As Int, UserChanged As Boolean)
Gcolor = value
selected_color = Colors.RGB(Rcolor,Gcolor,Bcolor)
selected_color_label.Color = selected_color
End Sub

Sub BlueSB_ValueChanged (Value As Int, UserChanged As Boolean)
Bcolor = value
selected_color = Colors.RGB(Rcolor,Gcolor,Bcolor)
selected_color_label.Color = selected_color
End Sub
 

Attachments

  • colors.jpg
    colors.jpg
    30.8 KB · Views: 403
Upvote 0
Top