Updated graph demo to show more

Added extra line segment graphing to the graph demo
This commit is contained in:
Andrew Hannam 2012-12-13 23:05:49 +10:00
parent 512c7fa4f6
commit f31a1f7f4a
2 changed files with 15 additions and 9 deletions

View File

@ -3,12 +3,12 @@
#include "gfx.h"
#include "math.h"
int data[5][2] = {
{ 0, 0 },
{ 10, 10 },
{ 20, 20 },
{ 30, 30 },
{ 40, 40 }
const GGraphPoint data[5] = {
{ -40, -40 },
{ 70, 40 },
{ 140, 60 },
{ 210, 60 },
{ 280, 200 }
};
GGraphObject g;
@ -24,8 +24,8 @@ GGraphStyle GraphStyle1 = {
};
GGraphStyle GraphStyle2 = {
{ GGRAPH_POINT_DOT, 0, Green }, // point
{ GGRAPH_LINE_NONE, 2, Gray }, // line
{ GGRAPH_POINT_SQUARE, 5, Red }, // point
{ GGRAPH_LINE_DOT, 2, Pink }, // line
{ GGRAPH_LINE_SOLID, 0, White }, // x axis
{ GGRAPH_LINE_SOLID, 0, White }, // y axis
{ GGRAPH_LINE_DASH, 5, Gray, 50 }, // x grid
@ -53,11 +53,17 @@ int main(void) {
gwinGraphDrawPoint(gh, i-gwinGetWidth(gh)/2, 80*sin(2*0.2*M_PI*i/180));
gwinGraphStartSet(gh);
gwinGraphSetStyle(gh, &GraphStyle2);
GraphStyle1.point.color = Green;
gwinGraphSetStyle(gh, &GraphStyle1);
for(i = 0; i < gwinGetWidth(gh)*5; i++)
gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*sin(2*0.2*M_PI*i/180));
gwinGraphStartSet(gh);
gwinGraphSetStyle(gh, &GraphStyle2);
gwinGraphDrawPoints(gh, data, sizeof(data)/sizeof(data[0]));
while(TRUE) {
chThdSleepMilliseconds(100);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB