Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Pixel_Outlaw

Pages: [1] 2 3 4 5 6 7 8 ... 10
1
After reading quite a few books on the subject of recreational programming (simple short programs to amuse) I've decided to make a forum for such things. Most of these projects are not really in line with the notion of a demo. They are usually programs with a simple effect in mind that is often static. Really the algorithm is what is important.

Since many people here enjoy programming an effect or two into a demo I thought I might draw some interest.
It is a bit different from a demoscene forum in that I ask users contribute algorithms in pseudocode or English.
I'm trying to create something that is both programming language, and platform agnostic.

Let me say that I would never want to pull people away from contributing to this forum.
My little project is more of an exploration of visual algorithms and oddidites.
There will never be compelling competitions like Shockwave has done here.

combatking0 has done the bulk of the work, we are just trying to get some solid content in now.
Most of my programming is done these days on low end Linux machines with old graphics cards so a lot of my work anymore is static graphics and concept exploration.

Please join, take a look at the examples and see if there is content you'd like to contribute!
Currently we have a approval process for joining. But that may change.

http://forums.pixeloutlaw.smakweb.com/index.php

Thanks for any interest!
There are a LOT of talented visionaries here that I'd like to have.  :hi:

2
General chat / Smooth interpolation...
« on: November 17, 2012 »
I stumbled upon this page today and thought it needed to be shared.
It discusses types of interpolation for movement. This can be used for things like movement, Perlin Noise, color cycling etc.

I use interpolation quite a lot and these new tools will get me away from the ever so common linear interpolation.
http://sol.gfxile.net/interpolation/index.html

3
Projects / The Demons of Cyclic Space (C++ & SDL)
« on: October 28, 2012 »
Greetings again. Recently I've purchased a supurb book "The Magic Machine: A Handbook of Computer Sorcery"  ISBN 0-7167-2125-2

The author outlines an algorithm to produce a gorgeous cycle of color from random noise. Here is my implimentation.
I don't have a Windows computer but it is in SDL so it should be compilable. Ensure that both the .h file and .cpp file are in the same folder.



If you are running SDL on the Pi it will probably work with the following compile line (assuming you have installed SDL and g++)

Ensure both files are in the same folder when you compile.
g++ -o cyclic_space cyclic_space.cpp -lSDL

If a member here could offer a Windows executable it would be great for those not used to compiling C++. :D

Feel free to hack on it and speed it up, it is not my algorithm so feel free to adopt it in your demos and such.
I've simply ported it from the book to a modern language.

The main file cyclic_space.cpp
Code: [Select]
// Ryan Burnside
// 10-26-2012
// "The Demons of Cyclic Space"
// Original algorithm - David Griffeath
 
// Header Section
#include <SDL/SDL.h>
#include <iostream>
#include <time.h>
#include <vector>
#include "HSLtoRGB.h"
 
// *** Function Section ***
void putpixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
bool user_quit(SDL_Event &event);
void gen_palette(std::vector<SDL_Color> &colors, int states);
void seed_buffer(int* buffer_start,unsigned int num_elements, int states);
void buffer_flip(SDL_Surface* surface, int* buffer_start,
                 unsigned int width, unsigned int height,
                 std::vector<SDL_Color>& color);
int get_index(int* buffer, int width, int x, int y);
void set_index(int* buffer, int width, int x, int y, int value);
Uint32 TimeLeft(const int TICK_INTERVAL);
void advance_pattern(int* old_buffer, int * new_buffer,
                     unsigned int width, unsigned int height, int max_value);
 
 
