Back to Blog
Z88dk cplot color5/4/2023 ![]() If you compiled and ran the example attached to the last article, you should have noticed a console output which looks like this: Last time we build up the basics of the raytracer: some essential math and the corresponding function implementations and structures in the C programming language. We will expand the ray tracer this time to generate actual graphics and to generate these images with multiple spheres, light sources, and reflections. Not super exciting, I know, but it verifies the correctness of our ray/sphere intersect function. Let's take this one step further and create an actuall graphic which you can open in an image viewer.Ĭomputer images are built up out of pixels (picture elements). You need to recompile the z80.lib library with USEFLOATS1 set in printflarge.c. The Amstrad CPC has three video modes : 'Mode 0' 160×200 pixels with 16 colors, 'Mode 1' 320×200 pixels with 4 colors and 'Mode 2' 640×200 pixels with 2 colors. ![]() Each pixel can represent any colour made up from the three primary colours red, green and blue. Assuming you use the SDCC backend: SDCCs printf does not include float support by default. When we say that an image is '24-bit colour', we mean that each pixel is built up out of 3 values, each 8 bit long. In this way, we can let the red, green and blue component vary in value between 0 and 255 because. Suppose we want to programatically create the Finnish flag: With 24 bit colour, we have enough to represent over 16.7 million colours. The first thing we need to do is agree on the format we're going to use. There are many image formats such as jpeg, png, gif, etc. Most of these are quite complex to generate unless you use existing libraries. For this tutorial however, we will use something very simple: the ppm (portable pixmap) format. ![]() Width of the image, ASCII decimal representation.A "magic number" identifying the file type, in our case this will be "P6".The PPM format has the following components (also called the header) needed for the file to be identified and displayed correctly by the image viewer: The ppm format is a simple uncompressed format from the Netpbm family of image formats. If X is a matrix, one line per column is created (Y&C should match its size then) Colors are interpolated according to current colormap & caxis. Maximum colour value, ASCII decimal representation.Height of the image, ASCII decimal representation. function hcplot(x,y,varargin) CPLOT colored linear plot CPLOT(X,Y,C) plots a line (Y vs.
0 Comments
Read More
Leave a Reply. |