Exemple #1
0
// Returns a new canvas object.
func New() *Canvas {
	cv := &Canvas{}

	cv.Init()

	cv.wand = C.NewMagickWand()

	cv.fg = C.NewPixelWand()
	cv.bg = C.NewPixelWand()

	cv.fill = C.NewPixelWand()
	cv.stroke = C.NewPixelWand()

	cv.drawing = C.NewDrawingWand()

	//cv.SetColor("#ffffff")
	cv.SetBackgroundColor("none")

	cv.SetStrokeColor("#ffffff")
	cv.SetStrokeAntialias(true)
	cv.SetStrokeWidth(1.0)
	cv.SetStrokeOpacity(1.0)
	cv.SetStrokeLineCap(STROKE_ROUND_CAP)
	cv.SetStrokeLineJoin(STROKE_ROUND_JOIN)

	//cv.SetFillRule(FILL_EVEN_ODD_RULE)
	cv.SetFillColor("#888888")

	return cv
}
Exemple #2
0
// Returns a new canvas object.
func New() *Canvas {
	self := &Canvas{}

	self.wand = C.NewMagickWand()
	self.drawing = C.NewDrawingWand()

	self.fg = C.NewPixelWand()
	self.bg = C.NewPixelWand()

	self.fill = C.NewPixelWand()
	self.stroke = C.NewPixelWand()

	self.SetBackgroundColor("none")

	self.SetStrokeColor("#ffffff")
	//self.SetStrokeAntialias(true)
	//self.SetStrokeWidth(1.0)
	//self.SetStrokeOpacity(1.0)
	//self.SetStrokeLineCap(STROKE_ROUND_CAP)
	//self.SetStrokeLineJoin(STROKE_ROUND_JOIN)

	self.SetFillColor("#000000")

	return self
}
Exemple #3
0
// Returns a TextProperties structure.
// Parameters:
//   read_default: if false, returns an empty structure.
//				   if true, returns a structure set with current canvas settings
func (self *Canvas) NewTextProperties(read_default bool) *TextProperties {
	if read_default == true {
		cfont := C.DrawGetFont(self.drawing)
		defer C.free(unsafe.Pointer(cfont))
		cfamily := C.DrawGetFontFamily(self.drawing)
		defer C.free(unsafe.Pointer(cfamily))
		csize := C.DrawGetFontSize(self.drawing)
		cweight := C.DrawGetFontWeight(self.drawing)
		calignment := C.DrawGetTextAlignment(self.drawing)
		cantialias := C.DrawGetTextAntialias(self.drawing)
		ckerning := C.DrawGetTextKerning(self.drawing)
		antialias := false
		if cantialias == C.MagickTrue {
			antialias = true
		}

		underColor := C.NewPixelWand()
		C.DrawGetTextUnderColor(self.drawing, underColor)
		return &TextProperties{
			Font:       C.GoString(cfont),
			Family:     C.GoString(cfamily),
			Size:       float64(csize),
			Weight:     uint(cweight),
			Alignment:  Alignment(calignment),
			Antialias:  antialias,
			Kerning:    float64(ckerning),
			UnderColor: underColor,
		}
	}
	return &TextProperties{
		UnderColor: C.NewPixelWand(),
	}
}
Exemple #4
0
// Returns a new canvas object.
func New() *Canvas {
	self := &Canvas{}

	self.wand = C.NewMagickWand()

	self.fg = C.NewPixelWand()
	self.bg = C.NewPixelWand()

	self.fill = C.NewPixelWand()
	self.stroke = C.NewPixelWand()

	self.drawing = C.NewDrawingWand()

	//self.SetColor("#ffffff")
	self.SetBackgroundColor("none")

	self.SetStrokeColor("#ffffff")
	self.SetStrokeAntialias(true)
	self.SetStrokeWidth(1.0)
	self.SetStrokeOpacity(1.0)
	self.SetStrokeLineCap(STROKE_ROUND_CAP)
	self.SetStrokeLineJoin(STROKE_ROUND_JOIN)

	//self.SetFillRule(FILL_EVEN_ODD_RULE)
	self.SetFillColor("#888888")

	self.text = self.NewTextProperties(true)

	return self
}
Exemple #5
0
// Private: Create a blank magick wand with size width and height
//
// Params:
// - format: format of the new image
// - width: width of the new image
// - height: height of the new image
//
// Examples
//  blankWand("jpg", 100, 100)
//
// Return *C.MagickWand
func blankWand(format string, width, height int) *C.MagickWand {
	wand := C.NewMagickWand()
	cformat := C.CString(format)
	noneBackground := C.CString("none")
	defer C.free(unsafe.Pointer(cformat))
	defer C.free(unsafe.Pointer(noneBackground))

	C.MagickSetFormat(wand, C.CString(format))
	pixel := C.NewPixelWand()
	defer C.DestroyPixelWand(pixel)

	C.PixelSetColor(pixel, noneBackground)
	C.MagickSetSize(wand, C.size_t(width), C.size_t(height))
	C.MagickNewImage(wand, C.size_t(width), C.size_t(height), pixel)
	return wand
}
Exemple #6
0
// Returns a new pixel wand
func NewPixelWand() *PixelWand {
	return &PixelWand{C.NewPixelWand()}
}