// *** Body Loop ***
int main (int argc, char** argv)
{
    srand (time(NULL));
 
    // Define Constants Section
    const int SCREEN_WIDTH = 256;
    const int SCREEN_HEIGHT = 256;
    const int NUM_STATES = 19; // between 12 and 16 are ideal
    const unsigned int NUM_ELEMENTS = SCREEN_WIDTH * SCREEN_HEIGHT;
    const int TICK_INTERVAL = 10;
 
    // 2 buffers to hold states of the cells
    int old_buf[SCREEN_WIDTH * SCREEN_HEIGHT];
    int new_buf[SCREEN_WIDTH * SCREEN_HEIGHT];
    seed_buffer(old_buf, NUM_ELEMENTS, NUM_STATES);
    seed_buffer(new_buf, NUM_ELEMENTS, NUM_STATES);
 
    // Initialize SDL video
    SDL_Init(SDL_INIT_VIDEO);
 
    // SDL cleans up before exit
    atexit(SDL_Quit);
 
    // Create a new window
    SDL_Surface* screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16,
                                           SDL_HWSURFACE|SDL_DOUBLEBUF);
 
    // Generate an array of precalculated lookup colors
    std::vector<SDL_Color> colors;
    gen_palette(colors, NUM_STATES);
 
    SDL_Event event;
    while(user_quit(event) == false)
    {
        advance_pattern(old_buf, new_buf, SCREEN_WIDTH, SCREEN_HEIGHT,
                        NUM_STATES - 1);
 
        buffer_flip(screen, new_buf, SCREEN_WIDTH, SCREEN_HEIGHT, colors);     
        SDL_Flip(screen);
        // Delay for atleast TICK_INTERVAL
        SDL_Delay(TimeLeft(TICK_INTERVAL));
    }
    return 0;
}
 
// *** Function Definitions ***
bool user_quit(SDL_Event &event)
{
    // These poll for user quit events.
    SDL_PollEvent(&event);
    switch (event.type)
    {
    case SDL_QUIT:
        return  true;
        break;
 
    case SDL_KEYDOWN:
    {
        if (event.key.keysym.sym == SDLK_ESCAPE)
            return  true;
        break;
    }
    default:
        return false;
    }   
}
 
void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
{
    // Places a pixel of color Uint32 on a SDL_Surface surface.
 
    int bpp = surface->format->BytesPerPixel;
    /* Here p is the address to the pixel we want to set */
    Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
 
    switch(bpp)
    {
    case 1:
        *p = pixel;
        break;
 
    case 2:
        *(Uint16 *)p = pixel;
        break;
 
    case 3:
        if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
        {
            p[0] = (pixel >> 16) & 0xff;
            p[1] = (pixel >> 8) & 0xff;
            p[2] = pixel & 0xff;
        }
        else
        {
            p[0] = pixel & 0xff;
            p[1] = (pixel >> 8) & 0xff;
            p[2] = (pixel >> 16) & 0xff;
        }
        break;
 
    case 4:
        *(Uint32 *)p = pixel;
        break;
    }
}
 
void gen_palette(std::vector<SDL_Color>& colors, int states)
{
    // Fills a std::vector with SDL_Colors for x many states
    // Colors differ by hue for a rainbow effect
    for(int i = 0; i < states; ++i)
    {
        SDL_Color temp;
        float r, g, b; // Used to hold values from function
        float step = 360.0/states;
 
        HSLtoRGB(i * step, 1, .5, r, g, b);
        temp.r = r;
        temp.g = g;
        temp.b = b;
        colors.push_back(temp);
    }
}
 
void seed_buffer(int* buffer_start, unsigned int num_elements, int states)
{
    // Assign a random color index to the color array.
    for(int i = 0; i < num_elements; ++i)
    {
        *(buffer_start + i) = rand() % states;
    }
}
 
void buffer_flip(SDL_Surface* surface, int* buffer_start,
                 unsigned int width, unsigned int height,
                 std::vector<SDL_Color>& color)
{
    // Blits a state buffer to the SDL_surface screen
    // using mapped colors defined in the std::vector color.
    int counter = 0;
    int color_index = 0;
   
    // Lock surface for modification
    SDL_LockSurface(surface);
    for(int y = 0; y < height; ++y)
    {
        for(int x = 0; x < width; ++x)
        {
            color_index = *(buffer_start + counter);
            putpixel(surface, x, y, SDL_MapRGB(surface->format,
                                               color[color_index].r,
                                               color[color_index].g,
                                               color[color_index].b));
             counter++;
        }
    }
    // Unlock surface
    SDL_UnlockSurface(surface);
}
 
