Giter Club home page Giter Club logo

pixelflut's Introduction

Pixelflut: Multiplayer canvas

What happens if you give a bunch of hackers the ability to change pixel colors on a projector screen? See yourself :)

Pixelflut is a very simple (and inefficient) ASCII based network protocol to draw pixels on a screen. You can write a basic client in a single line of shell code if you want, but you only get to change a single pixel at a time. If you want to get rectangles, lines, text or images on the screen you have to implement that functionality yourself. That is part of the game.

Pixelflut Protocol

Pixelflut defines four main commands that are always supported to get you started:

  • HELP: Returns a short introductional help text.
  • SIZE: Returns the size of the visible canvas in pixel as SIZE <w> <h>.
  • PX <x> <y> Return the current color of a pixel as PX <x> <y> <rrggbb>.
  • PX <x> <y> <rrggbb(aa)>: Draw a single pixel at position (x, y) with the specified hex color code. If the color code contains an alpha channel value, it is blended with the current color of the pixel.

You can send multiple commands over the same connection by terminating each command with a single newline character (\n).

Example:

$ echo "SIZE" | netcat pixelflut.example.com 1337
SIZE 800 600
$ echo "PX 23 42 ff8000" | netcat pixelflut.example.com 1337
$ echo "PX 23 42" | netcat pixelflut.example.com 1337
PX 23 42 ff8000

Implementations MAY support additional commands or have less strict parsing rules (e.g. allow \r\n or any whitespace between parameters) but they MUST support the commands above.

Server Implementations

This repository contains multiple implementations of the pixelflut protocol. Pull requests for additional implementations or improvements are always welcomed.

/pixelflut (python server)

Server written in Python, based on gevent and pygame. Easy to hack with, but a bit slow. In fact, it was slowed down on purpose to be more fair and encourage smart drawing techniques instead of image spamming. Perfect for small groups.

cd pixelflut
sudo apt-get install python-gevent python-pygame python-cairo
mkdir save
python pixelflut.py brain.py

/pixelwar (java server)

Server written in Java8, based on netty and awt. Optimized for speed and large player groups, fast networks or high-resolution projectors. This is probably the most portable version and runs on windows, too.

cd pixelwar
sudo apt-get install maven openjdk-8-jdk
mvn package
java -jar target/pixelwar*-jar-with-dependencies.jar

or, if you have docker installed but don't want to install maven:

docker run -it --rm --user "`id -u`:`id -g`" --volume "`pwd`:/build" --workdir /build maven:3-jdk-8-alpine mvn -Duser.home=/build clean package
java -jar target/pixelwar*-jar-with-dependencies.jar

/pixelnuke (C server)

Server written in C, based on libevent2, OpenGL, GLFW and pthreads. It won't get any faster than this. Perfect for fast networks and large groups.

cd pixelnuke
sudo apt-get install build-essential libevent-dev libglew-dev libglfw3-dev
make
./pixelnuke

Keyboard controls:

  • F11: Toggle between fullscreen and windowed mode
  • F12: Switch between multiple monitors in fullscreen mode
  • c: Clear the screen (50% black, hit multiple times)
  • q or ESC: Quit

Additional Commands:

  • STATS Return statistics as STATS <name>:<value> ...
    • px:<uint> Number of pixels drawn so far. Will overflow eventually.
    • conn:<uint> Number of currently connected clients.

Planned Features:

  • Toggle between windowed/fullscreen mode and switch monitors in fullscreen mode.
  • Persist pixel buffer between restarts. Use an mmap-ed file for pixel data?
  • Save to PPM (via key, timer or admin command) and add docs/tools to convert these into a video.
  • Support to draw directly to a framebuffer (no OpenGL or X Server dependency -> Raspberry-PI compatible)
  • Showcase-Mode: Players won't draw at the same time, but take turns. Each player gets N seconds of exclusive draw time)
  • Limit concurrent connections on a per IP basis.
  • Admin commands: Unlock additional commands with a password (e.g. PX2 <x> <y> <rrggbbaa> to draw to the overlay layer)

