Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Sunday, May 15, 2016

Scracth Jr for iOS: Coding for kids


Wondering if you have what's required to create an app or a game?  Why not start gently with Scratch Jr. for iPad.



A few years ago, I was showing my kids what I was doing at my job by using Scratch on the computer.  Basically, it's a software that lets you create small games and applications using logic blocks that you can drag and drop on you characters.  It's a bit like playing Lego blocks with your mouse.

There is an iOS version called Scratch Jr. available in the AppStore.  It targets kids but anyone who wants to learn about software programing can start with this little app.  Of course, you won't be able to publish your apps or create the latest 3D games with Scratch Jr.  It is meant to be a really simplified version of the real thing.  But nevertheless, you will learn about conditions, loops and events in a matter of minutes.


The best thing is that Scratch Jr. is free.  The MIT has created this amazing app so kids, and grown ups, can learn about software development in a fun way.


There is a more advanced version of Scratch available online at https://scratch.mit.edu.

Have fun!

Saturday, February 6, 2016

Encode a JPanel (Java Swing) into a movie with FFMpeg

A few days a go I was tweaking ScreenStudio 2.0.  The main idea is to create a dynamic overlay a bit like WebcamStudio without having to use a lot of CPU resources.

WebcamStudio is great but do required a powerful computer to make it work.  On the other hand, ScreenStudio is more limited but do have the advantage of being simple to broadcast live your desktop over Twitch and Youtube.

ScreenStudio do support a static overlay created by rendering an HTML file using a JLabel (a label component in Java Swing).  The result is pretty good but do lack dynamic content.  I've tried several ways without major success.  That is until a few days ago.

I knew that FFMpeg is able to read from many sources.  I had, in the past, used a TCP/IP connections to get a BufferedImage to FFMpeg.  The process is slow and do required a lot of code to handle the connections.

I also tried using the OutputStream for the Process to output the content to FFMpeg but it does not work reliably.

Then it occured to me that I could use a fifo file using the command "mkfifo" in linux to output a BufferedImage directly to FFMpeg.

The command is quite simple:

Monday, January 25, 2016

What is a null value?

A while ago, my kids were asking me about my work as a software programmer.  They were trying to understand what I was doing exactly all day long, "playing" on a computer with multiple displays.

They were understanding the concept of creating a software by writing coded instructions  but were actually baffled about the concept of variables.  It took a lot of explanations and examples to describe what was a variable but I finally was able to translate my mumbo-jumbo into bags of candies.  

The example was that at any moment, I wanted to keep count of how many laps a racing car had completed around the race track.  Each time the car does a lap, we add another candy into the bag.  The variable is the bag and the value is the amount of candies in the bag.  Technically, we have an Integer, meaning that this bag can only represents whole numbers.  

As we were discussing variable types (integer, strings, double,...), I mentioned that any variable must be initialized before using it or else, we would have a "null" value...  At that moment, I had lost them completely.  One of them replied that a null value is zero (0) so why have a name for a zero value?

The problem here is that I was explaining the concept of variables using quantities.  Saying that the bag had no candies in it or that the bag had zero candies in it, was the same thing.  They were right. I then used a pen and a piece of paper to explain the null value.

I wrote down the number 23 and asked them of many laps was represented.  They all answered twenty-three.  Then I erased the value and wrote 0 (zero).  Again I asked them how many laps and some answered zero, others said none.

Then I erased the number zero and left the piece of paper blank. 
- How many laps now?
- We don't know, you haven't written anything...
- That is a NULL value...

Then they started arguing that "zero" and "blank" was the same thing.  

- Wrong!  Writing "0" means that I had check how many laps were completed and counted no laps so the number of laps completed was "0".  This is an identifiable value.  When nothing was written, it meant that I did not count in any way the number of laps.  No value was available thus leaving the piece of paper blank.

I would have continued explaining the memory allocation or the joy of arrays but that was already too much information for them and they considered that my job must be very dull and complex.

At last, now, they do not think that I am gaming all day long...

Have a great week!