canvas: github.com/gosexy/canvas Index | Files | Directories

package canvas

import "github.com/gosexy/canvas"

Index

Package Files

canvas.go constants.go pixel.go pixel_iterator.go text.go

Constants

const (
    STROKE_BUTT_CAP   = uint(C.ButtCap)
    STROKE_ROUND_CAP  = uint(C.RoundCap)
    STROKE_SQUARE_CAP = uint(C.SquareCap)

    STROKE_MITER_JOIN = uint(C.MiterJoin)
    STROKE_ROUND_JOIN = uint(C.RoundJoin)
    STROKE_BEVEL_JOIN = uint(C.BevelJoin)

    FILL_EVEN_ODD_RULE = uint(C.EvenOddRule)
    FILL_NON_ZERO_RULE = uint(C.NonZeroRule)

    RAD_TO_DEG = 180 / math.Pi
    DEG_TO_RAD = math.Pi / 180

    UNDEFINED_ORIENTATION    = uint(C.UndefinedOrientation)
    TOP_LEFT_ORIENTATION     = uint(C.TopLeftOrientation)
    TOP_RIGHT_ORIENTATION    = uint(C.TopRightOrientation)
    BOTTOM_RIGHT_ORIENTATION = uint(C.BottomRightOrientation)
    BOTTOM_LEFT_ORIENTATION  = uint(C.BottomLeftOrientation)
    LEFT_TOP_ORIENTATION     = uint(C.LeftTopOrientation)
    RIGHT_TOP_ORIENTATION    = uint(C.RightTopOrientation)
    RIGHT_BOTTOM_ORIENTATION = uint(C.RightBottomOrientation)
    LEFT_BOTTOM_ORIENTATION  = uint(C.LeftBottomOrientation)

    POINT_FILTER          = uint(C.PointFilter)
    BOX_FILTER            = uint(C.BoxFilter)
    TRIANGLE_FILTER       = uint(C.TriangleFilter)
    HERMITE_FILTER        = uint(C.HermiteFilter)
    HANNING_FILTER        = uint(C.HanningFilter)
    HAMMING_FILTER        = uint(C.HammingFilter)
    BLACKMAN_FILTER       = uint(C.BlackmanFilter)
    GAUSSIAN_FILTER       = uint(C.GaussianFilter)
    QUADRATIC_FILTER      = uint(C.QuadraticFilter)
    CUBIC_FILTER          = uint(C.CubicFilter)
    CATROM_FILTER         = uint(C.CatromFilter)
    MITCHEL_FILTER        = uint(C.MitchellFilter)
    BESSEL_FILTER         = uint(C.BesselFilter)
    JINC_FILTER           = uint(C.BesselFilter)
    SINC_FAST_FILTER      = uint(C.SincFastFilter)
    SINC_FILTER           = uint(C.SincFilter)
    KAISER_FILTER         = uint(C.KaiserFilter)
    WELSH_FILTER          = uint(C.WelshFilter)
    PARZEN_FILTER         = uint(C.ParzenFilter)
    BOHMAN_FILTER         = uint(C.BohmanFilter)
    BARTLETT_FILTER       = uint(C.BartlettFilter)
    LAGRANGE_FILTER       = uint(C.LagrangeFilter)
    LANCZOS_FILTER        = uint(C.LanczosFilter)
    LANCZOS_SHARP_FILTER  = uint(C.LanczosSharpFilter)
    LANCZOS2_FILTER       = uint(C.Lanczos2Filter)
    LANCZOS2_SHARP_FILTER = uint(C.Lanczos2SharpFilter)
    ROBIDOUX_FILTER       = uint(C.RobidouxFilter)

    UNDEFINED_TYPE              = uint(C.UndefinedType)
    BILEVEL_TYPE                = uint(C.BilevelType)
    GRAYSCALE_TYPE              = uint(C.GrayscaleType)
    GRAYSCALE_MATTER_TYPE       = uint(C.GrayscaleMatteType)
    PALETTE_TYPE                = uint(C.PaletteType)
    PALETTE_MATTE_TYPE          = uint(C.PaletteMatteType)
    TRUE_COLOR_TYPE             = uint(C.TrueColorType)
    TRUE_COLOR_MATTE_TYPE       = uint(C.TrueColorMatteType)
    COLOR_SEPARATION_TYPE       = uint(C.ColorSeparationType)
    COLOR_SEPARATION_MATTE_TYPE = uint(C.ColorSeparationMatteType)
    OPTIMIZE_TYPE               = uint(C.OptimizeType)

    UNDEFINED_INTERLACE = uint(C.UndefinedInterlace)
    NO_INTERLACE        = uint(C.NoInterlace)
    LINE_INTERLACE      = uint(C.LineInterlace)
    PLANE_INTERLACE     = uint(C.PlaneInterlace)
    PARTITION_INTERLACE = uint(C.PartitionInterlace)
    GIF_INTERLACE       = uint(C.GIFInterlace)
    JPEG_INTERLACE      = uint(C.JPEGInterlace)
    PNG_INTERLACE       = uint(C.PNGInterlace)

    UNDEFINED_GRAVITY  = uint(C.UndefinedGravity)
    FORGET_GRAVITY     = uint(C.ForgetGravity)
    NORTH_WEST_GRAVITY = uint(C.NorthWestGravity)
    NORTH_GRAVITY      = uint(C.NorthGravity)
    NORTH_EAST_GRAVITY = uint(C.NorthEastGravity)
    WEST_GRAVITY       = uint(C.WestGravity)
    CENTER_GRAVITY     = uint(C.CenterGravity)
    EAST_GRAVITY       = uint(C.EastGravity)
    SOUTH_WEST_GRAVITY = uint(C.SouthWestGravity)
    SOUTH_GRAVITY      = uint(C.SouthGravity)
    SOUTH_EAST_GRAVITY = uint(C.SouthEastGravity)
)

