Update graph demo and move under gwin demos

ugfx_release_2.6
inmarket 2013-07-16 15:29:26 +10:00
parent c82fc68bfa
commit 83897ac07a
3 changed files with 165 additions and 153 deletions

View File

@ -38,6 +38,7 @@
/* GFX sub-systems to turn on */
#define GFX_USE_GDISP TRUE
#define GFX_USE_GWIN TRUE
#define GFX_USE_GMISC TRUE
/* Features for the GDISP sub-system. */
#define GDISP_NEED_VALIDATION TRUE
@ -56,4 +57,7 @@
/* Features for the GWIN sub-system. */
#define GWIN_NEED_GRAPH TRUE
/* Turn on fast trig */
#define GMISC_NEED_FASTTRIG TRUE
#endif /* _GFXCONF_H */

View File

@ -30,7 +30,7 @@
#include "gfx.h"
#include "math.h"
const GGraphPoint data[5] = {
static const point data[5] = {
{ -40, -40 },
{ 70, 40 },
{ 140, 60 },
@ -38,9 +38,9 @@ const GGraphPoint data[5] = {
{ 280, 200 }
};
GGraphObject g;
static GGraphObject g;
GGraphStyle GraphStyle1 = {
static GGraphStyle GraphStyle1 = {
{ GGRAPH_POINT_DOT, 0, Blue }, // point
{ GGRAPH_LINE_NONE, 2, Gray }, // line
{ GGRAPH_LINE_SOLID, 0, White }, // x axis
@ -50,7 +50,7 @@ GGraphStyle GraphStyle1 = {
GWIN_GRAPH_STYLE_POSITIVE_AXIS_ARROWS // flags
};
GGraphStyle GraphStyle2 = {
static const GGraphStyle GraphStyle2 = {
{ GGRAPH_POINT_SQUARE, 5, Red }, // point
{ GGRAPH_LINE_DOT, 2, Pink }, // line
{ GGRAPH_LINE_SOLID, 0, White }, // x axis
@ -66,21 +66,29 @@ int main(void) {
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);
gwinGraphSetStyle(gh, &GraphStyle1);
gwinGraphDrawAxis(gh);
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);
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));
gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*fsin(2*i/5)); //sin(2*0.2*M_PI*i/180));
gwinGraphStartSet(gh);
gwinGraphSetStyle(gh, &GraphStyle2);

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB