C how to draw a point / set a pixel without using graphics library or any other library functions

前端 未结 3 1307
无人共我
无人共我 2020-12-31 20:33

I am trying to understand how I can draw a set of points (/set the pixels) that form a circle without using the library functions.

Now, getting the (x,y) co-ordinat

3条回答
  •  伪装坚强ぢ
    2020-12-31 20:59

    I have a file that takes advantage of unicode braille.

    #include 
    #include 
    #include 
    
    #define PIXEL_TRUE 1
    #define PIXEL_FALSE 0
    
    // Core Function.
    void drawBraille(int type) {
      if(type > 255) {
        return;
      }
      setlocale(LC_CTYPE, "");
      wchar_t c = 0x2800 + type;
      wprintf(L"%lc", c);
    }
    
    /*
      Pixel Array.
      0x01, 0x08,
      0x02, 0x10,
      0x04, 0x20,
      0x40, 0x80,
    */
    
    int pixelArr[8] = {
      0x01, 0x08,
      0x02, 0x10,
      0x04, 0x20,
      0x40, 0x80
    };
    
    typedef int cell[8];
    
    void drawCell(cell cell) {
      int total;
      for(int i = 0; i < 8; i++) {
        if(cell[i] == 1) {
          total += pixelArr[i];
        }
      }
      drawBraille(total);
    }
    
    // Main.
    int main(void) {
      cell a = {
        0, 1,
        0, 0, 
        1, 1,
        0, 1
      };
      drawCell(a);
    return 0;
    }
    

    You're Welcome!

提交回复
热议问题