int get_index(int* buffer, int width, int x, int y)
{
    // Adapt 2D coordinates to 1 dimension and return index.
    return *(buffer + (width * y + x));
}
 
void set_index(int* buffer, int width, int x, int y, int value)
{
    // Adapt 2D coordinates to 1 dimension and set index.
    *(buffer + (width * y + x)) = value;
}
 
Uint32 TimeLeft(const int TICK_INTERVAL)
{
    // Taken from SDL homepage
    // Returns how many ticls left to wait
    static Uint32 next_time = 0;
    Uint32 now;
 
    now = SDL_GetTicks();
    if ( next_time <= now ) {
        next_time = now+TICK_INTERVAL;
        return(0);
    }
    return(next_time-now);
}
 
void advance_pattern(int* old_buffer, int * new_buffer,
                     unsigned int width, unsigned int height, int max_value)
 
{
    // Advances the cellular automation pattern 1 step
 
    // Create a list of points to check for neigbours colors
    int xpart[] = {0, 1, 0, -1};
    int ypart[] = {-1, 0, 1, 0};
 
    int test_x, test_y, old_color, neighbor_color;
 
    for(int y = 0; y < height; ++y)
    {
        for(int x = 0; x < width; ++x)
        {
            // Check 8 neighbors using parallel offset arrays
            for(int n = 0; n < 4; ++n)
            {
                test_x = x + xpart[n];
                test_y = y + ypart[n];
                // Wrap test point if need be
                if(test_x < 0)
                    test_x += width;
                if(test_y < 0)
                    test_y += height;
                if(test_x >= width)
                    test_x -= width;
                if(test_y >= height)
                    test_y -= height;
 
                // Find colors for center point and neighbour
                old_color = get_index(old_buffer, width, x, y);
               
                neighbor_color = get_index(old_buffer, width, test_x, test_y);
 
                // If the neighbour is one stage more adopt it for the middle
                if(neighbor_color == old_color + 1)
                    set_index(new_buffer, width, x, y, neighbor_color);
                else if(neighbor_color == 0 && old_color == max_value)
                    set_index(new_buffer, width, x, y, neighbor_color);
            }
        }
    }
   
    // Copy the new buffer into the old
    memcpy(old_buffer, new_buffer, width * height * sizeof(int));
}

The HSL to RGB function.
HSLtoRGB.h

Code: [Select]
#include <cmath>
 
void HSLtoRGB(float H, float S, float L,
              float& outR, float& outG, float& outB,
              float channel_max = 255, bool fraction = false)
{
// H [0 - 360] S [0 - 1] V [0 - 1]
  float C = (1 - std::abs(2.0 * L - 1)) * S;
    float H2 = H/60.0;
    float X = C * (1 - std::abs(std::fmod(H2, 2) - 1));
    // define base RGB values
    float r,g,b = 0;
   
    if(0 <= H2 && H2 < 1)
    {
        r = C;
        g = X;
        b = 0;
    }
    else if(1 <= H2 && H2 < 2)
    {
        r = X;
        g = C;
        b = 0;
    }
    else if(2 <= H2 && H2 < 3)
    {
        r = 0;
        g = C;
        b = X;
    }
    else if(3 <= H2 && H2 < 4)
    {
        r = 0;
        g = X;
        b = C;
    }
    else if(4 <= H2 && H2 < 5)
    {
        r = X;
        g = 0;
        b = C;
    }
    else if(5 <= H2 && H2 < 6)
    {
        r = C;
        g = 0;
        b = X;
    }
    float m = L - C * .5;
    if(fraction == false)
    {
        outR = int((r + m) * channel_max + .5);
        outG = int((g + m) * channel_max + .5);
        outB = int((b + m) * channel_max + .5);
    }
    else
    {
        outR = (r + m) * channel_max;
        outG = (g + m) * channel_max;
        outB = (b + m) * channel_max;
    }
}

