Update graph demo and move under gwin demos
parent
c82fc68bfa
commit
83897ac07a
|
@ -38,6 +38,7 @@
|
||||||
/* GFX sub-systems to turn on */
|
/* GFX sub-systems to turn on */
|
||||||
#define GFX_USE_GDISP TRUE
|
#define GFX_USE_GDISP TRUE
|
||||||
#define GFX_USE_GWIN TRUE
|
#define GFX_USE_GWIN TRUE
|
||||||
|
#define GFX_USE_GMISC TRUE
|
||||||
|
|
||||||
/* Features for the GDISP sub-system. */
|
/* Features for the GDISP sub-system. */
|
||||||
#define GDISP_NEED_VALIDATION TRUE
|
#define GDISP_NEED_VALIDATION TRUE
|
||||||
|
@ -56,4 +57,7 @@
|
||||||
/* Features for the GWIN sub-system. */
|
/* Features for the GWIN sub-system. */
|
||||||
#define GWIN_NEED_GRAPH TRUE
|
#define GWIN_NEED_GRAPH TRUE
|
||||||
|
|
||||||
|
/* Turn on fast trig */
|
||||||
|
#define GMISC_NEED_FASTTRIG TRUE
|
||||||
|
|
||||||
#endif /* _GFXCONF_H */
|
#endif /* _GFXCONF_H */
|
|
@ -30,7 +30,7 @@
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
const GGraphPoint data[5] = {
|
static const point data[5] = {
|
||||||
{ -40, -40 },
|
{ -40, -40 },
|
||||||
{ 70, 40 },
|
{ 70, 40 },
|
||||||
{ 140, 60 },
|
{ 140, 60 },
|
||||||
|
@ -38,9 +38,9 @@ const GGraphPoint data[5] = {
|
||||||
{ 280, 200 }
|
{ 280, 200 }
|
||||||
};
|
};
|
||||||
|
|
||||||
GGraphObject g;
|
static GGraphObject g;
|
||||||
|
|
||||||
GGraphStyle GraphStyle1 = {
|
static GGraphStyle GraphStyle1 = {
|
||||||
{ GGRAPH_POINT_DOT, 0, Blue }, // point
|
{ GGRAPH_POINT_DOT, 0, Blue }, // point
|
||||||
{ GGRAPH_LINE_NONE, 2, Gray }, // line
|
{ GGRAPH_LINE_NONE, 2, Gray }, // line
|
||||||
{ GGRAPH_LINE_SOLID, 0, White }, // x axis
|
{ GGRAPH_LINE_SOLID, 0, White }, // x axis
|
||||||
|
@ -50,7 +50,7 @@ GGraphStyle GraphStyle1 = {
|
||||||
GWIN_GRAPH_STYLE_POSITIVE_AXIS_ARROWS // flags
|
GWIN_GRAPH_STYLE_POSITIVE_AXIS_ARROWS // flags
|
||||||
};
|
};
|
||||||
|
|
||||||
GGraphStyle GraphStyle2 = {
|
static const GGraphStyle GraphStyle2 = {
|
||||||
{ GGRAPH_POINT_SQUARE, 5, Red }, // point
|
{ GGRAPH_POINT_SQUARE, 5, Red }, // point
|
||||||
{ GGRAPH_LINE_DOT, 2, Pink }, // line
|
{ GGRAPH_LINE_DOT, 2, Pink }, // line
|
||||||
{ GGRAPH_LINE_SOLID, 0, White }, // x axis
|
{ GGRAPH_LINE_SOLID, 0, White }, // x axis
|
||||||
|
@ -66,21 +66,29 @@ int main(void) {
|
||||||
|
|
||||||
gfxInit();
|
gfxInit();
|
||||||
|
|
||||||
gh = gwinCreateGraph(&g, 0, 0, gdispGetWidth(), gdispGetHeight());
|
{
|
||||||
|
GWindowInit wi;
|
||||||
|
|
||||||
|
wi.show = TRUE;
|
||||||
|
wi.x = wi.y = 0;
|
||||||
|
wi.width = gdispGetWidth();
|
||||||
|
wi.height = gdispGetHeight();
|
||||||
|
gh = gwinGraphCreate(&g, &wi);
|
||||||
|
}
|
||||||
|
|
||||||
gwinGraphSetOrigin(gh, gwinGetWidth(gh)/2, gwinGetHeight(gh)/2);
|
gwinGraphSetOrigin(gh, gwinGetWidth(gh)/2, gwinGetHeight(gh)/2);
|
||||||
gwinGraphSetStyle(gh, &GraphStyle1);
|
gwinGraphSetStyle(gh, &GraphStyle1);
|
||||||
gwinGraphDrawAxis(gh);
|
gwinGraphDrawAxis(gh);
|
||||||
|
|
||||||
for(i = 0; i < gwinGetWidth(gh); i++)
|
for(i = 0; i < gwinGetWidth(gh); i++)
|
||||||
gwinGraphDrawPoint(gh, i-gwinGetWidth(gh)/2, 80*sin(2*0.2*M_PI*i/180));
|
gwinGraphDrawPoint(gh, i-gwinGetWidth(gh)/2, 80*fsin(2*i/5)); //sin(2*0.2*M_PI*i/180));
|
||||||
|
|
||||||
gwinGraphStartSet(gh);
|
gwinGraphStartSet(gh);
|
||||||
GraphStyle1.point.color = Green;
|
GraphStyle1.point.color = Green;
|
||||||
gwinGraphSetStyle(gh, &GraphStyle1);
|
gwinGraphSetStyle(gh, &GraphStyle1);
|
||||||
|
|
||||||
for(i = 0; i < gwinGetWidth(gh)*5; i++)
|
for(i = 0; i < gwinGetWidth(gh)*5; i++)
|
||||||
gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*sin(2*0.2*M_PI*i/180));
|
gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*fsin(2*i/5)); //sin(2*0.2*M_PI*i/180));
|
||||||
|
|
||||||
gwinGraphStartSet(gh);
|
gwinGraphStartSet(gh);
|
||||||
gwinGraphSetStyle(gh, &GraphStyle2);
|
gwinGraphSetStyle(gh, &GraphStyle2);
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Loading…
Reference in New Issue