void Snake::paint(QPainter *painter){ painter->setBrush(getFillColor()); painter->setPen(getOutlineColor()); for(int k = 0; k < parts.count(); k++){ parts.at(k)->paint(painter); } }
void DisplayGrid::draw(sf::RenderTarget &target, sf::RenderStates states) const { int amtX = obsMap->getWidth(); int amtY = obsMap->getHeight(); int sizeX = getSize().x; int sizeY = getSize().y; int tileX, tileY; sf::Vector2f tileSize(sizeX / amtX, sizeY / amtY); sf::RectangleShape tile(tileSize); sf::Vector2f pos = getPosition(); for (int x = 0; x < amtX; x++) { for (int y = 0; y < amtY; y++) { tileX = pos.x + tileSize.x * x; tileY = pos.y + tileSize.y * y; tile.setPosition(tileX, tileY); tile.setFillColor(getTileColor(obsMap->at(x, y))); tile.setOutlineColor(getOutlineColor()); tile.setOutlineThickness(getOutlineThickness()); target.draw(tile); } } }
void RectangleShape::draw() { if (!_device->isInitialized() || !_visible) return; updateTransform(); if (_color.a > 0) { ShaderProgram::setUniform(UNIFORM_MODELVIEW_NAME, getCombinedTransform()); #ifdef _3DS auto vertices = VertexPool::getInstance()-> pushVertices<VertexPositionTexture>(4); vertices[0].position = Vec2(0, 0); vertices[1].position = Vec2(_size.x, 0); vertices[2].position = Vec2(0, _size.y); vertices[3].position = Vec2(_size.x, _size.y); vertices[0].texcoord = Vec2::Zero; vertices[1].texcoord = Vec2::Zero; vertices[2].texcoord = Vec2::Zero; vertices[3].texcoord = Vec2::Zero; //========================================================================= GPU_SetTexEnv(0, GPU_TEVSOURCES(GPU_CONSTANT, GPU_CONSTANT, GPU_CONSTANT), GPU_TEVSOURCES(GPU_CONSTANT, GPU_CONSTANT, GPU_CONSTANT), GPU_TEVOPERANDS(0, 0, 0), GPU_TEVOPERANDS(0, 0, 0), GPU_REPLACE, GPU_REPLACE, _color.r | _color.g << 8 | _color.b << 16 | _color.a << 24); u32 bufferOffsets[] = { 0x00 }; u64 bufferPermutations[] = { 0x10 }; u8 bufferNumAttributes[] = { 2 }; GPU_SetAttributeBuffers( 2, (u32*)osConvertVirtToPhys((u32)vertices), GPU_ATTRIBFMT(0, 2, GPU_FLOAT) | GPU_ATTRIBFMT(1, 2, GPU_FLOAT), 0xFFFC, 0x10, 1, bufferOffsets, bufferPermutations, bufferNumAttributes); GPU_DrawArray(GPU_TRIANGLE_STRIP, 0, 4); #else Vec4 c = _color.toVector(); float vertices[] = { 0, 0, -0.5f, c.x, c.y, c.z, c.w, 0, 0, _size.x, 0, -0.5f, c.x, c.y, c.z, c.w, 0, 0, 0, _size.y, -0.5f, c.x, c.y, c.z, c.w, 0, 0, _size.x, _size.y, -0.5f, c.x, c.y, c.z, c.w, 0, 0 }; glUniform1i(ShaderProgram::getCurrentProgram()-> getUniformLocation("textureEnabled"), false); glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float) * 36, vertices); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(_vao); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindVertexArray(0); #endif // _3DS } if (getOutlineColor().a > 0) { _outline.setTransform(getCombinedTransform()); _outline.setLine(0, 0, _size.x, 0); _outline.draw(); _outline.setLine(_size.x, 0, _size.x, _size.y); _outline.draw(); _outline.setLine(0, _size.y, _size.x, _size.y); _outline.draw(); _outline.setLine(0, 0, 0, _size.y); _outline.draw(); } Node::draw(); }