func Finalize Uses

func Finalize()

type Alignment Uses

type Alignment uint
const (
    UndefinedAlign Alignment = Alignment(C.UndefinedAlign)
    LeftAlign                = Alignment(C.LeftAlign)
    CenterAlign              = Alignment(C.CenterAlign)
    RightAlign               = Alignment(C.RightAlign)
)

type Canvas Uses

type Canvas struct {
    // contains filtered or unexported fields
}

Holds a Canvas object

func New Uses

func New() *Canvas

Returns a new canvas object.

func (*Canvas) AdaptiveBlur Uses

func (self *Canvas) AdaptiveBlur(sigma float64) error

Adaptively blurs the image by blurring less intensely near the edges and more intensely far from edges.

func (*Canvas) AdaptiveResize Uses

func (self *Canvas) AdaptiveResize(width uint, height uint) error

Adaptively changes the size of the canvas, returns true on success.

func (*Canvas) AddNoise Uses

func (self *Canvas) AddNoise() error

Adds random noise to the canvas.

func (*Canvas) Annotate Uses

func (self *Canvas) Annotate(text string, x, y float64)

Draws a string at the specified coordinates and using the current canvas Alignment.

func (*Canvas) AnnotateWithProperties Uses

func (self *Canvas) AnnotateWithProperties(text string, x, y float64, prop *TextProperties)

Draws a string at the specified coordinates and using the specified Text Properties Does not modify the canvas' default TextProperties

func (*Canvas) AppendCanvas Uses

func (self *Canvas) AppendCanvas(source *Canvas, x int, y int) error

Puts a canvas on top of the current one.

func (*Canvas) AutoOrientate Uses

func (self *Canvas) AutoOrientate() error

Auto-orientates canvas based on its original image's EXIF metadata

func (*Canvas) BackgroundColor Uses

func (self *Canvas) BackgroundColor() string

Returns canvas' background color.

func (*Canvas) Blank Uses

func (self *Canvas) Blank(width uint, height uint) error

Creates an empty canvas of the given dimensions.

func (*Canvas) Blob Uses

func (self *Canvas) Blob() ([]byte, error)

func (*Canvas) Blur Uses

func (self *Canvas) Blur(sigma float64) error

Convolves the canvas with a Gaussian function given its standard deviation.

func (*Canvas) Chop Uses

func (self *Canvas) Chop(x int, y int, width uint, height uint) error

Removes a region of a canvas and collapses the canvas to occupy the removed portion.

func (*Canvas) Circle Uses

func (self *Canvas) Circle(radius float64)

Draws a circle over the current drawing surface.

func (*Canvas) Clone Uses

func (self *Canvas) Clone() *Canvas

Clones an image to another canvas

func (*Canvas) Contrast Uses

func (self *Canvas) Contrast(sharpen bool) error

Enhances the intensity differences between the lighter and darker elements of the image. Set sharpen to a value other than 0 to increase the image contrast otherwise the contrast is reduced.

func (*Canvas) Crop Uses

func (self *Canvas) Crop(x int, y int, width uint, height uint) error

Extracts a region from the canvas.

func (*Canvas) Destroy Uses

func (self *Canvas) Destroy() error

Destroys canvas.

func (*Canvas) DrawAnnotation Uses

func (self *Canvas) DrawAnnotation(content string, width, height uint) error