4

With the demoscene virtually unknown in the US, you guys are my best resource for information.

What processors are most ASM programmers making demos for? Granted I understand that everyone has their favorite.

64 bit is the norm now with computers but are the ASM coders still working heavily with the x86?
One other question, since the assembly code very low language, how dependent on the OS is it?
I'm hardly on a Windows PC anymore and it would be nice to code ASM that ports easily! When you work with ASM are you still confined to the OS HAL or do you bypass that?

5

So my friend and I thought it might be fun to take a thin client computer and make it into a full server. Done.
Specs:
Debian 6, no X11.
300 MHz CPU (idles at about 6%, up to 10% with 4 users logged in)
512 MB RAM (system only needs 29 MB initially jumps to 39 MB with multiple programs users running)
"Mystic BBS" installed.

Yesterday we set up a BBS on it and nobody on our little server has ever used one.
The first thing to strike me is the notion of a "Time Bank" the bugger kicked me off after about half an hour. Even as a board operator it did it.

I know that ANSI art was popular at the time and I'm wondering how ANSI art is stored? Is it just a flat text file
with ansi characters inside?

If anyone knows how to set up a modern terminal to work with ANSI that would be great, currently we are using a few
Linux terminals gnome-terminal, lxterminal, and puTTY. They get garbled characters many times. I assume it is because they are trying to use Unicode instead of ANSI?

It is not ready for prime time yet, but it feels GREAT to be able to do so much with just simple text.
I guess it goes back to the hacker mentality of not accepting limitations on your system but redefining them.

A thin client is basically garbage but we've made a full early 90's style server out of one with very low resources.

Thoughts?
Reminiscence about BBS?  :carrot:

6
Projects / nCurses fire....
« on: February 27, 2012 »
Don't know how many people have a posix computer but This is about three hours of work.
It is not finished but I'm posting the code early...

I've been felling very texty as of late.
You'll need Linux or Unix and a C++ compiler to compile. Also the nCurses library.
q to quit.

Here is the source... IT IS HORRIBLY RUSHED.
http://pastebin.com/ZR8vUzeC

7

I'm sure everyone will recall the new line of Commodore computers coming out. Basically they are modern machines running emulated Commodore software through a tailored version of Linux. You can download the whole OS today.

I have mixed feeling about this. It is nice that they are releasing the OS free and trying to be open. On the other hand I think people want true classic commodre machine resurrected.

That said, I don't really consider them the same old company. They appear to be a new computer company committed to open source operating systems. Their OS is actually a very tailored version of Linux Mint (the most popular distribution). I might try their OS before passing judgement on them.

Link here...
http://www.commodoreusa.net/CUSA_OS_Vision_Download.aspx

8
I've been thinking about trying either GTK or FLTK for cross platform development. Before I allocate the time I was wondering if anyone has played with them much?

9
Well I'm taking a college course just for the heck of it. Let me just say that the network plan they had adopted is making most power users and students tear their hair out. They have adopted thin clients. Actually they are not thin clients they are more like zero clients as they have more RAM than drive space. Compiling code is a living hell and the thin clients are actually Linux machines that have some odd Windows layer running on top of them. They sport 512 MB of RAM and no internal storage. I value your opinions here and so my instructor asked me if I could gather some general feelings about a possible solution. Maybe you can offer your opinions?

 I personally feel that these thin clients are a bad idea when you have 30 students writing demanding programs all on the same server.   
:boxer:

From my instructor:

The networking types have installed a thin client working of a Win 2003 terminal server. The first problem arises when doing program development using Visual Studio 2010. If someone has made a mistake in a loop leading to a non-terminating logic error (infinite loop), the client completely locks up and one cannot break out of the command line window. To get out, one has to do a complete hard shutdown of the client. Even that does not always work. Some folks have come back after a couple of days only to find that the infinite loop is still grinding onward. If one is extremely lucky, the shutdown restart sequence works ok. Otherwise, you are stuck. Is there anything inherent in thin-client/terminal servers that prevent them from working properly in a programming environment? Is there something wrong with the configuration? Is it simply under-powered? Is there something else that we are overlooking?

