コード例 #1
0
ファイル: selection.go プロジェクト: reusee/my-editor-gl
func draw_selections(viewp, bufferp, crp unsafe.Pointer, mark_pairs []unsafe.Pointer) {
	view := (*C.GtkTextView)(viewp)
	buffer := (*C.GtkTextBuffer)(bufferp)
	cr := (*C.cairo_t)(crp)
	var alloc C.GtkAllocation
	C.gtk_widget_get_allocation((*C.GtkWidget)(viewp), &alloc)
	n := len(mark_pairs)
	var start_mark, stop_mark *C.GtkTextMark
	var location C.GdkRectangle
	var iter C.GtkTextIter
	var x, y C.gint
	var dx, dy C.double
	for i := 0; i < n; i += 2 {
		start_mark = (*C.GtkTextMark)(mark_pairs[i])
		C.gtk_text_buffer_get_iter_at_mark(buffer, &iter, start_mark)
		C.gtk_text_view_get_iter_location(view, &iter, &location)
		C.gtk_text_view_buffer_to_window_coords(view, C.GTK_TEXT_WINDOW_WIDGET, C.gint(location.x), C.gint(location.y), &x, &y)
		if C.int(x) > alloc.width || C.int(y) > alloc.height || x < 0 || y < 0 {
			continue
		}
		dx = C.double(x)
		dy = C.double(y)

		C.cairo_set_source_rgb(cr, 1, 0, 0)
		C.cairo_move_to(cr, dx, dy)
		C.cairo_set_line_width(cr, 2)
		C.cairo_line_to(cr, dx+6, dy)
		C.cairo_stroke(cr)

		C.cairo_move_to(cr, dx, dy)
		C.cairo_set_line_width(cr, 1)
		C.cairo_line_to(cr, dx, dy+C.double(location.height))
		C.cairo_stroke(cr)

		stop_mark = (*C.GtkTextMark)(mark_pairs[i+1])
		C.gtk_text_buffer_get_iter_at_mark(buffer, &iter, stop_mark)
		C.gtk_text_view_get_iter_location(view, &iter, &location)
		C.gtk_text_view_buffer_to_window_coords(view, C.GTK_TEXT_WINDOW_WIDGET, C.gint(location.x), C.gint(location.y), &x, &y)
		if C.int(x) > alloc.width || C.int(y) > alloc.height || x < 0 || y < 0 {
			continue
		}
		dx = C.double(x)
		dy = C.double(y)

		C.cairo_set_source_rgb(cr, 0, 1, 0)
		C.cairo_move_to(cr, dx, dy)
		C.cairo_set_line_width(cr, 1)
		C.cairo_line_to(cr, dx, dy+C.double(location.height))
		C.cairo_stroke(cr)

		C.cairo_move_to(cr, dx, dy+C.double(location.height))
		C.cairo_set_line_width(cr, 2)
		C.cairo_line_to(cr, dx-6, dy+C.double(location.height))
		C.cairo_stroke(cr)

	}
}
コード例 #2
0
ファイル: surface.go プロジェクト: ungerik/go-cairo
func (self *Surface) Stroke() {
	C.cairo_stroke(self.context)
}
コード例 #3
0
ファイル: cairo.go プロジェクト: raichu/gotk3
// Stroke is a wrapper around cairo_stroke().
func (v *Context) Stroke() {
	C.cairo_stroke(v.native())
}
コード例 #4
0
ファイル: cairo.go プロジェクト: jimmyfrasche/cairo
//Stroke strokes the current path according to the current line width,
//line join, line cap, and dash settings.
//
//After Stroke, the current path will be cleared from the cairo context.
//
//Degenerate segments and sub-paths are treated specially and provide a useful
//result.
//These can result in two different situations:
//
//1. Zero-length "on" segments set in SetDash.
//If the cap style is LineCapRound or LineCapSquare then these segments will be
//drawn as circular dots or squares respectively.
//In the case of LineCapSquare, the orientation of the squares is determined by
//the direction of the underlying path.
//
//2. A sub-path created by MoveTo followed by either a ClosePath or one or more
//calls to LineTo to the same coordinate as the MoveTo.
//If the cap style is LineCapRound then these sub-paths will be drawn as
//circular dots.
//Note that in the case of LineCapSquare a degenerate sub-path will not be drawn
//at all, as the correct orientation is indeterminate.
//
//In no case will a cap style of LineCapButt cause anything to be drawn in the
//case of either degenerate segments or sub-paths.
//
//Originally cairo_stroke.
func (c *Context) Stroke() *Context {
	C.cairo_stroke(c.c)
	return c
}
コード例 #5
0
ファイル: imgops.go プロジェクト: akiross/gogp
// Stroke the current path with the given color
func (i *Image) StrokeColor(col ...float64) {
	i.SetColor(col...)
	C.cairo_stroke(i.Ctx)
}