Lia Hello World

 

A very basic Hello World with output to the console.

import lia.sys.Lia;

 

public class Main{

 

  public static void main()

  {

    const f = Lia.console(), t = System.currentTimeMillis();

    f.println("Hello world, the time is: "+t);

    System.exit(0);

  }

}

 

A Hello World with loops that run in the background.

import lia.sys.Task;

import lia.utils.Formatter;

 

public class Main{

 

  async static void countDown(int toWhat,[Formatter out = null,boolean exitWhenDone = false])

  {

    if (out == null) out = Lia.console();

    foreach(i in toWhat){

       out.println("Count: "+i);

       Task.sleep(100);

    }

    if (exitWhenDone) System.exit(0);

  }

  public static void main()

  {

    const f = Lia.console(), t = System.currentTimeMillis();

    f.println("Hello world, the time is: "+t);

    async countDown(10,f);

    async countDown(20,f,true);

  }

}

 

A Hello World to a window where the font size adjusts with the window size.

import lia.fx.Brush;

import lia.fx.Color;

import lia.fx.Dimension;

import lia.fx.FittedText;

import lia.fx.FontMetrics;

import lia.fx.Graphics;

import lia.fx.app.AppTouchEvent;

import lia.fx.app.AppWindow;

import lia.fx.app.AppWindowConfig;

import lia.fx.app.AppWindowHandler;

import lia.fx.events.SurfaceKeyEvent;

import lia.sys.Lia;

 

public class Main implements AppWindowHandler{

 

  public static void main()

  {

    Lia.setAppWindowHandler(new Main());

  }

 

  FontMetrics calculated;

  Dimension mySize;

 

  public void repaint(Graphics g,int x,int y,int width,int height,int paintModifiers){

    if (mySize == null) return;

    const txt = "Hello from Lia";

    if (calculated == null)

       calculated = new FittedText().setFor(txt,mySize.width*0.8,0).calculate(Lia.fx().getDefaultFont());

    g.drawRect(0,0,mySize.width,mySize.height,Brush["#f0f0ff"],null);

    const h = calculated.height(), w = calculated.textWidth(txt);

    g.drawText(txt,(mySize.width-w)/2,(mySize.height-h)/2,calculated.getFont(),Color["black"]);

  }

 

  public int closeRequested(boolean cannotBeDenied){

    System.exit(0);

    return CloseRequestAccepted;

  }

 

  public void destroyed(){

  }

 

  public void touchEvent(AppTouchEvent touch){

  }

 

  public void resized(int width,int height){

    mySize = new Dimension(width,height);

    calculated = null;

  }

 

  public AppWindowConfig created(AppWindow window){

    const r = new AppWindowConfig();

    r.title = "Hello from Lia";

    r.setAspect(window,0.5,0.8);

    return r;

  }

 

  public void keyboardEvent(SurfaceKeyEvent keyEvent){

  }

}

 

Which produces this output.

A white paper with black text

AI-generated content may be incorrect.

A close-up of a sign

AI-generated content may be incorrect.

 

Generating targets

All target generation is push-button, which is to say there is no command line task for building at this time. You configure each target in the IDE and simply select “Build Now” to do so. However, I will describe what happens under the hood and what you need for each target.

Android

For Android you must install the Android command line tools – or the full Android Studio if you wish. Building will involve the IDE producing a Gradle project for the target and then running the Gradle build process. On success an APK is generated which can be installed on any compatible Android device manually or via the Android ADB tools.

Windows with Visual Studio

For Windows you must install Visual Studio command line tools – or the full Visual Studio if you wish. Building will involve the IDE producing a Visual Studio project for the target and then running the compiler in its own process. On success a Windows .exe is produced.

Windows with MinGW

MinGW is a windows compiler that runs on Linux or Windows or MacOS. Building will involve the IDE producing a C++ project for the target (a makefile) and then running the compiler in its own process. On success a Windows .exe is produced.

Linux

For Linux you must have GCC for the target system. Building involves the IDE producing a GCC project (a makefile) which is then run in a separate process, or for which the source code can be transported to the target Linux system and have GCC run on that target system.

iOS

For iOS you must have access to a Mac with XCode installed on it. Building involves the IDE producing Objective C code which can be remotely built on the Mac to for whichever iOS device you want to target. The IDE provides tools to do a remote build if you are not running the IDE on a Mac.

Javascript

For Javascript the IDE processes the source code directly into Javascript. The produced files can then be hosted on any website and will work on any browser.

Java

To produce a Java JAR executable file the IDE processes the source code directly into Java, runs the Java compiler and puts them into a JAR file.