/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); //spriteBatch.Draw() // TODO: Add your drawing code here int w = GraphicsDevice.Viewport.Width, h = GraphicsDevice.Viewport.Height; int y0 = (int)(h * margem), yn = h - y0; int tamanhoEfetivo = Math.Abs(y0 - yn); float escala = tamanhoEfetivo / tamanho; int x0 = w / 2 - tamanhoEfetivo / 2, xn = x0 + tamanhoEfetivo; int espacamento = tamanhoEfetivo / tamanho; spriteBatch.Draw(tex, new Rectangle(x0, y0, tamanhoEfetivo, tamanhoEfetivo), Color.White); for (int x = x0; x < xn; x += espacamento) { spriteBatch.Draw(tex, new Rectangle(x, y0, tamanhoEfetivo, 1), null, Color.LightGray, MathHelper.Pi / 2, Vector2.Zero, SpriteEffects.None, 1.0f); } for (int y = y0; y < yn; y += espacamento) { spriteBatch.Draw(tex, new Rectangle(x0, y, tamanhoEfetivo, 1), null, Color.Gray, 0f, Vector2.Zero, SpriteEffects.None, 1.0f); } for (int x = 0; x < tamanhoEfetivo; x++) { for (int y = 0; y < tamanhoEfetivo; y++) { var vx = Algoritmo.matrizLinha(new[] { 1.0, x / escala, y / escala }); var vy = Algoritmo.saida(realizacao.W, vx); if (cores.ContainsKey(vy)) { var cor = new Color(cores[vy], 0.2f); spriteBatch.Draw(tex, new Rectangle(x0 + x, y0 + y, 1, 1), cor); } } } foreach (var dado in Algoritmo.algoritmoCustom.Dados) { var row = dado.X.Row(0); int x = (int)(row[1] * escala), y = (int)(row[2] * escala); var rect = new Rectangle(x + x0 - 3, y + y0 - 3, 7, 7); var border = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); var cor = new Color(cores[dado.Y], 0.8f); spriteBatch.Draw(tex, border, Color.Black); spriteBatch.Draw(tex, rect, cor); } spriteBatch.End(); base.Draw(gameTime); }