Pretty Pixel-Level Picture Painting, Programmatically

My Mac laptop has 1,024,000 pixels. What is the easiest way to turn my display into completely black and go crazy by writing small programs to flip pixels into my heart?

To make it more specific, let's say I wanted to implement the Chaos Game to draw a Sierpinski triangle at the pixel level without anything else on the screen. What are the ways to do this?

+5
source share
5 answers

Maybe choose Processing

+3
source

, Serendipitous Solution?

- , . , , , .

+2

C ++, SDL. ( , ) Windows, OSX Linux.

http://lazyfoo.net/SDL_tutorials/index.php. , № 31 .

+1
source

A good way is GLUT, a (slightly) friendly multi-platform shell for OpenGL. Here is some code to circle some points:

#include <GL/glut.h>

void
reshape(int w, int h)
{
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, w, 0, h, -1, 1);
}

void
display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POINTS);
    for (int i = 0; i<399; ++i)
    {
        glVertex2i(i, (i*i)%399);
    }
    glEnd();
    glFlush();
}

int
main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutCreateWindow("some points");
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMainLoop();
    return 0;
}

This is C ++, but it should be almost identical in Python and many other languages.

+1
source

All Articles