Code Monkey home page Code Monkey logo

plutonem's Introduction

A library to draw graphics with pixels in the terminal

Who needs a GUI when you have a terminal ?

Building

To generate libpluto.a, run:

$ make

To install it so that your compiler can use it directly, run:

# make install

To compile some examples, run:

$ make exp

Pre-compiled library files are available in the releases tab (only for Linux x86-64)

Using the library

  1. Include the pluto header in your source file
#include <path to pluto.h> // do #include <pluto.h> if the lib is already installed
  1. Write your source code. An example program which draws a line: Documentation for the library is in src/pluto.h where functions and structures have been commented
#include <stdlib.h>
#include "pluto.h"									/* Change path if needed */

int main()
{
    pluto_init_window();								/* Initialize pluto */
    pluto_save_screen();								/* Save screen */

    for (;;)
    {
    	for (int i = 0; i < _pluto_canvas.cheight; i++)
    	{
	    for (int j = 0; j < _pluto_canvas.cwidth; j++)
	    {
	    	pluto_set_cpix(j, i, rand() % 256, rand() % 256, rand() % 256);		/* Set pixel with random colours */
	    }
    	}

	pluto_write_out();								/* Write to output buffer */
	pluto_render();									/* Render the output buffer */
    }

    pluto_deinit();
    return 0;
}
  1. Link the library generated, for example:
$ gcc -o program program.c -lpluto  # install it before or use -L<lib_folder_path>
  1. You're done! Just run your program now!

Comments in the pluto.h file describe what each function/data structure does

Perlin noise using plutonem


Mandelbrot (examples/mandelbrot.c)


Image rendered using plutonem


A raycaster written with plutonem

Plutonem is tested and works on:

  • Operating systems: Linux, BSD, MacOS, (idk windows cuz cringe)
  • Terminal emulators: XTerm, Termite, Konsole, GNOME-terminal, Alacritty (best performance) and Kitty

Contributing:

  • Bug fixes
  • Features (don't pull request too many files at once)
  • Issue (GitHub issues tab) fixing

Troubleshooting

  1. Check if proper fonts are installed. Pluto uses Unicode characters from U+10240(10) to U+10495(10). I recommend the Cascadia Mono font.
  2. Check if your terminal supports Unicode
  3. Check your locale, lang (pluto only supports UTF-8 currently). I have my locale set to en_US.UTF-8. On Arch Linux, which I use, I would use this command to set it:
# localectl set-locale LANG=en_US.UTF-8
  1. Open an issue in the issues tab, provide your terminal name, what locale it is set to, and your font

plutonem's People

Contributors

ethan4984 avatar mtvare6 avatar pqcraft avatar smart6502 avatar wxwisiasdf 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

Watchers

 avatar  avatar

plutonem's Issues

Missing srand in README.md starter code

It needs srand first before calling multiple rand calls since it will generate same numbers if srand is not called

You can include time.h and add srand(time(NULL))

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.