Even more implementations

A fast GPU accelerated pixelflut server in Rust.
https://github.com/timvisee/pixelpwnr-server

Links and Videos

Pixelflut at EasterHegg 2014 in Stuttgart, Germany
http://vimeo.com/92827556

Pixelflut Bar (SHA2017)
https://wiki.sha2017.org/w/Pixelflut_bar
https://www.youtube.com/watch?v=1Jt-X437MKM

Pixelflut GPN17 Badge
https://www.youtube.com/watch?v=JGg4zqqumvs

Rüspeler Tüfteltage (Kliemannsland, 2018) https://youtu.be/TijSQYZoRUU?t=6m

pixelflut's People

Contributors

ccoenen avatar danrl avatar defnull avatar joker234 avatar leodj avatar maxmatti avatar raboof avatar rhysperry111 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pixelflut's Issues

Pixelwar colors are off for RGBA

I recently started playing with Pixelflut.
On Windows - in my case - python pixelflut is way too slow (900px/s) and pixelnuke won't compile (obviously).
So I chose java Pixelwar, which is way faster and compiled it using maven. But there I have another problem:

  • colors are scrambled. (red renders as blue)
  • if pixels are set with alpha channel, but full opacity, it still renders them as transparent

When no alpha channel is set, it renders colors without a problem.

I didn't start looking into it yet, maybe it's something easy. I just wanted to document that problem first.

grafik
grafik
grafik

Error in callback for 'TICK'

python 2.7.6
pygame===1.9.1release
gevent==1.1.1

/tmp/pixelflut/pixelflut$ python2 pixelflut.py brain.py 
ERROR:pixelflut:Error in callback for 'TICK'
Traceback (most recent call last):
  File "pixelflut.py", line 155, in fire
    self.events[name](self, *a, **ka)
  File "brain.py", line 141, in on_tick
    canvas.save_as('save/mov_%d.png' % last_save)
  File "pixelflut.py", line 190, in save_as
    pygame.image.save(self.screen, filename)

Syntax error when running Pixelflut on Python 3.10

I tried to run Pixelflut on Ubuntu 22.04. Maybe the python version is too new? Which version should I use?

$ python3 --version && python3 pixelflut.py brain.py
Python 3.10.6

  File "pixelflut.py", line 22
    async = spawn
          ^
SyntaxError: invalid syntax

Clean Quit?

Is there a way to exit pixelflut cleanly? I have tried adding a key (Q) which calls sys.exit(0), but this does not work. Ctrl+C does also not work.

I tried killing the process (regular SIGTERM and also SIGKILL), but I don't return to my regular terminal afterwards either way. Right now, I'm simply power-cycling my Raspberry Pi.

pixelnuke compilation error

If i try make in the pixelnuke directory on ubuntu 16.04 LTS I get the following error:

gcc -Wall -pthread -O2 -flto -c canvas.c -o canvas.o
In file included from canvas.c:1:0:
/usr/include/GL/glew.h:1202:24: fatal error: GL/glu.h: Datei oder Verzeichnis nicht gefunden
compilation terminated.
Makefile:19: die Regel für Ziel „canvas.o“ scheiterte
make: *** [canvas.o] Fehler 1

Add Support for animation feaure like in gartic phone

Hey,

I think It might be funny to add a fature, where you could gray out the Background after a time or a treshhold of Pixels drawn it gets saved, and drawn over.
The goal could be to make a Gif, Video or Animation. It could be possible to request the last drawn picture to change and add to it.

If this makes no sense, just declare the Issue as resolved.

Example:
https://www.youtube.com/watch?v=yRNxEbtkrgA

Have an nice Day :)

Make pixelnuke RasPI compatible

Raspberry PI does not support OpenGL/GLFW very well. The easiest approach would be to add a canvas_fb.c that implements the canvas interface but writes directly to a mapped /dev/fb0, which should be fast enough or even faster than an OpenGL ES Implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.