Phillip Trelford's Array

POKE 36879,255

Introducing FunSharp

FunSharp is a new cross-platform open source graphics library, based on Small Basic’s library, with a typed API crafted for the sharp languages, F# and C#.

Drawing graphics is quick and easy:

GraphicsWindow.FillEllipse(10,10,300,300)

And when you ask FunSharp to draw graphics it will just go and open a window to view it for you:

Purple_Circle

FunSharp provides similar functionality to Python’s PyGame, used for developing games, and Processing used for visual art.

You can call FunSharp immediately from the F# REPL or build full-blown applications using F# and C#.

It’s an ideal library for beginners or anyone who just wants  to get stuff on the screen quickly.

With this in mind FunSharp works seamlessly on Raspberry Pi, Linux and Windows.

Getting Started

If you haven’t already, you’ll need to install F# on your machine, follow these instructions:

  • Linux (for Raspbian follow the Debian instructions)
  • Windows (install Xamarin Studio or Visual Studio)

Get the FunSharp source from GitHub using Clone or Download Zip, then load the FunSharp solution into MonoDevelop or Visual Studio and starting playing with the samples.

Notes:

  • FunSharp is built on Mono’s cross platform graphics libraries Xwt and Gtk# libraries which must be referenced.
  • currently apps must run in 32-bit mode.

Turtles

FunSharp has a Turtle module, which can be used to make fun shapes:

Turtle.X <- 150.
Turtle.Y <- 150.
for i in 0..5..200 do
   Turtle.Move(i)
   Turtle.Turn(90)

Renders:

Turtle_Example

Games

FunSharp can be used to make games quickly and easily. I’ve ported several games written for Small Basic requiring only minor modifications:

Asteroids

Have fun!

Comments (12) -

  • Mahesh

    8/14/2015 6:30:01 AM |

    Great

    • Franck

      8/14/2015 3:37:21 PM |

      Great ! Thanks Phil. I will also let my kids play a bit with the turtle and see what will happen Smile

  • jm

    8/14/2015 6:32:29 AM |

    You said that FunSharp provides similar functionality to PyGame and Processing. So I have an honnest question there: what is the advantage of FunSharp then ? That is to say, in which situation is it better to use FunSharp over PyGame or Processing ?

    • Phil Trelford

      8/14/2015 7:25:17 AM |

      Hi jm,
      PyGame and Processing are both great systems for knocking things together. I built this library for my 8yo who prefers using F# over Python for types, and prefers lighter syntax than the Java based Processing. I think it really just depends on your preferences.
      Cheers, Phil

      • Terrance Smith

        8/14/2015 7:43:34 AM |

        I like that your 8 year old has a programming language preference.  

        • bagherra

          8/14/2015 10:58:34 AM |

          I don't condone zealotry.

          • Chris

            8/16/2015 4:17:53 PM |

            opinions != zealotry

  • William Ivanski

    8/14/2015 7:35:33 AM |

    What's the difference between FunSharp and System.Drawing?
    See, System.Drawing has a Graphics.FillEllipse too: msdn.microsoft.com/.../...llellipse(v=vs.110).aspx

    • Phil Trelford

      8/14/2015 7:43:43 AM |

      Thanks William,

      Good question, with WinForms you need to start as an STA thread, create a window, show the window, handle the paint method and only then can you call Graphics.FillEllipse.
      In FunSharp you just write GraphicsWindow.FillEllipse, it does the rest for you.
      Personally I think FunSharp is a little more beginner friendly.

      Cheers,
      Phil

  • Alexander Savvas

    8/14/2015 7:49:56 AM |

    just starting with my own -almost-8yo, and I think this is great!

  • sabeen

    8/15/2015 1:33:19 PM |

    Hi Phil, how to use funSharp? i don' t know how to download the software ! plz help me out ...

    • Phil Trelford

      8/15/2015 2:26:31 PM |

      Hi Sabeen,
      Just follow the "Getting started" instructions in the post, and the notes on dependencies on the GitHub page.
      Thanks,
      Phil

Comments are closed