lunes, 5 de octubre de 2015

Clase Mancha




FMain:

' gambas class file

Private circulo As Mancha


Public Sub Form_Open()
Me.Center
SliderBox1.MaxValue = 1000
SliderBox1.MinValue = 1
SliderBox1.Value = 500
End

Public Sub Button1_Click()
Timer1.Start
End

Public Sub Timer1_Timer()
circulo = New Mancha(DrawingArea1)
Print Timer1.Delay
End

Public Sub Button2_Click()
Timer1.Stop
End

Public Sub Button3_Click()
DrawingArea1.Clear
End

Public Sub SliderBox1_Change()
Timer1.Delay = SliderBox1.Value
End


Clase Mancha:

' gambas class file

Property pantalla As DrawingArea
Private $pantalla As DrawingArea


Public Sub _new(device As DrawingArea)
$pantalla = device
Crear()
End

Private Function pantalla_Read() As DrawingArea
Return $pantalla
End

Private Sub pantalla_Write(Value As DrawingArea)
$pantalla = Value
End

Public Sub Crear()
Dim x, y, radio, pintura As Integer
Dim EsteColor As Integer

pintura = Rand(1, 5)
Select Case pintura
Case 1
EsteColor = Color.Red
Case 2
EsteColor = Color.Black
Case 3
EsteColor = Color.Blue
Case 4
EsteColor = Color.Green
Case 5
End Select
x = Rand(1, $pantalla.Width)
y = Rand(1, $pantalla.Height)
radio = Rand(1, 50)
' Print "X=" & x & ",Y=" & y & ",Radio=" & radio

Paint.Begin($pantalla)
Paint.LineWidth = 1
Paint.Background = EsteColor
Paint.Arc(x, y, radio)
Paint.Stroke
Paint.End

End


Código fuente: virus-0.0.1.tar.gz


sábado, 3 de octubre de 2015

Ejemplo Texto (Paint)



DrawingArea1.Cached=true


' gambas class file

' by postapase

Public Sub Form_Open()

Me.Center
Me.Title = "Ejemplo Texto"

Paint.Begin(DrawingArea1)
Paint.Font.Name = "Ubuntu"
Paint.Font.Size = 30
Paint.Font.Bold = True
Paint.Background = Color.Red
Paint.MoveTo(25, DrawingArea1.Height / 2)
Paint.Text("by postapase")
Paint.Fill
Paint.End

End





Ejemplo Cuadrado


DrawingArea1.Cached=true



' gambas class file

' by postapase

Public Sub Form_Open()
Dim Lado As Integer = 100

Me.Center
Me.Title = "Ejemplo Cuadrado"

Paint.Begin(DrawingArea1)
Paint.LineWidth = 1
Paint.Rectangle(DrawingArea1.Width / 2 - (Lado / 2), DrawingArea1.Height / 2 - (Lado / 2), Lado, Lado)
Paint.Stroke
Paint.End

End




Ejemplo de Círculo


DrawingArea1.Cached=true


' gambas class file

' by postapase

Public Sub Form_Open()

Me.Center
' centramos el formulario
Me.Title = "Ejemplo Círculo"


Paint.Begin(DrawingArea1)
' con Begin indicamos que comenzamos el dibujo y le indicamos donde, en este caso en DrawingArea1 entre los paréntesis.
Paint.LineWidth = 1
' el grosor de línea de la circunferencia
Paint.Arc(DrawingArea1.Width / 2, DrawingArea1.Height / 2, 50)' coordenadas x y, después indicamos el radio de la circunferencia
Paint.Stroke
' arranca y visualiza el gráfico
Paint.End


End