visualizations

Programmatic visualizations
git clone git://git.laack.co/visualizations.git
Log | Files | Refs | README

draw.c (878B)


      1 #include "raylib.h"
      2 #include "edge.hpp"
      3 
      4 #define VERTEX_SIZE 5
      5 
      6 void draw_edges(Edge* edges, int length) {
      7     for(int i = 0; i < length; ++i) {
      8         Edge e = edges[i];
      9 
     10         Vertex v1 = *e.v1;
     11         Vertex v2 = *e.v2;
     12         
     13         // TODO: Convert this to a function.
     14         Vector2 v1_p;
     15         v1_p.x = v1.x;
     16         v1_p.y = v1.y;
     17         Vector2 v2_p;
     18         v2_p.x = (float)v2.x;
     19         v2_p.y = (float)v2.y;
     20         if(e.traversed == true) {
     21             DrawLineEx(v1_p, v2_p, 1,WHITE);
     22         } else {
     23             DrawLineEx(v1_p, v2_p, 1,DARKGRAY);
     24         }
     25     }
     26 }
     27 
     28 void draw_vertices(Vertex* vertices, int length) {
     29     for(int i = 0; i < length; ++i) {
     30         Vertex v = vertices[i];
     31         if(v.visited) {
     32             DrawCircle(v.x,v.y,VERTEX_SIZE, WHITE);
     33         } else {
     34             DrawCircle(v.x,v.y,VERTEX_SIZE, GRAY);
     35         }
     36     }
     37 }
     38