func (*Canvas) Ellipse Uses

func (self *Canvas) Ellipse(a float64, b float64)

Draws an ellipse centered at the current coordinate system's origin.

func (*Canvas) Error Uses

func (self *Canvas) Error() error

Returns the latest error reported by the MagickWand API.

func (*Canvas) FillColor Uses

func (self *Canvas) FillColor() string

Returns the fill color for enclosed areas on the current drawing surface.

func (*Canvas) Fit Uses

func (self *Canvas) Fit(width uint, height uint) error

Creates a thumbnail that fits within the given dimensions

func (*Canvas) Flip Uses

func (self *Canvas) Flip() error

Creates a vertical mirror image by reflecting the pixels around the central x-axis.

func (*Canvas) Flop Uses

func (self *Canvas) Flop() error

Creates a horizontal mirror image by reflecting the pixels around the central y-axis.

func (*Canvas) Font Uses

func (self *Canvas) Font() (string, float64)

Returns canvas' current font name and size

func (*Canvas) FontFamily Uses

func (self *Canvas) FontFamily() string

Returns canvas' current font family

func (*Canvas) FontName Uses

func (self *Canvas) FontName() string

Returns canvas' current font name

func (*Canvas) FontSize Uses

func (self *Canvas) FontSize() float64

Returns canvas' current font size

func (*Canvas) FontWeight Uses

func (self *Canvas) FontWeight() uint

Returns canvas' current font weight

func (*Canvas) Format Uses

func (self *Canvas) Format() string

func (*Canvas) GetFormat Uses

func (self *Canvas) GetFormat() string

func (*Canvas) GetImageBlob Uses

func (self *Canvas) GetImageBlob() ([]byte, error)

func (*Canvas) Height Uses

func (self *Canvas) Height() uint

Returns canvas' height.

func (*Canvas) InterlaceScheme Uses

func (self *Canvas) InterlaceScheme() uint

func (*Canvas) Line Uses

func (self *Canvas) Line(x float64, y float64)

Draws a line starting on the current coordinate system origin and ending on the specified coordinates.

func (*Canvas) Metadata Uses

func (self *Canvas) Metadata() map[string]string

Returns all metadata keys from the currently loaded image.

func (*Canvas) NewTextProperties Uses

func (self *Canvas) NewTextProperties(readDefault bool) *TextProperties

Returns a TextProperties structure. Parameters:

  readDefault: if false, returns an empty structure.
				  if true, returns a structure set with current canvas settings

func (*Canvas) Open Uses

func (self *Canvas) Open(filename string) error

Opens an image file, returns nil on success, error otherwise.

func (*Canvas) OpenBlob Uses

func (self *Canvas) OpenBlob(blob []byte, length uint) error

Reads an image or image sequence from a blob.

func (*Canvas) PixelIterator Uses

func (self *Canvas) PixelIterator(x, y int, width, height uint) *PixelIterator

func (*Canvas) PopDrawing Uses

func (self *Canvas) PopDrawing() error

Destroys the current drawing surface and returns the latest surface that was pushed to the stack.

func (*Canvas) PushDrawing Uses

func (self *Canvas) PushDrawing() error

Clones the current drawing surface and stores it in a stack.

func (*Canvas) Quality Uses

func (self *Canvas) Quality() uint

Returns the compression quality of the canvas. Ranges from 1 (lowest) to 100 (highest).

func (*Canvas) QuantumRange Uses

func (self *Canvas) QuantumRange() uint

func (*Canvas) Rectangle Uses

func (self *Canvas) Rectangle(x float64, y float64)

Draws a rectangle over the current drawing surface.

func (*Canvas) Resize Uses

func (self *Canvas) Resize(width uint, height uint) error

Changes the size of the canvas, returns true on success.

func (*Canvas) ResizeWithFilter Uses

func (self *Canvas) ResizeWithFilter(width uint, height uint, filter uint, blur float32) error

Changes the size of the canvas using specified filter and blur, returns true on success.

func (*Canvas) Rotate Uses

func (self *Canvas) Rotate(rad float64)

Applies a rotation of a given angle (in radians) on the current coordinate system.

func (*Canvas) RotateCanvas Uses

func (self *Canvas) RotateCanvas(rad float64) error

Rotates the whole canvas.

func (*Canvas) Scale Uses

func (self *Canvas) Scale(x float64, y float64)

Applies a scaling factor to the units of the current coordinate system.

func (*Canvas) SetBackgroundColor Uses

func (self *Canvas) SetBackgroundColor(color string) error

Sets canvas' background color.

func (*Canvas) SetBrightness Uses

func (self *Canvas) SetBrightness(factor float64) error

