void Number::drawNumber(float wsize, float hsize, float x, float y, int num, int length) { bool firstNotNull=false; short digit=0; for(int i=length; i--;) { if(i) digit=(num/(int)pow(10,i))%10; else digit=num%10; if(!digit && !firstNotNull) { drawDigit(wsize,hsize,x+10-i,y,10); } else { drawDigit(wsize,hsize,x+10-i,y,digit); firstNotNull=true; } } }
void Hud::draw(int lifes) { glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(0.3,0,0); drawDigit(cent); glTranslatef(2.1,0,0); drawDigit(dez); glTranslatef(2.4,0,0); drawDigit(uni); glTranslatef(15.5, 2.5, 0); glColor3f(1.0, 1.0, 0.0); //drawDigit(lifes); drawLifes(lifes); glPopMatrix(); }
void QLCDNumber::drawString( const QString &s, QPainter &p, QBitArray *newPoints, bool newString ) { if ( isVisible() ) { QPoint pos; int digitSpace = smallPoint ? 2 : 1; int xSegLen = width()*5/(ndigits*(5 + digitSpace) + digitSpace); int ySegLen = height()*5/12; int segLen = ySegLen > xSegLen ? xSegLen : ySegLen; int xAdvance = segLen*( 5 + digitSpace )/5; int xOffset = ( width() - ndigits*xAdvance + segLen/5 )/2; int yOffset = ( height() - segLen*2 )/2; for ( int i=0; i<ndigits; i++ ) { pos = QPoint( xOffset + xAdvance*i, yOffset ); if ( newString ) drawDigit( pos, p, segLen, s[i], digitStr[i].latin1() ); else drawDigit( pos, p, segLen, s[i]); if ( newPoints ) { char newPoint = newPoints->testBit(i) ? '.' : ' '; if ( newString ) { char oldPoint = points.testBit(i) ? '.' : ' '; drawDigit( pos, p, segLen, newPoint, oldPoint ); } else { drawDigit( pos, p, segLen, newPoint ); } } } } if ( newString ) { digitStr = s; if ( (int)digitStr.length() > ndigits ) digitStr.truncate( ndigits ); if ( newPoints ) points = *newPoints; } }
int main(void) { // Setup // init I/Os DDRB |= (1 << PB1) | (1 << PB2) | (1 << PB3) | (1 << PB4) | (1 << PB0); PORTB |= (1 << PB1) | (1 << PB2) | (1 << PB3) | (1 << PB4) | (1 << PB0); // clear framebuffer for (uint8_t i = 0; i < 64; i++) { framebuffer[i] = 0x00; } drawDigit(0,0); drawDigit(0,1); drawDigit(0,2); drawDigit(0,3); drawBlinker(1); // Loop while (1) { // scan all rows uint8_t rowAddr = 1; //uint8_t bufferPos = 0; uint8_t* p = &framebuffer[0]; // On for (char row = 0; row < 8; row++) { for (char bank = 3; bank >= 0; bank--) { // set a pixel bank MODE_B; clock_byte_lsb_first(bank); // load 16 pixels per board MODE_A; STROBE_HIGH; clock_byte_lsb_first(p[1]); clock_byte_lsb_first(p[0]); _delay_us(25); p += 2; } // select row MODE_B; clock_byte_lsb_first(rowAddr); STROBE_LOW; MODE_A; rowAddr = rowAddr << 1; } } return 0; }
/// images are always SD PAL progressive full res images for the purpose of this example only MyImage::MyImage(MyClipInstance &clip, OfxTime time, int view) : OFX::Host::ImageEffect::Image(clip) /// this ctor will set basic props on the image , _data(NULL) { // make some memory _data = new OfxRGBAColourB[kPalSizeXPixels * kPalSizeYPixels] ; /// PAL SD RGBA int fillValue = (int)(floor(255.0 * (time/OFXHOSTDEMOCLIPLENGTH))) & 0xff; OfxRGBAColourB color; #ifdef OFX_EXTENSIONS_VEGAS color.r = view == 0 ? fillValue : 0; color.g = view == 1 ? fillValue : 0; color.b = view == 1 ? fillValue : 0; #else color.r = color.g = color.b = fillValue; #endif color.a = 255; std::fill(_data, _data + kPalSizeXPixels * kPalSizeYPixels, color); // draw the time and the view number in reverse color const int scale = 5; const int charwidth = 4*scale; #ifdef OFX_EXTENSIONS_VEGAS color.r = view == 0 ? 255-fillValue : 0; color.g = view == 1 ? 255-fillValue : 0; color.b = view == 1 ? 255-fillValue : 0; #else color.r = color.g = color.b = 255-fillValue; #endif int xx = 50; int yy = 50; int d; d = (int(time)/10)%10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); xx += charwidth; d = int(time)%10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); xx += charwidth; d = 10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); xx += charwidth; d = int(time*10)%10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); xx = 50; yy += 8*scale; d = int(view)%10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); // render scale x and y of 1.0 setDoubleProperty(kOfxImageEffectPropRenderScale, 1.0, 0); setDoubleProperty(kOfxImageEffectPropRenderScale, 1.0, 1); // data ptr setPointerProperty(kOfxImagePropData,_data); // bounds and rod setIntProperty(kOfxImagePropBounds, kPalRegionPixels.x1, 0); setIntProperty(kOfxImagePropBounds, kPalRegionPixels.y1, 1); setIntProperty(kOfxImagePropBounds, kPalRegionPixels.x2, 2); setIntProperty(kOfxImagePropBounds, kPalRegionPixels.y2, 3); setIntProperty(kOfxImagePropRegionOfDefinition, kPalRegionPixels.x1, 0); setIntProperty(kOfxImagePropRegionOfDefinition, kPalRegionPixels.y1, 1); setIntProperty(kOfxImagePropRegionOfDefinition, kPalRegionPixels.x2, 2); setIntProperty(kOfxImagePropRegionOfDefinition, kPalRegionPixels.y2, 3); // row bytes setIntProperty(kOfxImagePropRowBytes, kPalSizeXPixels * sizeof(OfxRGBAColourB)); }
void CFreqDisplay::setFrequency(const CFrequency& frequency) { wxInt64 hz = frequency.get(); // Only display to 10 Hz if ((m_lastFrequency.get() / 10LL) == (hz / 10LL)) return; clearGraph(); wxMemoryDC memoryDC; memoryDC.SelectObject(*m_bitmap); int mhzDigits = m_mhzDigits; if (mhzDigits == 0) { mhzDigits = 1; if (hz >= 10000000000LL) // 10 GHz mhzDigits = 5; else if (hz >= 1000000000LL) // 1000 MHz mhzDigits = 4; else if (hz >= 100000000LL) // 100 MHz mhzDigits = 3; else if (hz >= 10000000LL) // 10 MHz mhzDigits = 2; } const int bigThickness = 5; const int littleThickness = 4; int bigHeight = m_height - 2 * BORDER_SIZE; int littleHeight = 3 * bigHeight / 4; int bigWidth = (m_width - 2 * BORDER_SIZE) / (mhzDigits + 5); int littleWidth = 3 * bigWidth / 4; int bigY = BORDER_SIZE; int littleY = (bigHeight + BORDER_SIZE) - littleHeight; int x = BORDER_SIZE + (mhzDigits + 4) * bigWidth; wxInt64 rem = hz / 10LL; drawDigit(memoryDC, littleWidth, littleHeight, littleThickness, x, littleY, rem % 10LL, false); x -= littleWidth; rem /= 10LL; drawDigit(memoryDC, littleWidth, littleHeight, littleThickness, x, littleY, rem % 10LL, false); x -= bigWidth; rem /= 10LL; drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, false); x -= bigWidth; rem /= 10LL; drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, false); x -= bigWidth; rem /= 10LL; drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, true); x -= bigWidth; rem = hz / 1000000LL; for (int i = 0; i < mhzDigits; i++) { wxInt64 n = rem % 10LL; rem /= 10LL; if (rem != 0LL || (rem == 0LL && n != 0LL)) drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, n, false); x -= bigWidth; } memoryDC.SelectObject(wxNullBitmap); wxClientDC clientDC(this); show(clientDC); m_lastFrequency = frequency; }