10

As a novelty I have been considering playing around wiith a monochrome screen. The problem is that I don't know a good approach to getting my hands on a green or amber one. I think they look really nice but I'd need to connect something via VGA to my computer. I would buy one on ebay but shipping kills me as they are CRT and quite heavy.

Any ideas? I'd be willing to hack a cheap LCD if there is a way. Do they make cheap video mixers that can sum the RGB channels and then feed that average back into green? An odd place to ask maybe, but plenty of people got to play with monochrome CRT screens before me. I recall my grandma having a Brother word processor that had a really crisp yellow/amber screen. :)

11
General chat / I guess I don't like Web programming...
« on: September 11, 2011 »

So for about 3 months now I've been working at a job I dislike. (bitch whine...etc)

The real problem I feel is that I don't like web programming. Basically I feel that it is all sort of temporary and meaningless.

I don't like the mindset of web programming.
I don't like making stateless programs where you have to fiddle with cookies and such.
Unlike standard programming, all that you depends on 3rd party software the web browser you are at the mercy of the browser.
I don't like the fact that the standards of HTML are a mess and that browsers are all different this causes walls and walls of special cases.
It seems that web programmers don't speak the same (sensible) language as application programmers. (I sort of regard them as false prophets of the computer world).
You never just sit down and work in HTML, you have to add on myriads of external languages and clutter just to "trick" HTML into displaying what you want.
There is no cycle like a normal program you calculate then barf everything onto to the screen.

I work in a combination of javascript, HTML (duh) and jQuery at work. They have this horrible horrible product called BCD Websmart that supposedly enables COBOL programmers to integrate into web design. Ofcourse it runs all the logic of the webpage and has it's own syntax (another layer of annoyance). Also it integrated with IBM's DB2 database (Which they've had since the 80's).

Just frusterated as hell and needed to vent. I really think web design is far more convoluted that it need be and my case is probably as bad as it gets.

12

Many people will recall the early days of programming when you got small snippits of code from a magazine and you poked them into your computer.
Sadly, I never had the chance to do this as I did not own a computer until middle school in the 90's.

I think these were a healthy way to teach young people how a computer works. Ideally, you would have to make a simple (but usable) IDE that could compile code and then have monthly releases of programming magazines. Maybe each month you have a handful of programs for them to poke in, spanning no more than around 300 lines. Perhaps they might be able to submit programs and there would he a showcase each month with the winner's name and program code for everyone to try.

I'm not saying I'm going to quit my job and start publishing magazines but it is something that I've been rolling around in my mind for a while.

Do you think it is possible?
Are kids today just as willing as their parents were?

We still have the problems of languages like C not doing much own their own as far as display and sound go but a simple library could be made for the magazine too I suppose.

Thoughts please!

14
I'm working on exploring some new pathfinding code and currently have a problem.

I have a stl list of Tiles. I have written a search function that should search the stl list and return a pointer to the memory location of the Tile.
However, it appears that what I'm doing will not work because it wants to use a pointer to an iterator rather than a pointer to a Tile.


The understandable error:
Code: [Select]
/home/ryan/Dropbox/Rpath/main.cpp|110|error: cannot convert ‘std::_List_iterator<Tile>*’ to ‘Tile*’ in return|
Code: [Select]
struct Tile
{
public:
    int x,y,value,g,h,f; // a non zero value means unwalkable
    Tile * parent;

    Tile(Tile * parent, int x, int y, int g, int h, int value)
    {
        this -> parent = parent;
        this -> x = x;
        this -> g = g;
        this -> h = h;
        this -> value = value;
        this -> f = g + h;
    }

    bool operator == (Tile& compare)
    {
        // Tiles are only compared on x and y values
        // other variables are not taken into account
        if(compare.x != x) return false;
        if(compare.y != y) return false;
        return true;
    }

