Example #1
0
// fontrange shows a range of fonts
void fontrange(int w, int h) {
	int *s, sizes[] = { 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 21, 24, 36, 48, 60, 72, 96, 0 };
	VGfloat x, y = h / 2, spacing = 50, s2 = spacing / 2, len, lx;
	char num[4];

	Start(w, h);
	Background(255, 255, 255);

	// compute the length so we can center
	for (len = 0, s = sizes; *s; s++) {
		len += *s + spacing;
	}
	len -= spacing;
	lx = (w / 2) - (len / 2);			   // center point

	// for each size, display a character and label
	for (x = lx, s = sizes; *s; s++) {
		Fill(128, 0, 0, 1);
		TextMid(x, y, "a", *s);
		Fill(128, 128, 128, 1);
		snprintf(num, 3, "%d", *s);
		TextMid(x, y - spacing, num, 16);
		x += *s + spacing;
	}
	// draw a line below the characters, a curve above
	x -= spacing;
	Stroke(150, 150, 150, 0.5);
	StrokeWidth(2);
	Line(lx, y - s2, x, y - s2);
	Fill(255, 255, 255, 1);
	Qbezier(lx, y + s2, x, y + s2, x, y + (spacing * 3));
	End();
}
Example #2
0
void viewTime(TWidget *Widget, TMain *Main) {
	time_t rawtime;
	struct tm * timeinfo;
	char buffer[80];
	Fill(0, 0, 0, 1);
	char str[100];
	time(&rawtime);
	timeinfo = localtime(&rawtime);
	strftime(buffer, 80, "%H:%M:%S", timeinfo);
	sprintf(str, "%s", buffer);
	TextMid(Widget->X+Main->mX+136, Widget->Y+Main->mY+72-20, str, SerifTypeface, 40);
	
	strftime(buffer, 80, "%d. %B", timeinfo);
	sprintf(str, "%s", buffer);
	TextMid(Widget->X+Main->mX+136, Widget->Y+Main->mY+36-10, str, SerifTypeface, 20);
}
Example #3
0
// textlines writes lines of text
void textlines(VGfloat x, VGfloat y, char *s[], int fontsize, VGfloat leading) {
	int i;
	for (i = 0;; i++) {
		if (s[i] == NULL) {
			break;
		}
		TextMid(x, y, s[i], fontsize);
		y -= leading;
	}
}
void displayLogoConnecting(void) {
    Start(width, height);                   // Start the picture
    Background(0, 0, 0);                    // Black background

    Image((width / 2)-(logo_w / 2), (3 * height / 5) - (logo_h / 2), logo_w, logo_h, logo_path);

    Fill(255, 255, 255, 1);                 // White text
    TextMid(width / 2, 3* height / 20, "Connecting..", SansTypeface, width / 30);  // Greetings
    End();
}
Example #5
0
DrawButton(int ButtonIndex)
{
	button_t *Button=&(ButtonArray[ButtonIndex]);
	
	Fill(Button->Status[Button->NoStatus].Color.r, Button->Status[Button->NoStatus].Color.g, Button->Status[Button->NoStatus].Color.b, 1);
	 Roundrect(Button->x,Button->y,Button->w,Button->h, Button->w/10, Button->w/10);
	Fill(255, 255, 255, 1);				   // White text
	TextMid(Button->x+Button->w/2, Button->y+Button->h/2, Button->Status[Button->NoStatus].Text, SerifTypeface, Button->w/strlen(Button->Status[Button->NoStatus].Text)/*25*/);	

}
Example #6
0
// raspi draws the raspberry pi, scaled to the screen dimensions
void raspi(int w, int h, char *s) {
	VGfloat midx = w / 2, midy = h / 2;
	int rw = midx, rh = (rw * 2) / 3, fontsize = w * 0.03;

	Start(w, h);
	Background(255, 255, 255);
	makepi(midx - (rw / 2), midy - (rh / 2), rw, rh);
	Fill(128, 0, 0, 1);
	TextMid(midx, midy - (rh / 2) - (fontsize * 2), s, fontsize);
	End();
}
Example #7
0
void imagetable(int w, int h) {
	int imgw = 422, imgh = 238;
	char *itable[] = {
		"desert0.jpg",
		"desert1.jpg",
		"desert2.jpg",
		"desert3.jpg",
		"desert4.jpg",
		"desert5.jpg",
		"desert6.jpg",
		"desert7.jpg",
		NULL
	};
	VGfloat left = 50.0;
	VGfloat bot = h - imgh - 50.0;
	VGfloat gutter = 50.0;

	VGfloat x = left;
	VGfloat y = bot;
	int i;
	Start(w, h);
	Background(0, 0, 0);
	for (i = 0; itable[i] != NULL; i++) {
		Image(x, y, imgw, imgh, itable[i]);
		Fill(255, 255, 255, 0.3);
		Rect(x, y, imgw, 32);
		Fill(0, 0, 0, 1);
		TextMid(x + (imgw / 2), y + 10, itable[i], 16);

		x += imgw + gutter;
		if (x > w) {
			x = left;
			y -= imgh + gutter;
		}
	}
	y = h * 0.1;
	Fill(128, 128, 128, 1);
	TextMid(w / 2, 100, "Joshua Tree National Park", 48);
	End();
}
Example #8
0
// testpattern shows a test pattern 
void testpattern(int w, int h, char *s) {
	VGfloat midx, midy1, midy2, midy3;
	int fontsize = 256, h2 = h / 2;
	FW tw1 = { 0, fontsize };
	FW tw2 = { 0, fontsize };
	FW tw3 = { 0, fontsize };

	Start(w, h);

	// colored squares in the corners
	Fill(255, 0, 0, 1);
	Rect(0, 0, 100, 100);
	Fill(0, 255, 0, 1);
	Rect(0, h - 100, 100, 100);
	Fill(0, 0, 255, 1);
	Rect(w - 100, 0, 100, 100);
	Fill(128, 128, 128, 1);
	Rect(w - 100, h - 100, 100, 100);

	// for each font, (Sans, Serif, Mono), adjust the string to the w
	fitwidth(w, 20, s, &tw1);
	fitwidth(w, 20, s, &tw2);
	fitwidth(w, 20, s, &tw3);

	midx = w / 2;

	// Adjust the baselines to be medial
	midy1 = h2 + 20 + (tw1.fontsize) / 2;
	midy2 = h2 - (tw2.fontsize) / 2;
	midy3 = h2 - 20 - tw2.fontsize - (tw3.fontsize) / 2;

	Fill(128, 128, 128, 1);
	TextMid(midx, midy1, s, tw1.fontsize);
	Fill(128, 0, 0, 1);
	TextMid(midx, midy2, s, tw2.fontsize);
	Fill(0, 0, 128, 1);
	TextMid(midx, midy3, s, tw3.fontsize);
	End();
}
Example #9
0
int   	Button::draw_sunken (	)
{
	//Fill_l(text_color);
	Stroke_l ( background_color );
	Fill_l   ( background_color );
	Roundrect( left, bottom, width, height, 15.0, 15.0);

	if (text==NULL) return 1;
	Fill_l (text_color);
	float y = bottom + (height - text_size)/2.0;
	TextMid(left+width/2.0, y, text, SerifTypeface, text_size );
	return 1;
}
Example #10
0
int main() {
	int width, height;
	char s[3];
	char hello1[] = {'H','e','j',',',' ','v', 0xc3, 0xa4,'r' , 'l','d' ,'e','n',0};
	char hello2[] = {'H','e','l','l',0xc3,0xb3,' ', 'V', 'i', 'l', 0xc3,0xa1,'g',0};
	char hello3[] = {'A','h','o','j',' ','s','v',0xc4,0x95,'t','e',0};
	init(&width, &height);				   // Graphics initialization

	Start(width, height);				   // Start the picture
	Background(0, 0, 0);				   // Black background
	Fill(44, 77, 232, 1);				   // Big blue marble
	Circle(width / 2, 0, width);			   // The "world"
	Fill(255, 255, 255, 1);				   // White text
	TextMid(width / 2, (height * 0.7), "hello, world", SerifTypeface, width / 15);	// Greetings 
	TextMid(width / 2, (height * 0.5), hello1 , SerifTypeface, width / 15);
	TextMid(width / 2, (height * 0.3), hello2 , SerifTypeface, width / 15);
	TextMid(width / 2, (height * 0.1), hello3 , SerifTypeface, width / 15);
	End();						   // End the picture

	fgets(s, 2, stdin);				   // look at the pic, end with [RETURN]
	finish();					   // Graphics cleanup
	exit(0);
}
Example #11
0
// gradient demos linear and radial gradients
void gradient(int width, int height) {
	VGfloat x1, y1, x2, y2, cx, cy, fx, fy, r;
	VGfloat w = (VGfloat)width;
	VGfloat h = (VGfloat)height;
	VGfloat dotcolor[4] = {0, 0, 0, 0.3};
	
	
	VGfloat stops[] = {
		0.0, 1.0, 1.0, 1.0, 1.0,
		0.5, 0.5, 0.5, 0.5, 1.0,
		1.0, 0.0, 0.0, 0.0, 1.0
	};
				
	
	x1 = w/8;
	x2 = (w*3)/8;
	y1 = h/3;
	y2 = (h*2)/3;
	cx = (w*3)/4;
	cy = (h/2);
	r = (x2-x1);
	fx = cx + (r/4);
	fy = cy + (r/4);
	Start(w, h);
	Background(128, 128, 128);
	

	FillLinearGradient(x1, y1, x2, y2, stops, 3);
	Rect(x1, y1, x2-x1, y2-y1);
	FillRadialGradient(cx, cy, fx, fy, r, stops, 3);
	Circle(cx, cy, r);
	
	RGBA(.5, 0, 0, 0.3, dotcolor);
	setfill(dotcolor);
	Circle(x1, y1, 10);
	Circle(x2, y2, 10);
	Circle(cx, cy, 10);
	Circle(cx+r/2, cy, 10);
	Circle(fx, fy, 10);
	
	RGB(0,0,0,dotcolor);
	setfill(dotcolor);
	TextMid(x1, y1-20, "(x1, y1)", 18);
	TextMid(x2, y2+10, "(x2, y2)", 18);
	TextMid(cx, cy, "(cx, cy)", 18);
	TextMid(fx, fy, "(fx, fy)", 18);
	TextEnd(cx+(r/2)+20, cy, "r", 18);
	
	
	TextMid(x1+((x2-x1)/2), h/6, "Linear Gradient", 36);
	TextMid(cx, h/6, "Radial Gradient", 36);
	
	
	End();

}
Example #12
0
int Leveler::draw_y_label() 
{
	VGfloat fade  = (100.0 / (VGfloat) 1) / 100.0;
	VGfloat alpha = 1.0;
	int yrange = (top-bottom);
	int tenpercent = (float)(right-left)*margin_percent;
	int x = left-tenpercent;
	int y = bottom+yrange/2.0;
	float size = 14;  //yrange/strlen(yAxisLabel);

	Translate(x, y);
	Rotate(90);	
	Fill(0, 255, 125, alpha);
	TextMid  ( 0, 0, yAxisLabel, SerifTypeface, size );
	Rotate   ( -90    );	
	Translate( -x, -y );
}
Example #13
0
int   	Button::draw_raised (	)
{
	// Draw Border:
	Stroke_l ( 0xFF000000 );
	Roundrect( left, bottom, width, height, 15.0, 15.0);
			// use 2 rectangles:
	Stroke_l ( border_color );
	Fill_l   ( background_color );
	Roundrect( left+1, bottom+1, width-2, height-2, 15.0, 15.0);

	// DRAW TEXT:
	float y = bottom + (height - text_size)/2.0;	
	if (text==NULL) return 1;
	Fill_l (text_color);
	TextMid(left+width/2.0, y, text, SerifTypeface, text_size );
	return 1;
}
Example #14
0
int main() {
	int width, height, cursorx, cursory, cbsize;

	init(&width, &height);				   // Graphics initialization
	cursorx = width / 2;
	cursory = height / 2;
	cbsize = (CUR_SIZ * 2) + 1;
	VGImage CursorBuffer = vgCreateImage(VG_sABGR_8888, cbsize, cbsize, VG_IMAGE_QUALITY_BETTER);

	if (mouseinit(width, height) != 0) {
		fprintf(stderr, "Unable to initialize the mouse\n");
		exit(1);
	}
	Start(width, height);				   // Start the picture
	Background(0, 0, 0);				   // Black background
	Fill(44, 77, 232, 1);				   // Big blue marble
	Circle(width / 2, 0, width);			   // The "world"
	Fill(255, 255, 255, 1);				   // White text
	TextMid(width / 2, height / 2, "hello, world", SerifTypeface, width / 10);	// Greetings 
	End();						   // update picture

	// MAIN LOOP
	while (left_count < 2) {			   // Loop until the left mouse button pressed & released
		// if the mouse moved...
		if (mouse.x != cursorx || mouse.y != cursory) {
			restoreCursor(CursorBuffer);
			cursorx = mouse.x;
			cursory = mouse.y;
			saveCursor(CursorBuffer, cursorx, cursory, width, height, CUR_SIZ);
			circleCursor(cursorx, cursory, width, height, CUR_SIZ);
			End();				   // update picture
		}
	}
	restoreCursor(CursorBuffer);			   // not strictly necessary as display will be closed
	vgDestroyImage(CursorBuffer);			   // tidy up memory
	finish();					   // Graphics cleanup
	exit(0);
}
Example #15
0
void viewLesson(TWidget *Widget, TMain *Main){
	int l_number = 0;
	wchar_t* l_text = L"-";
	time_t now = time(NULL);
	struct tm *tnow = localtime( &now );
	
	int time_mix = 0;
	time_mix = tnow->tm_hour*3600 + tnow->tm_min*60 + tnow->tm_sec;
	
	//id, type, start, end, len
	int i = 0;
	char l_numb[5];
	
	char timer_left[10];
	
	int time_diff, d_min, d_sec = 0;
	
	for(i = 1; i <= (lesson_array_count + 1); i++){
		if((time_mix >= Lessons[i].start) && (time_mix < Lessons[i].end)) {
			if(time_mix < (Lessons[i].end - 3000)) time_diff = Lessons[i].end - 3000 - time_mix;
			else time_diff = Lessons[i].end - time_mix;
	
			l_number = i;
			l_text = L"pāris";
			if((time_mix >= (Lessons[i].start + Lessons[i].length)) && (time_mix < (Lessons[i].end - Lessons[i].length))) {
				time_diff = Lessons[i].end - Lessons[i].length - time_mix;
				l_text = L"starpbrīdis";
			}
		}
		if((time_mix >= Lessons[(i - 1)].end) && (time_mix < Lessons[i].start)) {
			time_diff = Lessons[i].start - time_mix;
			l_text = L"starpbrīdis";
		}
	}
	if(time_mix < (Lessons[1].start - 1800)){
		time_diff = 0;
		l_text = L"-";
	}
	if((time_mix >= (Lessons[1].start - 1800)) && (time_mix < Lessons[1].start)){
		time_diff = Lessons[1].start - time_mix;
	}
	d_min = time_diff / 60;
	d_sec = time_diff % 60;

	sprintf(timer_left, "%02i:%02i", d_min, d_sec);
	
	Fill(50, 205, 50, 1);
	if(time_diff < 60) Fill(255, 0, 0, 1);
	TextMid(Widget->X+Main->mX+135, Widget->Y+Main->mY+30-15, timer_left, TimesTypeface, 30);
	
	Fill(0, 0, 0, 1);
	if(l_number > 0) {
		sprintf(l_numb, "%i.", l_number);
		TextMid(Widget->X+Main->mX+135, Widget->Y+Main->mY+120-25, l_numb, TimesTypeface, 50);
	}
	else{
		TextMid(Widget->X+Main->mX+135, Widget->Y+Main->mY+120-25, "-", TimesTypeface, 50);
	}
	TextMidW(Widget->X+Main->mX+135, Widget->Y+Main->mY+70-10, l_text, TimesTypeface, 20);
	/*
	if((time_mix >= 830) && (time_mix < 1005)) {
		l_number = "1.";
		l_text = "paris";
	}*/
}