本文整理汇总了C++中draw_pixel函数的典型用法代码示例。如果您正苦于以下问题:C++ draw_pixel函数的具体用法?C++ draw_pixel怎么用?C++ draw_pixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_pixel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: labs
void InterpolateVideo::draw_line(VFrame *frame, int x1, int y1, int x2, int y2)
{
int w = labs(x2 - x1);
int h = labs(y2 - y1);
//printf("InterpolateVideo::draw_line 1 %d %d %d %d\n", x1, y1, x2, y2);
if(!w && !h)
{
draw_pixel(frame, x1, y1);
}
else
if(w > h)
{
// Flip coordinates so x1 < x2
if(x2 < x1)
{
y2 ^= y1;
y1 ^= y2;
y2 ^= y1;
x1 ^= x2;
x2 ^= x1;
x1 ^= x2;
}
int numerator = y2 - y1;
int denominator = x2 - x1;
for(int i = x1; i < x2; i++)
{
int y = y1 + (int64_t)(i - x1) * (int64_t)numerator / (int64_t)denominator;
draw_pixel(frame, i, y);
}
}
else
{
// Flip coordinates so y1 < y2
if(y2 < y1)
{
y2 ^= y1;
y1 ^= y2;
y2 ^= y1;
x1 ^= x2;
x2 ^= x1;
x1 ^= x2;
}
int numerator = x2 - x1;
int denominator = y2 - y1;
for(int i = y1; i < y2; i++)
{
int x = x1 + (int64_t)(i - y1) * (int64_t)numerator / (int64_t)denominator;
draw_pixel(frame, x, i);
}
}
//printf("InterpolateVideo::draw_line 2\n");
}
示例2: draw_rect
void draw_rect(int x1, int y1, int width, int height, color_t c) {
int vert =0;
int hori = 0;
for(hori = x1; hori < width+x1; hori++) {
draw_pixel(hori,y1,c);
draw_pixel(hori,y1+height,c);
}
for(vert =y1; vert<height+y1; vert++) {
draw_pixel(x1, vert, c);
draw_pixel(x1+width, vert,c);
}
}
示例3: draw_line
void
draw_line(
color24_t c,
uint32_t x0,
uint32_t y0,
uint32_t x1,
uint32_t y1
)
{
const int32_t dx = abs(x1 - x0);
const int32_t dy = abs(y1 - y0);
const int32_t sx = x0 < x1 ? 1 : -1;
const int32_t sy = y0 < y1 ? 1 : -1;
int32_t err = dx - dy;
#if VSCREEN_SHIFT != 0
uint32_t last_px = -1;
uint32_t last_py = -1;
#endif
while(1)
{
#if VSCREEN_SHIFT != 0
uint32_t px = x0 >> VSCREEN_SHIFT;
uint32_t py = y0 >> VSCREEN_SHIFT;
if (px != last_px || py != last_py)
{
last_px = px;
last_py = py;
draw_pixel(c, x0, y0);
}
#else
draw_pixel(c, x0, y0);
#endif
if (x0 == x1 && y0 == y1)
break;
int32_t e2 = 2 * err;
if (e2 > -dy)
{
err -= dy;
x0 += sx;
}
if (e2 < +dx)
{
err += dx;
y0 += sy;
}
}
}
示例4: draw_rect
void draw_rect(int x1, int y1, int width, int height, color_t c){
int x = 0;
int y = 0;
for(x = x1; x <= width+1; x++){
draw_pixel(x, y1, c);
draw_pixel(x, y1 + height, c);
}
for(y = y1; y <= height+2; y++){
draw_pixel(x1, y, c);
draw_pixel(x1 + width, y, c);
}
}
示例5: memset
bool Pattern_peak_spike::display()
{
#undef LOG_PEAKS
#ifdef LOG_PEAKS
const int max_dots = 64;
char dots[max_dots + 2];
memset(dots, ' ', sizeof(dots));
dots[max_dots] = '|';
dots[max_dots + 1] = '\0';
memset(dots, '.', get_mapped_peak(max_dots));
Serial.printf("peak %5u %s\n", get_peak(), dots);
#endif
Colour c = make_hue(g_hue.get());
int leds = get_mapped_peak(LED_COUNT / 2);
#define FADE_PEAK
#ifdef FADE_PEAK
static Value held_leds(0, 0, LED_COUNT / 2);
held_leds.set_velocity(-10, 60);
if (leds > held_leds.get()) {
held_leds.set(leds);
}
leds = held_leds.get();
#endif
// Start drawing out from the bottom middle both up and horizontally.
int start_x = COLUMN_COUNT / 2;
int start_y = ROW_COUNT - 1;
int x = start_x;
int y = start_y;
for (int led = 0; led < leds; ++led) {
draw_pixel(x, y, c);
draw_pixel(flip_x(x), y, c);
++x;
++y;
if (x >= COLUMN_COUNT || y >= ROW_COUNT) {
--start_y;
if (start_y < 0) {
start_y = 0;
++start_x;
}
x = start_x;
y = start_y;
}
}
return true;
}
示例6: draw_blocks
static void inline draw_blocks(uint8_t blocks[][4]) {
uint8_t i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
if (blocks[i][j]) {
draw_pixel(2*i, j+4, cff5500);
draw_pixel(2*i+1, j+4, cff5500);
} else {
draw_pixel(2*i, j+4, c000000);
draw_pixel(2*i+1, j+4, c000000);
}
}
}
}
示例7: draw_line
/**
* @param surface cíl
* @param x1 počáteční souřadnice úsečky
* @param y1 počáteční souřadnice
* @param x2 koncové souřadnice úsečky
* @param y2 koncové souřadnice úsečky
* @param color barva úsečky
*/
void draw_line(SDL_Surface* surface, int x1, int y1, int x2, int y2, SDL_Color color){
// pres parametrickou rovnici usecky
// kazdy bod Z usecky AB se spocita
// Z = A + (B-A)t
// pro 0<= t <= 1
int length, w=(x2-x1), h=(y2-y1), t;
// length= sqrt(w^2+h^2);
length= w*w + h*h;
for( t=0 ; t*t<length ; ++t); length=t;
// vhodne zdrobnely parametr vykresli dostatecne mnoho pixelu
if(length){
for( t=0 ; t<=length ; ++t )
draw_pixel(surface, x1 + w*t/length, y1 + h*t/length ,color);
} else draw_pixel(surface, x1, y1 ,color);
}
示例8: print_character
void print_character(uint16_t *colour_ptr, uint32_t x, uint32_t y, volatile unsigned char *fb) {
for (int i = 0; i < CHAR_WIDTH; ++i) {
for (int j = 0; j < CHAR_HEIGHT; ++j) {
draw_pixel(x + j, y + i, fb, colour_ptr[j + (i * CHAR_WIDTH)]);
}
}
}
示例9: draw_pixel
void
Canvas::fill_rect(uint8_t x, uint8_t y, uint8_t width, uint8_t height)
{
for (uint8_t i = 0; i < width; i++)
for (uint8_t j = 0; j < height; j++)
draw_pixel(x + i, y + j);
}
示例10: smooth_buffer
void smooth_buffer(struct pixel_buffer* pix) {
int x,y;
for (x = 0; x < pix->width; x++) {
for (y = 0; y < pix->height; y++) {
int left = (x - 1) % pix->width;
int right = (x + 1) % pix->width;
int up = (y - 1) % pix->height;
int down = (y + 1) % pix->height;
if (left < 0) {
left = left + pix->width;
}
if (up < 0) {
up = up + pix->height;
}
Uint32 val = (get_pixel(pix, x, up) + get_pixel(pix, x, down) + get_pixel(pix, left, y) + get_pixel(pix, right, y)) / 4;
draw_pixel(pix, x, y, val);
}
}
}
示例11: fract_j
static void fract_j(t_env *env, t_fract fr)
{
double rn1;
double in1;
double rn;
double in;
int a;
rn1 = 2.0 * (fr.x - env->win_x / 2) / (0.5 * env->zoom * env->win_x) +
env->pos_x;
in1 = (fr.y - env->win_y / 2) / (0.5 * env->zoom * env->win_y) + env->pos_y;
a = -1;
while (++a < (env->iter - 1))
{
rn = rn1;
in = in1;
rn1 = (rn * rn) - (in * in) + fr.rc;
in1 = 2 * rn * in + fr.ic;
if ((rn1 * rn1 + in1 * in1) > 4)
break ;
}
get_color_palette(env, env->color, a, env->pal);
if ((fr.x >= 0 && fr.x < env->win_x) && (fr.y >= 0 && fr.y < env->win_y)
&& a < (env->iter - 1))
draw_pixel(env, fr.x, fr.y, env->color);
}
示例12: draw_wall
static void draw_wall(t_event *e, t_raycast *rc, t_vec2 *p, int line_height)
{
int color;
int id;
if (!e->texture_mode)
{
if (rc->side)
color = rc->step.y > 0 ? 0xff0000 : 0xffff00;
else
color = rc->step.x > 0 ? 0x00ff00 : 0x00ffff;
}
else
{
id = e->game.map[rc->map.y][rc->map.x];
rc->tex.y = (p->y * 2 - e->height + line_height)
* (e->textures[id].height / 2) / line_height;
color = e->textures[id].data[rc->tex.y
* e->textures[id].width + rc->tex.x];
if (rc->side)
color = color_fusion(color, 0x0f0f0f);
else
color = color_fusion(color, 0x1f1f1f);
}
draw_pixel(e, p->x, p->y, color);
free(p);
}
示例13: draw_xy
static inline void draw_xy(int x, int y,
unsigned char r,
unsigned char g,
unsigned char b)
{
draw_pixel(x + centerX, centerY - y, r, g, b);
}
示例14: press_event
void press_event(MouseEvent ev)
{
pressed = true;
draw_pixel(ev.x, ev.y);
last_x = ev.x;
last_y = ev.y;
}
示例15: draw_bitmap
void draw_bitmap(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint16_t *sprite, volatile unsigned char *fb) {
for (int i = 0; i < width; ++i) {
for (int j = 0; j < height; ++j) {
draw_pixel(x + i, y + j, fb, sprite[i + (width * j)]);
}
}
}