<div dir="ltr"><div class="gmail_extra"><div><div dir="ltr"><div dir="ltr"><div>ravi,<br><br></div>thanks for the information. it worked for me.<br></div><br clear="all">Thanks & Regards<br>--<br>Lokesh.<br></div></div>
<br><br><div class="gmail_quote">On Fri, Aug 8, 2014 at 11:53 AM, RAVI NANJUNDAPPA <span dir="ltr"><<a href="mailto:nravi.n@samsung.com" target="_blank">nravi.n@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
hi Lokesh,<br>
<br>
I tried your sample code in my machine.<br>
I guess the program is fine except that I changed the rgb values in draw_graphlins()<br>
from<br>
<div class="">cairo_set_source_rgb( cr, 0.8, 0.8, 0.8 );<br>
</div>to<br>
cairo_set_source_rgb( cr, 0, 0, 0 );<br>
After this change, am able to see the grid + blue line.<br>
<br>
So, I feel it was due to rgb values which was making the grid lines not recognized by eyes.<br>
Please check this out in your environment too.<br>
<br>
Thanks and Best Regards,<br>
N Ravi<br>
<br>
------- Original Message -------<br>
Sender : Lokesh Chakka<<a href="mailto:lvenkatakumarchakka@gmail.com">lvenkatakumarchakka@gmail.com</a>><br>
Date : Aug 08, 2014 10:15 (GMT+05:30)<br>
Title : [cairo] unable to get the dotted and continuous lines<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
Hello,<br>
<br>
<br>
I newly started using Cairo. I am facing one problem with the Cairo function calls. I want to first draw Cartesian grids using hyphens with gray color and after that I want to plot a normal line in blue color.<br>
<br>
<br>
I referred the program pen dashes at Basic drawing in Cairo<br>
<br>
<br>
But I am seeing only the blue color line. but not the Cartesian grids. Can some one help me by telling what mistake I am doing.<br>
<br>
<br>
#include <cairo.h><br>
#include <gtk/gtk.h><br>
#include <math.h><br>
#include <inttypes.h><br>
<br>
<br>
uint16_t drawing_width = 300, drawing_height = 200;<br>
<br>
uint16_t evaluate_y_coordinate( uint16_t y )<br>
{<br>
return drawing_height - y;<br>
}<br>
<br>
static void draw_graphlines( cairo_t *cr )<br>
{<br>
const uint16_t stepx = drawing_width/10, stepy = drawing_height/5;<br>
const double dashes[] = { 5, 10 };<br>
uint32_t i;<br>
<br>
cairo_set_source_rgb( cr, 0.8, 0.8, 0.8 );<br>
cairo_set_line_width( cr, 0.5 );<br>
cairo_set_dash ( cr, dashes, 2, 0 );<br>
for( i=0; i<drawing_width; i+=stepx )<br>
{//vertical lines<br>
cairo_move_to( cr, i, evaluate_y_coordinate( 0 ) );<br>
cairo_line_to( cr, i, evaluate_y_coordinate( drawing_height ) );<br>
}<br>
for( i=0; i<drawing_height; i+=stepy )<br>
{// horizontal lines<br>
cairo_move_to( cr, 0, evaluate_y_coordinate( i ) );<br>
cairo_line_to( cr, drawing_width, evaluate_y_coordinate( i ) );<br>
}<br>
cairo_stroke(cr);<br>
cairo_set_dash ( cr, dashes, 0, 0 );<br>
}<br>
<br>
<br>
static void do_drawing( GtkWidget *widget, cairo_t *cr, char *data )<br>
{<br>
GdkRGBA rgba;<br>
<br>
draw_graphlines( cr );<br>
cairo_set_source_rgb( cr, 0, 0, 1 );<br>
cairo_set_line_width( cr, 2.0 );<br>
cairo_move_to( cr, 10, 10 );<br>
cairo_line_to( cr, 100, 100 );<br>
cairo_stroke(cr);<br>
}<br>
<br>
<br>
int main (int argc, char *argv[])<br>
{<br>
GtkWidget *window;<br>
GtkWidget *darea;<br>
<br>
gtk_init(&argc, &argv);<br>
<br>
window = gtk_window_new(GTK_WINDOW_<br>
TOPLEVEL);<br>
<br>
darea = gtk_drawing_area_new();<br>
gtk_container_add(GTK_CONTAINER(window), darea);<br>
<br>
g_signal_connect(G_OBJECT(darea), "draw", G_CALLBACK(do_drawing), NULL);<br>
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);<br>
<br>
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);<br>
gtk_window_set_default_size(GTK_WINDOW(window), drawing_width, drawing_height );<br>
gtk_window_set_title(GTK_WINDOW(window), "Fill & stroke");<br>
<br>
gtk_widget_show_all(window);<br>
<br>
gtk_main();<br>
<br>
return 0;<br>
}<br>
<br>
<br>
<br>
<br>
Thanks & Regards<br>
--<br>
Lokesh</div></div></blockquote></div><br></div></div>