Adjusts the canvas's brightness given a factor (-1.0 thru 1.0)

func (*Canvas) SetCaption Uses

func (self *Canvas) SetCaption(content string) error

func (*Canvas) SetColor Uses

func (self *Canvas) SetColor(color string) bool

Sets canvas's foreground color.

func (*Canvas) SetContrast Uses

func (self *Canvas) SetContrast(factor float64) error

func (*Canvas) SetFillColor Uses

func (self *Canvas) SetFillColor(color string)

Sets the fill color for enclosed areas on the current drawing surface.

func (*Canvas) SetFont Uses

func (self *Canvas) SetFont(font string, size float64)

Sets canvas' font name and size. If font is 0-length, the current font family is not changed If size is <= 0, the current font size is not changed

func (*Canvas) SetFontFamily Uses

func (self *Canvas) SetFontFamily(family string)

Sets canvas' default font family

func (*Canvas) SetFontName Uses

func (self *Canvas) SetFontName(font string)

Sets canvas' default font name

func (*Canvas) SetFontSize Uses

func (self *Canvas) SetFontSize(size float64)

Sets canvas' default font size

func (*Canvas) SetFontWeight Uses

func (self *Canvas) SetFontWeight(weight uint)

Sets canvas' default font weight

func (*Canvas) SetFormat Uses

func (self *Canvas) SetFormat(format string) error

Sets the format of a particular image

func (*Canvas) SetGravity Uses

func (self *Canvas) SetGravity(gravity uint)

func (*Canvas) SetHue Uses

func (self *Canvas) SetHue(factor float64) error

Adjusts the canvas's hue given a factor (-1.0 thru 1.0)

func (*Canvas) SetInterlaceScheme Uses

func (self *Canvas) SetInterlaceScheme(scheme uint) error

func (*Canvas) SetMetadata Uses

func (self *Canvas) SetMetadata(key string, value string) error

Associates a metadata key with its value.

func (*Canvas) SetOption Uses

func (self *Canvas) SetOption(key, value string) error

func (*Canvas) SetQuality Uses

func (self *Canvas) SetQuality(quality uint) error

Changes the compression quality of the canvas. Ranges from 1 (lowest) to 100 (highest).

func (*Canvas) SetSaturation Uses

func (self *Canvas) SetSaturation(factor float64) error

Adjusts the canvas's saturation given a factor (-1.0 thru 1.0)

func (*Canvas) SetSepiaTone Uses

func (self *Canvas) SetSepiaTone(threshold float64) error

func (*Canvas) SetSize Uses

func (self *Canvas) SetSize(width, height uint) error

func (*Canvas) SetStrokeAntialias Uses

func (self *Canvas) SetStrokeAntialias(value bool)

Sets antialiasing setting for the current drawing stroke.

func (*Canvas) SetStrokeColor Uses

func (self *Canvas) SetStrokeColor(color string)

Sets the stroke color on the current drawing surface.

func (*Canvas) SetStrokeLineCap Uses

func (self *Canvas) SetStrokeLineCap(value uint)

Sets the type of the line cap on the current drawing surface.

func (*Canvas) SetStrokeLineJoin Uses

func (self *Canvas) SetStrokeLineJoin(value uint)

Sets the type of the line join on the current drawing surface.

func (*Canvas) SetStrokeOpacity Uses

func (self *Canvas) SetStrokeOpacity(value float64)

Sets the opacity of the stroke on the current drawing surface.

func (*Canvas) SetStrokeWidth Uses

func (self *Canvas) SetStrokeWidth(value float64)

Sets the width of the stroke on the current drawing surface.

func (*Canvas) SetTextAlignment Uses

func (self *Canvas) SetTextAlignment(a Alignment)

Sets canvas' default text alignment. Available values are: UndefinedAlign (?), LeftAlign, CenterAlign, RightAlign

func (*Canvas) SetTextAntialias Uses

func (self *Canvas) SetTextAntialias(b bool)

Sets canvas' default text antialiasing option.

func (*Canvas) SetTextKerning Uses

func (self *Canvas) SetTextKerning(k float64)

Sets canvas' default text antialiasing option.

func (*Canvas) SetTextProperties Uses

func (self *Canvas) SetTextProperties(def *TextProperties)

Sets canvas' default TextProperties

func (*Canvas) SetType Uses

func (self *Canvas) SetType(imageType uint) error

func (*Canvas) SharpenImage Uses

func (self *Canvas) SharpenImage(radius float32, sigma float32, channel int) error

Sharpens an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and selects a suitable radius for you. You can pass 0 as channel number - to use default channels