    bool operator < (const Tile& compare)
    {
        if(f < compare.f) return true;
    }
};

//  now the function that cannot compare an stl list iterator pointer to a Tile.

Tile* find_by_value(list<Tile>& my_list, Tile &my_tile)
{
    // return true if a similar tile is found
    for(list<Tile>::iterator i = my_list.begin(); i != my_list.end(); i++)
    {
        if(*i == my_tile) return &i;
    }
    return NULL;
}


The function is supposed to take a Tile and search the stl list to find a matching one, returning a pointer to the matching Tile.[/code]

15
Longing for more minimalism and nonsensical restriction in programming, I wonder how far somebody could take making a program with a single variable?

I suppose you could use a large variable like a double and then divide it into smaller memory sections. It would be really fun to look at a code and only see a single variable declaired and lots of shifting bits around to maintain such a low memory state.

Any thoughts? I might try this should I built up enough interest.
Might be an interesting challange to demo coding as we tend to applaud clever restrictions and ingenuity.

Again just making a conversation point here. I'd be interested to hear your thoughts.

16
C / C++ /C# / Any cross platform video library?
« on: July 20, 2011 »

I sort of want to embed some video information in a project.
Are there some simple and powerful video library loading libraries?
It would also need to provide me some pixel level access to the video screen buffer for some fancy effects...

17
General chat / Kind of frusterated...
« on: July 04, 2011 »
Recently I landed a job with an insurance company. They actually contacted me as I had an internship there.
Now everyone there is kind and welcoming but I feel that I'm really in over my head as far as their technology goes.

Let me further explain:
They operate an IBM i5 series server which is LOADED with IBM proprietary stuff.
Their interface for their "processors" and "underwriters" (employee positions) is a text driven user interface that cannot display pictures.
To remedy this situation they have employed a second Windows XP picture server which may just be a common desktop machine.
This picture server holds pictures for insurance data and it gets linked to via FTP when something needs to be updated from the I5 server.

Here is the problem,
They use COBOL and RPG to query the database and work with files. Since the programs were all written in house there is no documentation to be found.
Upgrading the system would be damn near impossible because they have patched the thing so many times without any documentation.
The database is a DB2 system which means that it does not play nicely with others. The whole thing is being held together with a truckload of custom undocumented software with quite
cryptic file names. Everyone there is 50+ and they don't know any modern programming languages. By modern I mean C and foreward.

I'm not sure what to do. I try to pick up a little everyday but I don't know enough about insurance nor do I know any COBOL, RPG, javascript (for the website agent portal).

I'm not sure what to do here. I'm not thinking about quitting just yet but it is heavily undocumented and outdated technology that cannot easily be updated.
I'm having to deal with files named things like PDK01. Sure that might mean something to somebody who wrote the system but they have made it damn near impossible for a newcomer to under
stand.

Perhaps the worst part is that they just make me watch them for 8 hours each day expecting something to suddenly make sense...

Just venting some frusterations perhaps. They pay is good and the hours are great...but at what cost?

18

I've been curious about the old BBS systems that had the wonderful art made of ANSi characters.
Are these kinds of things still popular?
What is required to run such a board if so?

From what I gather they are a sort of forum before forums existed.
Now what is all this about a call number?

Sorry, I was crawling around and pooping my pants when this stuff was in its heyday...

19

Here is a small tecnique I've come up with for single shot 360 degree panoramas.

http://ryanburnside.wordpress.com/2011/06/15/53/

Nothing too fancy but it is fun. Just thought i'd share.  ;D

20
C / C++ /C# / [C++] outputting unicode strings...
« on: June 13, 2011 »

I currently have the need to output some unicode characters into the console window.
I wish to output some braille characters like shown  here...
http://tlt.its.psu.edu/suggestions/international/bylanguage/braillechart.html

These will be dithering patterns in a crude image to text program.
Please help if you can.


Pages: [1] 2 3 4 5 6 7 8 ... 10