Hexpixel Code
From Wikibooks, the open-content textbooks collection
The Hexpixel Code is an easy-to-use language used to create images in text editors using hex triplets.
Contents
|
[edit] Introduction
The reason the language is called The Hexpixel Code is because it is a language (or code) which uses Hex triplets and goes pixel by pixel. With this language, you can create images in Notepad.
[edit] Quick Rules
- ONLY these characters are allowed:
()[]-;=ABCDEFGHIJKLMNOPQRSTUVWXxYZ0123456789
Take note that there are no lowercase letters or spaces except x. - All beginning statements ( or [ must be ended, with a ) or ].
[edit] Starting out
It is time to start. Please read and follow the directions very carefully. Use copy and paste to help you when you see the code boxes because it is very easy to make a simple typo with character mistakes.
- Open Notepad or another text editor.
- Open a small image using a bitmap graphics editor preferably Paint.
- Type the following into your text editor:
(HPC1)
This means Hexpixel Code Version 1. - Find the dimensions of your image. (Width and Height)
- Add
(WIDTHxHEIGHT)
to your text (with no spaces). Now, it should look like this:(HPC1)(WIDTHxHEIGHT)
- Replace WIDTH with the width of your image and replace HEIGHT with the Height of your image.
If your width was 4 and your height was 3, your text should look like this:(HPC1)(4x3)
- Add
(START)
to your text.
[edit] Adding the Pixels/Hex triplets
Read the following instructions to learn how to properly add pixels (Hex triplets) to your text.
- Add
[HC1][HC2][HC3]
etc. to your text. - Replace HC1 with the Hex triplet of the first pixel in the first line of your image.
For example, if the first pixel in the first line was black, you would look it up here (it is #FFFFFF), and you would replace it with HC1. - Replace HC2, HC3, etc. the same way you did with HC1 above.
- Delete the #s in the text.
- When you get to the second line of your image, add a comma to your text then you may go to the second line of your image.
[edit] Ending
Read the following instructions to learn how to properly end the text.
- Add
(END)
to the end of your text after you are done with all the lines and pixels of your image to end. - You are done, but read the rest to make your file smaller, etc.
[edit] Transpareny
Use:
[TRANSP]
or
[NNNNNN]
for transparent pixels. Read further for the variables available for transparent pixels.
[edit] Partial Transparency
Partial transparency support is currently unavailable in Hexpixel Code Version 1 and will/might be available later in version 1 or in version 2, 3, 4, etc.
[edit] Animated Images
Read the following instructions to learn how to properly create animated image files.
- If you have an animated image, after the (WIDTHxHEIGHT and Before the ) in the text, add an A.
- After the A, Add the number of frames your animated image has.
- After the frames count, add a comma to your text and add the frame rate (in seconds) of the Animated Image.
- After the frame rate, write an L and then how many times the animated image loops. If it loops infinite times, put I.
- Normally, the ) will go to end the statement (but don't have two in a row ever).
- When separating between frames, use two commas.
[edit] Variables
Read the following instructions to learn how to properly assign variables and lower the filesize.
- If you use a pixel such as [F0F8FF] more than once, you can assign a variable for it.
- To shorten a pixel such as [F0F8FF] to a variable such as [AB], after the (WIDTHxHEIGHT) and before the (START), add
([AB]=[F0F8FF])
or([F0F8FF]=[AB])
to your text.
[edit] Preassigned Variables
The variables below are variables that are preassigned and will be recognized without assigning them.
[0]=[000000] [F]=[FFFFFF] [W]=[FFFFFF] [B]=[0000FF] [Y]=[FFFF00] [R]=[FF0000] [G]=[00FF00] [V]=[FF00FF] [P]=[FF00FF] [A]=[00FFFF] [C]=[00FFFF] [N]=[NNNNNN] /Transparent [T]=[TRANSP] /Transparent
[edit] Variable Rules
- Anything above six character or below one character variables are not allowed.
- You cannot reassign a pixel or a variable to preassigned variables.
- You cannot assign a variable or preassigned variables to another variable unless they are multiple.
- You may assign multiple pixels and multiple variables to a variable.
- Variables can only have these characters:
ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
If you have a con or a conline you can also have a - or ;.
[edit] Consecutives
Read the following instructions to learn how to properly assign Consective Pixels/Variables (cons).
[edit] Consecutive Pixels and Variables
- If you use a pixel or a variable such as [F0F8FF] more than once in the same Consecutive order, you can shorten it into a conpixvar.
- If you saw a string of pixels (or variables) in an order like this:
[F0F8FF][F0F8FF][F0F8FF][F0F8FF][F0F8FF]
you can shorten the string by deleting those pixels and then adding something like this:[F0F8FF-5]
For each non-conpixvar you can add a -1 within the pixel (or variable) but this is unnecessary because it increases filesize.
[edit] Consecutive Lines
- If you saw a string of pixels (or variables) in an order, like this:
[F0F8FF][0][CADABA][FC0FC0],[F0F8FF][0][CADABA][FC0FC0],[F0F8FF][0][CADABA][FC0FC0]
you can shorten the string by assigning a variable, example:([F0F8FF][0][CADABA][FC0FC0]=[1])
then you can put your three conlines:[1;3],[x-3],[x-3]
- Use the [x] where the conlines assigned pixels.
- When put together, the full text looks something like this:
(HPC1)(4x3)([F0F8FF][0][CADABA][FC0FC0]=[1])(START)[1;3],[x-3],[x-3](END)
- For each non-conline you can add a ;1 within the pixel (or variable) but this is unnecessary because it increases filesize.
[edit] Additional Color Space Support
[edit] RGB
If you know the RGB of a color but not the hex color code, you can:
- Use this website to convert.
- Put the RGB into the pixel format (which increases the filesize):
- Put this in your code:
[RGB]
- Replace R with the red in the color (000-255).
- Replace G with the green in the color (000-255).
- Replace B with the blue in the color (000-255).
- All RGB pixels have exactly 9 characters inside the brackets.
[edit] HSL
If you know the HSL of a color but not the hex color code, you can:
- Convert it to hex using this formula.
- Put the RGB into the pixel format (which increases the filesize):
- Put this in your code:
[xHSL]
- Replace H with the hue in the color (000-360).
- Replace S with the saturation in the color (000-100).
- Replace L with the luminance in the color (000-100).
- All RGB pixels have exactly 10 characters inside the brackets.
[edit] CMYK
If you know the CMYK of a color but not the hex color code, you can:
- Use this website to convert.
- Put the RGB into the pixel format (which increases the filesize):
- Put this in your code:
[CMYK]
- Replace C with the cyan in the color (000-100).
- Replace M with the magenta in the color (000-100).
- Replace Y with the yellow in the color (000-100).
- Replace K with the black in the color (000-100).
- All CMYK pixels have exactly 12 characters inside the brackets.
[edit] Examples
Below are examples to help you.
[edit] One Line
(HPC1)(3x1)(START)[F0F8FF][E32636][FFBF00](END)
[edit] Two Lines
(HPC1)(3x1)(START)[F0F8FF][E32636][FFBF00],[F0F8FF][E32636][FFBF00](END)
[edit] Variables
[edit] One Variable
(HPC1)(3x1)([1]=[F0F8FF])(START)[1][E32636][FFBF00](END)
[edit] Two Variables
(HPC1)(3x1)([1]=[F0F8FF])([AI]=[E32636])(START)[1][AI][FFBF00](END)
[edit] Multivars
(HPC1)(2x1)([F0F8FF][E32636]=[1])(START)[1](END)
[edit] Animated Images
[edit] Animated Images with Loops
(HPC1)(3x1A2,7)(START)[F][F0F8FF][FFBF00],,[0][F0F8FF][FFBF00](END)
[edit] Consecutives
[edit] Consecutive Pixels
(HPC1)(3x1)(START)[E32636-3](END)
[edit] Consecutive Lines
(HPC1)(1x3)(START)[E32636;3],[x],[x](END)
[edit] Consecutive Pixels and Lines
(HPC1)(3x3)(START)[E32636-3;3],[x-3],[x-3](END)
(HPC1)(6x4)(START)[E32636-3;4][G-3],[x-3][F-3],[x-3][0-2][Y],[x-3][G][R][F](END)
[edit] Additional Color Spaces
[edit] RGB
(HPC1)(1x1)(START)[000000000](END)
(HPC1)(1x1)(START)[103255100](END)
[edit] Examples Real-life Images
[edit] Hi.HPC
[edit] Code
(HPC1)(7x3)(START)[0][F][0][F][0-3],[0-3][F-2][0][F],[0][F][0][F][0-3](END)
[edit] Image
[edit] Smiley.HPC
[edit] Code
(HPC1)(12x11)(START)[F-4][0-4][F-4], [F-2][0-2][Y-4][0-2][F-2],[F][0][Y-8][0][F], [F][0][Y-2][0-2][Y-2][0-2][Y][0][F],[0][Y-3][0][Y-2][0][Y-3][0], [0][Y-10][0],[0][Y-2][0][Y-4][0][Y-2][0], [F][0][Y-2][0-4][Y-2][0][F],[F][0][Y-8][0][F], [F-2][0-2][Y-4][0-2][F-2],[F-4][0-4][F-4](END)
[edit] Image
[edit] Authors
- Domthedude001, First author of this Wikibook and creator of the Hexpixel Code.
- All of the other contributors

