- Read black & white image file
- Read header
- Width
- Height
- Read header
- Read a horizontal line in the image file
- If pixel is black
- Make the pen touch the paper
- Make a rectangular/circular motion (depends on the writing tool)
- Move pen back up
- Move motor right by a tiny amount (one pixel)
- If pixel is black
- If there is another line, move the motor down one pixel, and back to the left by [width] pixels
- Go back to the instruction
Read a horizontal...
until all lines have been read
Code: Select all
ReadFileHeader("filename.pic", &width, &height);
for(y = 0; y < height; ++y)
{
for(x = 0; x < width; ++x)
{
if(ReadFileNextByte() == BLACK)
{
MovePen(DOWN);
MoveHand(CIRCLE_MOTION);
MovePen(UP);
}
MoveHand(RIGHT, 1);
}
MoveHand(LEFT, width);
MoveHand(DOWN, 1);
}