浏览代码

* Implemented cucul_get_color().

tags/v0.99.beta14
Sam Hocevar sam 18 年前
父节点
当前提交
81760312af
共有 2 个文件被更改,包括 28 次插入0 次删除
  1. +27
    -0
      cucul/colour.c
  2. +1
    -0
      cucul/cucul.h

+ 27
- 0
cucul/colour.c 查看文件

@@ -108,6 +108,33 @@ int cucul_set_truecolor(cucul_canvas_t *cv, unsigned int fg, unsigned int bg)
return 0;
}

/** \brief Get the colour pair at the given coordinates.
*
* This function gets the internal \e libcucul colour pair value of the
* character at the given coordinates. The colour pair value has 32
* significant bits: the lower 16 are for the foreground colour, the higher
* 16 are for the background.
*
* If the coordinates are outside the canvas boundaries, the current colour
* pair is returned.
*
* This function never fails.
*
* \param cv A handle to the libcucul canvas.
* \param x X coordinate.
* \param y Y coordinate.
* \param ch The requested colour pair value.
* \return The character always returns 0.
*/
unsigned long int cucul_get_color(cucul_canvas_t *cv, int x, int y)
{
if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height)
return ((uint32_t)cv->bgcolor << 16) | (uint32_t)cv->fgcolor;

return (unsigned long int)cv->attr[x + y * cv->width];
}


/*
* XXX: the following functions are local
*/


+ 1
- 0
cucul/cucul.h 查看文件

@@ -99,6 +99,7 @@ int cucul_free_buffer(cucul_buffer_t *);
* @{ */
int cucul_set_color(cucul_canvas_t *, unsigned char, unsigned char);
int cucul_set_truecolor(cucul_canvas_t *, unsigned int, unsigned int);
unsigned long int cucul_get_color(cucul_canvas_t *, int, int);
char const *cucul_get_color_name(unsigned int);
int cucul_putchar(cucul_canvas_t *, int, int, unsigned long int);
unsigned long int cucul_getchar(cucul_canvas_t *, int, int);


正在加载...
取消
保存