func (*Canvas) SigmoidalContrast Uses

func (self *Canvas) SigmoidalContrast(sharpen bool, alpha float64, beta float64) error

Adjusts the contrast of an image with a non-linear sigmoidal contrast algorithm. Increase the contrast of the image using a sigmoidal transfer function without saturating highlights or shadows. Contrast indicates how much to increase the contrast (0 is none; 3 is typical; 20 is pushing it); mid-point indicates where midtones fall in the resultant image (0 is white; 50 is middle-gray; 100 is black). Set sharpen to true to increase the image contrast otherwise the contrast is reduced.

func (*Canvas) Strip Uses

func (self *Canvas) Strip() error

func (*Canvas) StrokeAntialias Uses

func (self *Canvas) StrokeAntialias() bool

Returns antialiasing setting for the current drawing stroke.

func (*Canvas) StrokeColor Uses

func (self *Canvas) StrokeColor() string

Returns the stroke color on the current drawing surface.

func (*Canvas) StrokeLineCap Uses

func (self *Canvas) StrokeLineCap() uint

Returns the type of the line cap on the current drawing surface.

func (*Canvas) StrokeLineJoin Uses

func (self *Canvas) StrokeLineJoin() uint

Returns the type of the line join on the current drawing surface.

func (*Canvas) StrokeOpacity Uses

func (self *Canvas) StrokeOpacity() float64

Returns the opacity of the stroke on the current drawing surface.

func (*Canvas) StrokeWidth Uses

func (self *Canvas) StrokeWidth() float64

Returns the width of the stroke on the current drawing surface.

func (*Canvas) TextAlignment Uses

func (self *Canvas) TextAlignment() Alignment

Returns the canvas' current text aligment

func (*Canvas) TextAntialias Uses

func (self *Canvas) TextAntialias() bool

Returns the canvas' current text aligment

func (*Canvas) TextKerning Uses

func (self *Canvas) TextKerning() float64

Returns the canvas' current text aligment

func (*Canvas) TextProperties Uses

func (self *Canvas) TextProperties() *TextProperties

Gets a copy of canvas' current TextProperties

func (*Canvas) Thumbnail Uses

func (self *Canvas) Thumbnail(width uint, height uint) error

Converts the current image into a thumbnail of the specified width and height preserving ratio. It uses Crop() to clip the image to the specified area.

If width or height are bigger than the current image, a centered thumbnail will be produced.

Is width and height are smaller than the current image, the image will be resized and cropped, if needed.

func (*Canvas) Translate Uses

func (self *Canvas) Translate(x float64, y float64)

Moves the current coordinate system origin to the specified coordinate.

func (*Canvas) Type Uses

func (self *Canvas) Type() uint

func (*Canvas) Update Uses

func (self *Canvas) Update() error

Copies a drawing surface to the canvas.

func (*Canvas) Width Uses

func (self *Canvas) Width() uint

Returns canvas' width.

func (*Canvas) Write Uses

func (self *Canvas) Write(filename string) error

Writes canvas to a file, returns true on success.

type Pixel Uses

type Pixel struct {
    // contains filtered or unexported fields
}

func (*Pixel) Blue Uses

func (self *Pixel) Blue() float64

func (*Pixel) Destroy Uses

func (self *Pixel) Destroy()

func (*Pixel) Green Uses

func (self *Pixel) Green() float64

func (*Pixel) Red Uses

func (self *Pixel) Red() float64

func (*Pixel) SetColor Uses

func (self *Pixel) SetColor(color string) error

type PixelIterator Uses

type PixelIterator struct {
    // contains filtered or unexported fields
}

func (*PixelIterator) Destroy Uses

func (self *PixelIterator) Destroy()

func (*PixelIterator) Error Uses

func (self *PixelIterator) Error() error

func (*PixelIterator) NextRow Uses

func (self *PixelIterator) NextRow() (row []*Pixel)

func (*PixelIterator) Sync Uses

func (self *PixelIterator) Sync() error

type TextProperties Uses

type TextProperties struct {
    Font   string
    Family string
    Size   float64
    // Stretch		C.StretchType
    Weight uint
    // Style		C.StyleType
    // Resolution  [2]C.double
    Alignment Alignment
    Antialias bool
    // Decoration	C.DecorationType
    // Encoding	string
    Kerning float64
    // Interline	float64
    // Interword	float64
    UnderColor *C.PixelWand
}

structure containing all text properties for an annotation except the colors that are defined by FillColor and StrokeColor

Directories

PathSynopsis
_examples

Package canvas imports 8 packages (graph) and is imported by 1 packages. Updated 2016-07-15. Refresh now. Tools for package owners.