本文整理汇总了C++中drawPixel函数的典型用法代码示例。如果您正苦于以下问题:C++ drawPixel函数的具体用法?C++ drawPixel怎么用?C++ drawPixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drawPixel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setArea
void MI0283QT9::drawCircle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t color)
{
int16_t err, x, y;
err = -radius;
x = radius;
y = 0;
setArea(0, 0, lcd_width-1, lcd_height-1);
while(x >= y)
{
drawPixel(x0 + x, y0 + y, color);
drawPixel(x0 - x, y0 + y, color);
drawPixel(x0 + x, y0 - y, color);
drawPixel(x0 - x, y0 - y, color);
drawPixel(x0 + y, y0 + x, color);
drawPixel(x0 - y, y0 + x, color);
drawPixel(x0 + y, y0 - x, color);
drawPixel(x0 - y, y0 - x, color);
err += y;
y++;
err += y;
if(err >= 0)
{
x--;
err -= x;
err -= x;
}
}
return;
}
示例2: if
void Button::draw(SDL_Surface* s){
if ((hovered&&!leftDown)||(leftDown&&!hovered)) SDL_FillRect(s,NULL,(foreColour.r<<16)|(foreColour.g<<8)|foreColour.b);
else if ((leftDown&&hovered)||(!leftDown&&!hovered))SDL_FillRect(s,NULL,(backColour.r<<16)|(backColour.g<<8)|backColour.b);
SDL_Color darkborder = {0,0,0,0}, lightborder = {170,170,170,255};
if(hovered&&leftDown){
SDL_Color temp(darkborder);
darkborder = lightborder;
lightborder = temp;
}
//draw a border _bBT thick.
for(int top = 0; top < _bBT; top++) for(int p = top; p <width-top; p++)
drawPixel(s,p,top,lightborder);
for(int bottom = 0; bottom < _bBT; bottom++) for(int p = bottom; p <width-bottom; p++)
drawPixel(s,p,height-bottom-1,darkborder);
for(int left = 0; left < _bBT; left++) for(int p = left; p <height-left; p++)
drawPixel(s,left,p,lightborder);
for(int right = 0; right < _bBT; right++) for(int p = right; p <height-right; p++)
drawPixel(s,width-right-1,p,darkborder);
//draw focus box if focused.
if(focused){
for(int p = _bBT+1; p <width-_bBT-1; p+=2) drawPixel(s,p,_bBT+2,0,0,0);
for(int p = _bBT+1; p <width-_bBT-1; p+=2) drawPixel(s,p,height-_bBT-2,0,0,0);
for(int p = _bBT+1; p <height-_bBT-1; p+=2) drawPixel(s,_bBT+2,p,0,0,0);
for(int p = _bBT+1; p <height-_bBT-1; p+=2) drawPixel(s,width-_bBT-2,p,darkborder);
}
//draw text
drawText(text,width/2,height/2,font,s,textColour.r,textColour.g,
textColour.b,Centered);
}
示例3: while
void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0,
int16_t r, uint8_t cornername, uint16_t color) {
int16_t f = 1 - r;
int16_t ddF_x = 1;
int16_t ddF_y = -2 * r;
int16_t x = 0;
int16_t y = r;
while (x<y) {
if (f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
if (cornername & 0x4) {
drawPixel(x0 + x, y0 + y, color);
drawPixel(x0 + y, y0 + x, color);
}
if (cornername & 0x2) {
drawPixel(x0 + x, y0 - y, color);
drawPixel(x0 + y, y0 - x, color);
}
if (cornername & 0x8) {
drawPixel(x0 - y, y0 + x, color);
drawPixel(x0 - x, y0 + y, color);
}
if (cornername & 0x1) {
drawPixel(x0 - y, y0 - x, color);
drawPixel(x0 - x, y0 - y, color);
}
}
}
示例4: while
// from https://web.archive.org/web/20120225095359/http://homepage.smc.edu/kennedy_john/belipse.pdf
void SmartMatrix::drawEllipse(int16_t x0, int16_t y0, uint16_t radiusX, uint16_t radiusY, const rgb24& color) {
int16_t twoASquare = 2 * radiusX * radiusX;
int16_t twoBSquare = 2 * radiusY * radiusY;
int16_t x = radiusX;
int16_t y = 0;
int16_t changeX = radiusY * radiusY * (1 - (2 * radiusX));
int16_t changeY = radiusX * radiusX;
int16_t ellipseError = 0;
int16_t stoppingX = twoBSquare * radiusX;
int16_t stoppingY = 0;
while (stoppingX >= stoppingY) { // first set of points, y' > -1
drawPixel(x0 + x, y0 + y, color);
drawPixel(x0 - x, y0 + y, color);
drawPixel(x0 - x, y0 - y, color);
drawPixel(x0 + x, y0 - y, color);
y++;
stoppingY += twoASquare;
ellipseError += changeY;
changeY += twoASquare;
if (((2 * ellipseError) + changeX) > 0) {
x--;
stoppingX -= twoBSquare;
ellipseError += changeX;
changeX += twoBSquare;
}
}
// first point set is done, start the second set of points
x = 0;
y = radiusY;
changeX = radiusY * radiusY;
changeY = radiusX * radiusX * (1 - 2 * radiusY);
ellipseError = 0;
stoppingX = 0;
stoppingY = twoASquare * radiusY;
while (stoppingX <= stoppingY) { // second set of points, y' < -1
drawPixel(x0 + x, y0 + y, color);
drawPixel(x0 - x, y0 + y, color);
drawPixel(x0 - x, y0 - y, color);
drawPixel(x0 + x, y0 - y, color);
x++;
stoppingX += twoBSquare;
ellipseError += changeX;
changeX += twoBSquare;
if (((2 * ellipseError) + changeY) > 0) {
y--;
stoppingY -= twoASquare;
ellipseError += changeY;
changeY += twoASquare;
}
}
}
示例5: swapXY
int Graph::bresenham(Point pt1, Point pt2, float r, float g, float b ){
Point p1 = pt1;
Point p2 = pt2;
int x, y, x_end, y_end, p;
int dx = (p2.x - p1.x), dy = (p2.y - p1.y); //for determining sign of slope
bool steep = false;
float m = (float)dy/(float)dx ; //find the slope first
//DPRINT("The slope is %.2f,\tline with color %.2f,%.2f,%.2f\n", m, r,g,b);
bool positive_slope;
if( m >= 0 ) // positive slope
positive_slope = true;
else
positive_slope = false;
if( fabs(m) <= 1 ){ //shallow
steep = false;
}
else{ //steep
steep = true;
swapXY(&p1);
swapXY(&p2);
}
determineStartAndEndPoints(p1, p2, &x, &y, &x_end, &y_end);
//DPRINT("x: %d,\ty: %d,\tx_end: %d,\ty_end:%d\n", x, y, x_end, y_end);
dx = abs(x_end - x);
dy = abs(y_end - y);
//draw first point
if(steep)
drawPixel(y,x,r,g,b);//x and y was swapped before
else
drawPixel(x,y,r,g,b);
p = 2 * dy - dx;
for( ; x < x_end; ){
x++;
if( p >= 0){ // if d1 - d2 >= 0, means d2 is shorter, so advance y one level up
positive_slope? y++:y--;
p = p + 2*dy - 2*dx;
}
else // if d1 - d2 < 0; means d1 is shorter, so no change of y;
p = p + 2*dy;
if(steep)
drawPixel(y,x,r,g,b);//x and y was swapped before
else
drawPixel(x,y,r,g,b);
}
return 0;
}
示例6: drawPixel
void SDLWindow::drawPixel(uint32_t x, uint32_t y, const RGBColor& color)
{
if(mGamma == 1.0)
{
drawPixel(x, y, color.r * 255, color.g * 255, color.b * 255);
}
else
{
drawPixel(x, y,
pow(color.r, mInvGamma) * 255,
pow(color.g, mInvGamma) * 255,
pow(color.b, mInvGamma) * 255
);
}
}
示例7: drawPixel
// drawBitmap() variant w/background for RAM-resident (not PROGMEM) bitmaps.
void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg) {
int16_t i, j, byteWidth = (w + 7) / 8;
uint8_t byte;
for(j=0; j<h; j++) {
for(i=0; i<w; i++ ) {
if(i & 7) byte <<= 1;
else byte = bitmap[j * byteWidth + i / 8];
if(byte & 0x80) drawPixel(x+i, y+j, color);
else drawPixel(x+i, y+j, bg);
}
}
}
示例8: drawCross
/**************************************************************************//**
* @brief Draw a 9 pixel cross
* @param[in] xpos Horizontal position of cross center
* @param[in] ypos Vertical position of cross center
* @param[in] color Color to use for cross
*****************************************************************************/
static void drawCross( uint32_t xpos, uint32_t ypos, uint16_t color )
{
drawPixel( xpos-2, ypos, color );
drawPixel( xpos-1, ypos, color );
drawPixel( xpos, ypos, color );
drawPixel( xpos+1, ypos, color );
drawPixel( xpos+2, ypos, color );
drawPixel( xpos, ypos-2, color );
drawPixel( xpos, ypos-1, color );
drawPixel( xpos, ypos+1, color );
drawPixel( xpos, ypos+2, color );
}
示例9: makeLine
void makeLine (double x1, double y1, double x2, double y2)
{
for (double x = x1; x <= x2; x++)
{
drawPixel (x,(x-x1)/(x2-x1)*(y2-y1) + y1);
}
}
示例10: main
int main ()
{
for (int count = 0; count <= 9; count++)
{
makeLine (count*100,100,(count+1)*100,150);
//makeLine ()
}
for (double x = 0; x <= 1000; x++)
{
drawPixel (x/2,150+20.0*sin(x/5.0));
}
updateGraphics();
std::cout << "Press any key to continue...";
std::cin.get();
std::cout << std::endl;
return 0;
}
示例11: display
void display(void)
{
int i,k;
glColor3f(1.0,1.0,1.0) ;
glClear(GL_COLOR_BUFFER_BIT);
drawAxis () ;
glColor3f( 1,0,0);
for(i=0;i<n;i++)
{
y[i] = 0 ;
for(k=1;k<=i;k++)
{
y[i] += - a[k]*y[i-k] ;
}
for(k=0;k<=i;k++)
{
y[i] += b[k]*U(i-k) ;
}
}
for(i=0;i<n;i++)
drawPixel(i*10,y[i]*1.0);
glFlush();
}
示例12: drawLine
void drawLine(int x1, int y1, int x2, int y2, int color) {
float u, s, v, d1x, d1y, d2x, d2y, m, n;
int x = x1, y = y1;
u = x2-x1;
v = y2-y1;
d1x = d2x = _sign(u);
d1y = _sign(v);
d2y = 0;
m = abs(u);
n = abs(v);
if (m <= n) {
d2x = 0;
d2y = _sign(v);
m = abs(v);
n = abs(u);
}
s = (int)(m/2);
for (int i=0; i<round(m); i++) {
drawPixel(x, y, color);
s += n;
if (s >= m) {
s -= m;
x += d1x;
y += d1y;
} else {
x += d2x;
y += d2y;
}
}
}
示例13: defined
void GxEPD::drawBitmapBM(const uint8_t *bitmap, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color, int16_t mode)
{
uint16_t inverse_color = (color != GxEPD_WHITE) ? GxEPD_WHITE : GxEPD_BLACK;
uint16_t fg_color = (mode & bm_invert) ? inverse_color : color;
uint16_t bg_color = (mode & bm_invert) ? color : inverse_color;
// taken from Adafruit_GFX.cpp, modified
int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
uint8_t byte = 0;
for (int16_t j = 0; j < h; j++)
{
for (int16_t i = 0; i < w; i++ )
{
if (i & 7) byte <<= 1;
else
{
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
byte = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
#else
byte = bitmap[j * byteWidth + i / 8];
#endif
}
// keep using overwrite mode
uint16_t pixelcolor = (byte & 0x80) ? fg_color : bg_color;
uint16_t xd = x + i;
uint16_t yd = y + j;
if (mode & bm_flip_x) xd = x + w - i;
if (mode & bm_flip_y) yd = y + h - j;
drawPixel(xd, yd, pixelcolor);
}
}
}
示例14: drawChar
int16_t drawChar(uint8_t c, int16_t x, int16_t y){
if(c<32 || (c-32) > charcount){
c=127;
}
c-=32;
uint16_t xc, yc;
uint8_t fontSize = 7;
if(x<-fontSize || x> GFX_WIDTH || y<-8 || y>GFX_HEIGHT){
return x+fontSize;
}
for(xc=0;xc<fontSize;xc++){
// uint8_t slice = (big)?font7x8[c][xc]:font5x7[c][xc];
uint8_t slice = font7x8[c][xc];
for(yc=0;yc<8;yc++){
if(slice & (1<<yc)){
drawPixel(x+xc, y+yc);
}
}
}
return x+fontSize;
}
示例15: init_io
/*********************************************************************************************************
** Function name: drawLine
** Descriptions: drawLine
*********************************************************************************************************/
void ePaper::drawLine(int x0, int y0, int x1, int y1)
{
init_io();
int x = x1-x0;
int y = y1-y0;
int dx = abs(x), sx = x0<x1 ? 1 : -1;
int dy = -abs(y), sy = y0<y1 ? 1 : -1;
int err = dx+dy, e2;
for (;;)
{
drawPixel(x0,y0,1);
e2 = 2*err;
if (e2 >= dy)
{
if (x0 == x1) break;
err += dy; x0 += sx;
}
if (e2 <= dx)
{
if (y0 == y1) break;
err += dx; y0 += sy;
}
}
}