Hey, I've got freaking needles now
This commit is contained in:
parent
e5b2b11ec0
commit
4900d59328
1 changed files with 26 additions and 0 deletions
|
@ -8,6 +8,24 @@
|
|||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
static void draw_needle(cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
double r,
|
||||
double min_angle,
|
||||
double max_angle,
|
||||
double value) {
|
||||
double angle = min_angle + ((max_angle - min_angle) * value) - 90.0;
|
||||
|
||||
cairo_move_to(cr, x, y);
|
||||
|
||||
cairo_line_to(cr,
|
||||
x + r * cos((M_PI/180.0) * angle),
|
||||
y + r * sin((M_PI/180.0) * angle));
|
||||
|
||||
cairo_stroke(cr);
|
||||
}
|
||||
|
||||
static void redraw(cairo_t *ctx) {
|
||||
/*
|
||||
* Paint canvas black
|
||||
|
@ -22,6 +40,14 @@ static void redraw(cairo_t *ctx) {
|
|||
cairo_arc(ctx, 208, 240, 192, 0, 360);
|
||||
cairo_stroke(ctx);
|
||||
|
||||
/*
|
||||
* Draw a gauge needle
|
||||
*/
|
||||
draw_needle(ctx, 208, 240, 176, 240, 480, 0.0);
|
||||
|
||||
/*
|
||||
* Draw another circle
|
||||
*/
|
||||
cairo_arc(ctx, 816, 240, 192, 0, 360);
|
||||
cairo_stroke(ctx);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue