Basic painting algorithm implemented