博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
GTK+基本图元的绘制
阅读量:6072 次
发布时间:2019-06-20

本文共 2754 字,大约阅读时间需要 9 分钟。

// main.c#include 
static voiddraw_round_rectangle (cairo_t * cr, double x, double y, double width, double height, double r){ cairo_move_to (cr, x + r, y); cairo_line_to (cr, x + width - r, y); cairo_move_to (cr, x + width, y + r); cairo_line_to (cr, x + width, y + height - r); cairo_move_to (cr, x + width - r, y + height); cairo_line_to (cr, x + r, y + height); cairo_move_to (cr, x, y + height - r); cairo_line_to (cr, x, y + r); cairo_arc (cr, x + r, y + r, r, 3.14, 3 * 3.14 / 2.0); cairo_arc (cr, x + width - r, y + r, r, 3 * 3.14 / 2, 2 * 3.14); cairo_arc (cr, x + width - r, y + height - r, r, 0, 3.14 / 2); cairo_arc (cr, x + r, y + height - r, r, 3.14 / 2, 3.14);}static gbooleandraw (GtkWidget *widget, cairo_t *cr, gpointer user_data){ cr = gdk_cairo_create (gtk_widget_get_window (widget)); cairo_set_source_rgb (cr, 0, 0, 0); cairo_set_line_width (cr, 1); cairo_rectangle (cr, 20, 20, 120, 80); cairo_rectangle (cr, 180, 20, 80, 80); cairo_stroke_preserve (cr); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); cairo_set_source_rgb (cr, 0, 0, 0); cairo_arc (cr, 330, 60, 40, 0, 2 * 3.14); cairo_stroke_preserve (cr); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); cairo_set_source_rgb (cr, 0, 0, 0); cairo_arc (cr, 90, 160, 40, 3.14 / 4, 3.14); cairo_close_path (cr); cairo_stroke_preserve(cr); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); cairo_set_source_rgb (cr, 0, 0, 0); cairo_translate (cr, 220, 180); cairo_scale (cr, 1, 0.7); cairo_arc (cr, 0, 0, 50, 0, 2 * 3.14); cairo_stroke_preserve (cr); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); cairo_set_source_rgb (cr, 0.8, 0.4, 0); cairo_translate (cr, 80, -30); cairo_set_line_width (cr, 6); draw_round_rectangle (cr, 5, 5, 60, 60, 8); cairo_stroke_preserve (cr); cairo_set_source_rgb (cr, 0.8, 0.8, 0.2); cairo_fill (cr); cairo_destroy (cr); return FALSE;}intmain (int argc, char **argv){ GtkWidget *window; GtkWidget *darea; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); darea = gtk_drawing_area_new (); gtk_container_add (GTK_CONTAINER (window), darea); g_signal_connect (darea, "draw", G_CALLBACK (draw), NULL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); gtk_window_set_default_size (GTK_WINDOW (window), 390, 240); gtk_widget_show_all (window); gtk_main (); return 0;}

转载于:https://www.cnblogs.com/the-capricornus/p/3851920.html

你可能感兴趣的文章
python 递归
查看>>
原型链-面向面试
查看>>
shr 右移测试
查看>>
文件夹中的文件以目录的形式呈现
查看>>
java操作数据库出错
查看>>
linux基础-第十四单元 Linux网络原理及基础设置
查看>>
浅谈一下Windows下的用户权限
查看>>
什么是linux的ftp
查看>>
Python命令行解析argparse常用语法使用简介
查看>>
Spring 4 官方文档学习(十二)View技术
查看>>
jsp页面验证码(完整实例)
查看>>
学习建模 - UML
查看>>
Android解析WindowManager(一)WindowManager体系
查看>>
一个想法(续二):换个角度思考如何解决IT企业招聘难的问题!
查看>>
tomcat指定配置文件路径方法
查看>>
一些常见的关于Linux系统的问题
查看>>
推荐一款jQuery ColorPicked 颜色拾取器插件
查看>>
javaweb学习总结(二十三)——jsp自定义标签开发入门
查看>>
网络编程中的CAP & 有趣的存储框架(关系型、NoSQL)全图
查看>>
[Linux内核]ctrl-z/fg/bg/nohup/setsid/()与&/disown/screen
查看>>