Share My Creation 10PRINT C64 to B4J

Read this first: https://10print.org/

create a new b4j project and paste this code:

B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private vpW, vpH As Float
    Private cnv As Canvas
    Private timer1 As Timer
    Private left = 0, top = 0, spacing = 10 As Float
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Show
   
    vpW = MainForm.RootPane.Width
    vpH = MainForm.RootPane.Height
   
    cnv.Initialize("")
    MainForm.RootPane.AddNode(cnv,0,0, vpW, vpH)
   
    timer1.Initialize("timer1",25)
    timer1.Enabled = True
End Sub

Sub timer1_Tick
    If Rnd(0,10) < 5 Then cnv.DrawLine(left,top,left+spacing,top+spacing,fx.Colors.Black,2) Else _ 'LINE MODE
        cnv.DrawLine(left+spacing,top,left,top+spacing,fx.Colors.Black,2)
       
'    If Rnd(0,10) < 5 Then cnv.DrawRect(left,top,spacing,spacing,fx.Colors.Black,True,0) Else _ 'RECT MODE
'        cnv.DrawRect(left,top,spacing,spacing,fx.Colors.White,True,0)

'    If Rnd(0,10) < 5 Then cnv.DrawText("p",left,top,fx.DefaultFont(16),fx.Colors.Black,"LEFT") Else _ 'TEXT MODE
'        cnv.DrawText("b",left,top,fx.DefaultFont(16),fx.Colors.Black,"LEFT")
    moveRight
End Sub

Sub moveRight
    left = left + spacing
    If left > vpW Then
        left = 0
        top = top + spacing
    End If   
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
 

Attachments

  • 10print.jpg
    10print.jpg
    388.8 KB · Views: 2,857
Last edited:

ilan

Expert
Licensed User
Longtime User
i have updated the code, now there is another MODE (rect)

try to find other possibilities that will create randomly a nice texture and share it here :)

B4X:
    If Rnd(0,10) < 5 Then cnv.DrawRect(left,top,spacing,spacing,fx.Colors.Black,True,0) Else _ 'RECT MODE
        cnv.DrawRect(left,top,spacing,spacing,fx.Colors.White,True,0)


EDIT: another combination.

B4X:
    If Rnd(0,10) < 5 Then 'LINE2 MODE
        cnv.DrawLine(left+(spacing/2),top,left,top+(spacing/2),fx.Colors.Black,2)
        cnv.DrawLine(left,top+(spacing/2),left+(spacing/2),top+spacing,fx.Colors.Black,2)
    Else
        cnv.DrawLine(left+(spacing/2),top,left+spacing,top+(spacing/2),fx.Colors.Black,2)
        cnv.DrawLine(left+spacing,top+(spacing/2),left+(spacing/2),top+spacing,fx.Colors.Black,2)
    End If
 
Last edited:
Top