void drawLegend() { GLubyte red[] = {15, 231, 76, 60}; //oxygen GLubyte green[] = {20, 39, 174, 96}; //carbon GLubyte blue[] = {20, 52, 152, 219}; //nitrogen GLubyte yellow[] = {10, 241, 196, 15}; //hydrogen drawAtom(50, 170, 0, yellow); glColor3ub(52, 73, 94); output(100, 168, "Hydrogen", fonts[0]); drawAtom(50, 135, 0, red); glColor3ub(52, 73, 94); output(100, 133, "Oxygen", fonts[0]); drawAtom(50, 90, 0, blue); glColor3ub(52, 73, 94); output(100, 88, "Nitrogen", fonts[0]); drawAtom(50, 40, 0, green); glColor3ub(52, 73, 94); output(100, 38, "Carbon", fonts[0]); glColor3ub(52, 73, 94); glLineWidth(1.25); glBegin(GL_LINE_STRIP); glVertex3f(0, 200, 0); glVertex3f(200, 200, 0); glVertex3f(200, 0, 0); glEnd(); }
foreach ( Atom atom, atomList ) { if ( atom.column > column ) { // Switch to next column if ( mEqualColumnWidth ) { point.rx() += mColumnSpace + maxColumnWidth; } else { point.rx() += mColumnSpace + columnWidth; } point.ry() = columnTop; columnWidth = 0; column++; firstInColumn = true; } // Add space if necessary, unfortunately it depends on first nucleon if ( !firstInColumn ) { point.ry() += spaceAboveAtom( atom ); } drawAtom( atom, painter, point ); columnWidth = qMax( atom.size.width(), columnWidth ); point.ry() += atom.size.height(); columnMaxHeight = qMax( point.y() - columnTop, columnMaxHeight ); firstInColumn = false; }
foreach ( Atom atom, atomList ) { if ( atom.column > column ) { // Switch to next column if ( mEqualColumnWidth ) { point.rx() += mColumnSpace + maxColumnWidth; } else { point.rx() += mColumnSpace + columnWidth; } point.ry() = columnTop; columnWidth = 0; column++; firstInColumn = true; } if ( !firstInColumn ) { point.ry() += spaceAboveAtom( atom ); } QSizeF atomSize = drawAtom( atom, painter, point ); columnWidth = qMax( atomSize.width(), columnWidth ); point.ry() += atom.size.height(); columnMaxHeight = qMax( point.y() - columnTop, columnMaxHeight ); firstInColumn = false; }
void draw(GAME game) { int x,y; int hs,vs; //horizontal and vertical shift, maps game to gl coordinates hs=-game.width/2; vs=-game.height/2+1; glLoadIdentity(); for(x=0;x<game.width;++x){ for(y=0;y<game.height;++y){ drawAtom(game.field[game.height*x+y],x+hs,y+vs); } } if(game.piece!='\0'){ drawPiece(game.piece,game.x+hs,game.y+vs,game.rot); } drawFrame(game.width,game.height,hs,vs); }
void LaboratoryScreen::drawMolecule(MoleculeInstance * m) { glPushMatrix(); glScalef(m->scale, m->scale, m->scale); glRotatef(m->rotation.x, 1, 0, 0); glRotatef(m->rotation.y, 0, 1, 0); glRotatef(m->rotation.z, 0, 0, 1); glTranslatef(m->position.x, m->position.y, m->position.z); for (auto atomInstance : m->atomInstances) drawAtom(atomInstance); glLineWidth(lineWidth[1]); for (auto ab : m->atomBindingInstances) { drawAtomBinding(ab); } glPopMatrix(); }
void cytosineGuanine() { float hex1[6][2], hex2[6][2]; float rx=512; //radius and color declarations GLubyte red[] = {15, 231, 76, 60}; //oxygen GLubyte green[] = {20, 39, 174, 96}; //carbon GLubyte blue[] = {20, 52, 152, 219}; //nitrogen GLubyte yellow[] = {10, 241, 196, 15}; //hydrogen getHexagonPoints(hex1, -192, 350, 75); getHexagonPoints(hex2, 192, 350, 75); glPushMatrix(); glTranslatef(rx, 0, 0); glRotatef(theta, 0.0, 1.0, 0.0); //hexagon 1 drawAtom(hex1[0][0], hex1[0][1], 0, green); drawAtom(hex1[1][0], hex1[1][1], 0, blue); drawAtom(hex1[2][0], hex1[2][1], 0, green); drawAtom(hex1[3][0], hex1[3][1], 0, green); drawAtom(hex1[4][0], hex1[4][1], 0, green); drawAtom(hex1[5][0], hex1[5][1], 0, blue); drawBondLine(hex1[0][0],hex1[0][1],0, hex1[1][0],hex1[1][1],0); drawBondLine(hex1[1][0],hex1[1][1],0, hex1[2][0],hex1[2][1],0); drawBondLine(hex1[2][0],hex1[2][1],0, hex1[3][0],hex1[3][1],0); drawBondLine(hex1[3][0],hex1[3][1],0, hex1[4][0],hex1[4][1],0); drawBondLine(hex1[4][0],hex1[4][1],0, hex1[5][0],hex1[5][1],0); drawBondLine(hex1[5][0],hex1[5][1],0, hex1[0][0],hex1[0][1],0); drawAtom(hex1[0][0], hex1[0][1]-50, 0, red); drawBondLine(hex1[0][0],hex1[0][1],0, hex1[0][0],hex1[0][1]-50,0); drawAtom(hex1[2][0]+50, hex1[2][1]+25, -50, blue); drawBondLine(hex1[2][0],hex1[2][1],0, hex1[2][0]+50,hex1[2][1]+25,-50); drawAtom(hex1[2][0]+50,hex1[2][1]+67.5, -50, yellow); drawBondLine(hex1[2][0]+50,hex1[2][1]+25,-50, hex1[2][0]+50,hex1[2][1]+67.5,-50); drawAtom(hex1[2][0]+85,hex1[2][1],-50, yellow); drawBondLine(hex1[2][0]+50,hex1[2][1]+25,-50, hex1[2][0]+85,hex1[2][1],-50); drawAtom(hex1[3][0],hex1[3][1]+25, -50, yellow); drawBondLine(hex1[3][0],hex1[3][1],0, hex1[3][0],hex1[3][1]+25,-50); drawAtom(hex1[4][0]-15,hex1[4][1]+15, 50, yellow); drawBondLine(hex1[4][0],hex1[4][1],0, hex1[4][0]-15,hex1[4][1]+15,50); //hexagon 2 drawAtom(hex2[0][0], hex2[0][1], 0, blue); drawAtom(hex2[1][0], hex2[1][1], 0, green); drawAtom(hex2[2][0], hex2[2][1], 0, green); drawAtom(hex2[3][0], hex2[3][1], 0, green); drawAtom(hex2[4][0], hex2[4][1], 0, blue); drawAtom(hex2[5][0], hex2[5][1], 0, green); drawBondLine(hex2[0][0],hex2[0][1],0, hex2[1][0],hex2[1][1],0); drawBondLine(hex2[1][0],hex2[1][1],0, hex2[2][0],hex2[2][1],0); drawBondLine(hex2[2][0],hex2[2][1],0, hex2[3][0],hex2[3][1],0); drawBondLine(hex2[3][0],hex2[3][1],0, hex2[4][0],hex2[4][1],0); drawBondLine(hex2[4][0],hex2[4][1],0, hex2[5][0],hex2[5][1],0); drawBondLine(hex2[5][0],hex2[5][1],0, hex2[0][0],hex2[0][1],0); drawAtom(hex2[1][0]+50, hex2[0][1]+25, 50, blue); drawBondLine(hex2[1][0],hex2[1][1],0, hex2[1][0]+50,hex2[0][1]+25,50); drawAtom(hex2[2][0]+50, hex2[3][1]-25, 50, blue); drawBondLine(hex2[2][0],hex2[2][1],0, hex2[2][0]+50,hex2[3][1]-25,50); drawAtom(hex2[2][0]+100,hex2[2][1]-37.5,75, green); drawBondLine(hex2[1][0]+50, hex2[0][1]+25, 50, hex2[2][0]+100,hex2[2][1]-37.5,75); drawBondLine(hex2[2][0]+50, hex2[3][1]-25, 50, hex2[2][0]+100,hex2[2][1]-37.5,75); drawAtom(hex2[2][0]+142.5,hex2[2][1]-37.5,75, yellow); drawBondLine(hex2[2][0]+100,hex2[2][1]-37.5,75, hex2[2][0]+142.5,hex2[2][1]-37.5,75); drawAtom(hex2[3][0], hex2[3][1]+50, 0, red); drawBondLine(hex2[3][0],hex2[3][1],0, hex2[3][0],hex2[3][1]+50,0); drawAtom(hex2[4][0]-25, hex2[4][1]+25, 0, yellow); drawBondLine(hex2[4][0],hex2[4][1],0, hex2[4][0]-25,hex2[4][1]+25,0); drawAtom(hex2[5][0]-50, hex2[0][1]+25, 50, blue); drawBondLine(hex2[5][0],hex2[5][1],0, hex2[5][0]-50,hex2[0][1]+25,50); drawAtom(hex2[5][0]-50, hex2[0][1]-15, 50, yellow); drawBondLine(hex2[5][0]-50,hex2[0][1]+25,50, hex2[5][0]-50,hex2[0][1]-15,50); drawAtom(hex2[5][0]-85, hex2[0][1]+60, 50, yellow); drawBondLine(hex2[5][0]-50,hex2[0][1]+25,50, hex2[5][0]-85,hex2[0][1]+60,50); //H-bonds glLineWidth(1.5); glBegin(GL_LINES); glVertex3f(hex1[0][0],hex1[0][1]-50,0); glVertex3f(hex2[5][0]-85,hex2[0][1]+60,50); glVertex3f(hex1[1][0],hex1[1][1],0); glVertex3f(hex2[4][0]-25,hex2[4][1]+25,0); glVertex3f(hex1[2][0]+85,hex1[2][1],-50); glVertex3f(hex2[3][0],hex2[3][1]+50,0); glEnd(); glTranslatef(-rx, 0, 0); glPopMatrix(); theta+=0.25; drawLegend(); glColor3ub(52, 73, 94); output(300, 190, "Cytosine recognizes specific DNA sequences and catalyzes", fonts[2]); output(300, 170, "the transfer of a methyl group.", fonts[2]); output(300, 130, "Guanine can carry energy and if bound to special receptors,", fonts[2]); output(300, 110, "can help carry signals from one part of the cell to another.", fonts[2]); }
void adenineThymine() { float hex1[6][2], hex2[6][2]; float rx=512; //radius and colors declarations GLubyte red[] = {15, 231, 76, 60}; //oxygen GLubyte green[] = {20, 39, 174, 96}; //carbon GLubyte blue[] = {20, 52, 152, 219}; //nitrogen GLubyte yellow[] = {10, 241, 196, 15}; //hydrogen getHexagonPoints(hex1, -128, 350, 75); getHexagonPoints(hex2, 128, 350, 75); glPushMatrix(); glTranslatef(rx, 0, 0); glRotatef(theta, 0.0, 1.0, 0.0); //hexagon 1 drawAtom(hex1[0][0], hex1[0][1], 0, green); drawAtom(hex1[1][0], hex1[1][1], 0, blue); drawAtom(hex1[2][0], hex1[2][1], 0, green); drawAtom(hex1[3][0], hex1[3][1], 0, green); drawAtom(hex1[4][0], hex1[4][1], 0, green); drawAtom(hex1[5][0], hex1[5][1], 0, blue); drawBondLine(hex1[0][0],hex1[0][1],0, hex1[1][0],hex1[1][1],0); drawBondLine(hex1[1][0],hex1[1][1],0, hex1[2][0],hex1[2][1],0); drawBondLine(hex1[2][0],hex1[2][1],0, hex1[3][0],hex1[3][1],0); drawBondLine(hex1[3][0],hex1[3][1],0, hex1[4][0],hex1[4][1],0); drawBondLine(hex1[4][0],hex1[4][1],0, hex1[5][0],hex1[5][1],0); drawBondLine(hex1[5][0],hex1[5][1],0, hex1[0][0],hex1[0][1],0); drawAtom(hex1[0][0], hex1[0][1]-50, 0, red); drawBondLine(hex1[0][0],hex1[0][1],0, hex1[0][0],hex1[0][1]-50,0); drawAtom(hex1[1][0]+15, hex1[1][1]-15, -50, yellow); drawBondLine(hex1[1][0],hex1[1][1],0, hex1[1][0]+15,hex1[1][1]-15,-50); drawAtom(hex1[2][0]+40, hex1[2][1]+40, 0, red); drawBondLine(hex1[2][0],hex1[2][1],0, hex1[2][0]+40,hex1[2][1]+40,0); drawAtom(hex1[3][0], hex1[3][1]+50, 0, green); drawBondLine(hex1[3][0],hex1[3][1],0, hex1[3][0],hex1[3][1]+50,0); drawAtom(hex1[3][0], hex1[3][1]+75, 50, yellow); drawBondLine(hex1[3][0],hex1[3][1]+50,0, hex1[3][0],hex1[3][1]+75,50); drawAtom(hex1[3][0]+35, hex1[3][1]+75, -35, yellow); drawBondLine(hex1[3][0],hex1[3][1]+50,0, hex1[3][0]+35,hex1[3][1]+75,-35); drawAtom(hex1[3][0]-35, hex1[3][1]+75, -35, yellow); drawBondLine(hex1[3][0],hex1[3][1]+50,0, hex1[3][0]-35,hex1[3][1]+75,-35); drawAtom(hex1[4][0]-15,hex1[4][1]+15, 50, yellow); drawBondLine(hex1[4][0],hex1[4][1],0, hex1[4][0]-15,hex1[4][1]+15,50); //hexagon 2 drawAtom(hex2[0][0], hex2[0][1], 0, blue); drawAtom(hex2[1][0], hex2[1][1], 0, green); drawAtom(hex2[2][0], hex2[2][1], 0, green); drawAtom(hex2[3][0], hex2[3][1], 0, green); drawAtom(hex2[4][0], hex2[4][1], 0, blue); drawAtom(hex2[5][0], hex2[5][1], 0, green); drawBondLine(hex2[0][0],hex2[0][1],0, hex2[1][0],hex2[1][1],0); drawBondLine(hex2[1][0],hex2[1][1],0, hex2[2][0],hex2[2][1],0); drawBondLine(hex2[2][0],hex2[2][1],0, hex2[3][0],hex2[3][1],0); drawBondLine(hex2[3][0],hex2[3][1],0, hex2[4][0],hex2[4][1],0); drawBondLine(hex2[4][0],hex2[4][1],0, hex2[5][0],hex2[5][1],0); drawBondLine(hex2[5][0],hex2[5][1],0, hex2[0][0],hex2[0][1],0); drawAtom(hex2[1][0]+50, hex2[0][1]+25, 50, blue); drawBondLine(hex2[1][0],hex2[1][1],0, hex2[1][0]+50,hex2[0][1]+25,50); drawAtom(hex2[2][0]+50, hex2[3][1]-25, 50, blue); drawBondLine(hex2[2][0],hex2[2][1],0, hex2[2][0]+50,hex2[3][1]-25,50); drawAtom(hex2[2][0]+100,hex2[2][1]-37.5,75, green); drawBondLine(hex2[1][0]+50, hex2[0][1]+25, 50, hex2[2][0]+100,hex2[2][1]-37.5,75); drawBondLine(hex2[2][0]+50, hex2[3][1]-25, 50, hex2[2][0]+100,hex2[2][1]-37.5,75); drawAtom(hex2[2][0]+142.5,hex2[2][1]-37.5,75, yellow); drawBondLine(hex2[2][0]+100,hex2[2][1]-37.5,75, hex2[2][0]+142.5,hex2[2][1]-37.5,75); drawAtom(hex2[3][0], hex2[3][1]+50, 0, blue); drawBondLine(hex2[3][0],hex2[3][1],0, hex2[3][0],hex2[3][1]+50,0); drawAtom(hex2[3][0], hex2[3][1]+75, 50, yellow); drawBondLine(hex2[3][0], hex2[3][1]+50,0, hex2[3][0],hex2[3][1]+75,50); drawAtom(hex2[3][0], hex2[3][1]+75, -50, yellow); drawBondLine(hex2[3][0],hex2[3][1]+50,0, hex2[3][0],hex2[3][1]+75,-50); drawAtom(hex2[5][0]-30,hex2[5][1]-30, 0, yellow); drawBondLine(hex2[5][0],hex2[5][1],0, hex2[5][0]-30,hex2[5][1]-30,0); //H-bonds glLineWidth(1.5); glBegin(GL_LINES); glVertex3f(hex1[2][0]+40,hex1[2][1]+40,0); glVertex3f(hex2[3][0], hex2[3][1]+75, 50); glVertex3f(hex1[1][0]+15, hex1[1][1]-15, -50); glVertex3f(hex2[4][0],hex2[4][1],0); glEnd(); glTranslatef(-rx, 0, 0); glPopMatrix(); theta+=0.25; drawLegend(); glColor3ub(52, 73, 94); output(300, 190, "Adenine is a nucleobase which plays a major role in", fonts[2]); output(300, 170, "cellular respiration and is rich in adenosine.", fonts[2]); output(300, 130, "Thymine is a pyrimidine nucleobase and it", fonts[2]); output(300, 110, "assists in stabalizing the nucleic acid structures.", fonts[2]); }