Back to

Package coreanim

Latest Go to latest

The latest major version is .

Published: Dec 3, 2019 | License: BSD-3-Clause | Module:


Package coreanim provides access to Apple's Core Animation API (

This package is in very early stages of development. It's a minimal implementation with scope limited to supporting the movingtriangle example.


type Layer

type Layer interface {
	// Layer returns the underlying CALayer * pointer.
	Layer() unsafe.Pointer

Layer is an object that manages image-based content and allows you to perform animations on that content.


type MetalDrawable

type MetalDrawable struct {
	// contains filtered or unexported fields

MetalDrawable is a displayable resource that can be rendered or written to by Metal.


func (MetalDrawable) Drawable

func (md MetalDrawable) Drawable() unsafe.Pointer

Drawable implements the mtl.Drawable interface.

func (MetalDrawable) Texture

func (md MetalDrawable) Texture() mtl.Texture

Texture returns a Metal texture object representing the drawable object's content.


type MetalLayer

type MetalLayer struct {
	// contains filtered or unexported fields

MetalLayer is a Core Animation Metal layer, a layer that manages a pool of Metal drawables.


func MakeMetalLayer

func MakeMetalLayer() MetalLayer

MakeMetalLayer creates a new Core Animation Metal layer.


func (MetalLayer) Layer

func (ml MetalLayer) Layer() unsafe.Pointer

Layer implements the Layer interface.

func (MetalLayer) NextDrawable

func (ml MetalLayer) NextDrawable() (MetalDrawable, error)

NextDrawable returns a Metal drawable.


func (MetalLayer) PixelFormat

func (ml MetalLayer) PixelFormat() mtl.PixelFormat

PixelFormat returns the pixel format of textures for rendering layer content.


func (MetalLayer) SetDevice

func (ml MetalLayer) SetDevice(device mtl.Device)

SetDevice sets the Metal device responsible for the layer's drawable resources.


func (MetalLayer) SetDisplaySyncEnabled

func (ml MetalLayer) SetDisplaySyncEnabled(enabled bool)

SetDisplaySyncEnabled controls whether the Metal layer and its drawables are synchronized with the display's refresh rate.


func (MetalLayer) SetDrawableSize

func (ml MetalLayer) SetDrawableSize(width, height int)

SetDrawableSize sets the size, in pixels, of textures for rendering layer content.


func (MetalLayer) SetMaximumDrawableCount

func (ml MetalLayer) SetMaximumDrawableCount(count int)

SetMaximumDrawableCount controls the number of Metal drawables in the resource pool managed by Core Animation.

It can set to 2 or 3 only. SetMaximumDrawableCount panics for other values.


func (MetalLayer) SetPixelFormat

func (ml MetalLayer) SetPixelFormat(pf mtl.PixelFormat)

SetPixelFormat controls the pixel format of textures for rendering layer content.

The pixel format for a Metal layer must be PixelFormatBGRA8UNorm, PixelFormatBGRA8UNormSRGB, PixelFormatRGBA16Float, PixelFormatBGRA10XR, or PixelFormatBGRA10XRSRGB. SetPixelFormat panics for other values.


Package Files

Documentation was rendered with GOOS=darwin and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier