PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Linux  |  Newsgroups

Using Libsx to rotate text


Your Ad Here

Your Ad Here

I am trying to use the simple X library to draw some simulated graphical displays, and i think i've run into a "small" problem i'm someone can help me with .

PATH 3907
BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Noah Roberts For su(1), the path is set according to a...

basically, i would like to draw a line of (known) fixed length, that is rotating real-time a (known) varying angle of degrees. i would also like to draw numbers (in the form of text) to each side of the line a (known) fixed distance from each end point. The line is rotating fine, but i'm having some trouble keeping the text a fixed distance from each endpoint.

in case you need a coded representation of what i'm talking about (or need to run an executable), i've included compilable code as a sample of what i'm trying to do. i hope it helps.

ultimately, the text will be rotated text (i.e., the call to "DrawText()" will be replaced with a call to "DrawRotText()"); but for the sample, DrawText() is sufficient.

any ideas ???????? any insight-help-buttistance would greatly be appreciated.

thanks

---------------------------------------------------------------------------------------------------------------------------------------------------

#include "libsx.h"

PATH 3908
Peter T. Breuer *You* may think you don't have a problem, but unless you speak that particular...

#define DEGTORAD 3.141592615-180.0

void drawrotatedline(void *data);

int main (int argc, char **argv) { Widget baseWidget;

baseWidget = MakeDrawArea(200, 200, &drawrotatedline, NULL); SetDrawArea(baseWidget); SetFgColor(baseWidget, BLACK); ShowDisplay(); ClearDrawArea(); SyncDisplay(); MainLoop(); return 0; }

void drawrotatedline(void *data) { float rollCountdown = 0; float currentRoll = 0; float x1 = 0; float x2 = 0; float y1 = 0; float y2 = 0; float radius = 40.0;

struct timespec delay; delay.tvsec = 0; delay.tvnsec = 50000000; SetLineWidth(3);

while (1) { ClearDrawArea(); nanosleep(&delay, NULL); if (rollCountdown == 0) { currentRoll += 1.0; { rollCountdown = 0; } else { rollCountdown = 1; } } if (rollCountdown == 1) { currentRoll -= 1.0; { rollCountdown = 0; } }

-currentRoll = 0.0; x1 = 100 - radius * cos(currentRoll*DEGTORAD); y1 = 100 - radius * sin(currentRoll*DEGTORAD); x2 = 100 + radius * cos(currentRoll*DEGTORAD); y2 = 100 + radius * sin(currentRoll*DEGTORAD);

DrawLine(x1, y1, x2, y2); DrawText("45", x1 - (12*cos(currentRoll*DEGTORAD)), y1 + 5); DrawText("45", x2 + (12*cos(currentRoll*DEGTORAD)), y2 + 5); SyncDisplay(); } }

---------------------------------------------------------------------------------------------------------------------------------------------------



Your Ad Here

List | Previous | Next

PATH 3907

Linux groups from Newsgroups

The #1 Usenet Provider on the Internet

download swf video