
# python wrapper for package github.com/tfuxu/dither-go/dither_go within overall package dither_go
# This is what you import to use the package.
# File is generated by gopy. Do not edit.
# gopy build -no-make -output=dither_go/bindings -vm=python3 ./dither_go github.com/tfuxu/dither-gopy

# the following is required to enable dlopen to open the _go.so file
import os,sys,inspect,collections
try:
	import collections.abc as _collections_abc
except ImportError:
	_collections_abc = collections

cwd = os.getcwd()
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
os.chdir(currentdir)
from . import _dither_go
from . import go

os.chdir(cwd)

# to use this code in your end-user python file, import it as follows:
# from dither_go import dither_go
# and then refer to everything using dither_go. prefix
# packages imported by this package listed below:




# ---- Types ---

# Python type for slice []color.Color
class Slice_color_Color(go.GoClass):
	""""""
	def __init__(self, *args, **kwargs):
		"""
		handle=A Go-side object is always initialized with an explicit handle=arg
		otherwise parameter is a python list that we copy from
		"""
		self.index = 0
		if len(kwargs) == 1 and 'handle' in kwargs:
			self.handle = kwargs['handle']
			_dither_go.IncRef(self.handle)
		elif len(args) == 1 and isinstance(args[0], go.GoClass):
			self.handle = args[0].handle
			_dither_go.IncRef(self.handle)
		else:
			self.handle = _dither_go.Slice_color_Color_CTor()
			_dither_go.IncRef(self.handle)
			if len(args) > 0:
				if not isinstance(args[0], _collections_abc.Iterable):
					raise TypeError('Slice_color_Color.__init__ takes a sequence as argument')
				for elt in args[0]:
					self.append(elt)
	def __del__(self):
		_dither_go.DecRef(self.handle)
	def __str__(self):
		s = 'dither_go.Slice_color_Color len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' ['
		if len(self) < 120:
			s += ', '.join(map(str, self)) + ']'
		return s
	def __repr__(self):
		return 'dither_go.Slice_color_Color([' + ', '.join(map(str, self)) + '])'
	def __len__(self):
		return _dither_go.Slice_color_Color_len(self.handle)
	def __getitem__(self, key):
		if isinstance(key, slice):
			if key.step == None or key.step == 1:
				st = key.start
				ed = key.stop
				if st == None:
					st = 0
				if ed == None:
					ed = _dither_go.Slice_color_Color_len(self.handle)
				return Slice_color_Color(handle=_dither_go.Slice_color_Color_subslice(self.handle, st, ed))
			return [self[ii] for ii in range(*key.indices(len(self)))]
		elif isinstance(key, int):
			if key < 0:
				key += len(self)
			if key < 0 or key >= len(self):
				raise IndexError('slice index out of range')
			return go.color_Color(handle=_dither_go.Slice_color_Color_elem(self.handle, key))
		else:
			raise TypeError('slice index invalid type')
	def __setitem__(self, idx, value):
		if idx < 0:
			idx += len(self)
		if idx < len(self):
			_dither_go.Slice_color_Color_set(self.handle, idx, value.handle)
			return
		raise IndexError('slice index out of range')
	def __iadd__(self, value):
		if not isinstance(value, _collections_abc.Iterable):
			raise TypeError('Slice_color_Color.__iadd__ takes a sequence as argument')
		for elt in value:
			self.append(elt)
		return self
	def __iter__(self):
		self.index = 0
		return self
	def __next__(self):
		if self.index < len(self):
			rv = _dither_go.Slice_color_Color_elem(self.handle, self.index)
			self.index = self.index + 1
			return rv
		raise StopIteration
	def append(self, value):
		_dither_go.Slice_color_Color_append(self.handle, value.handle)
	def copy(self, src):
		""" copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """
		mx = min(len(self), len(src))
		for i in range(mx):
			self[i] = src[i]


#---- Enums from Go (collections of consts with same type) ---


#---- Constants from Go: Python can only ask that you please don't change these! ---


# ---- Global Variables: can only use functions to access ---


# ---- Interfaces ---


# ---- Structs ---


# ---- Slices ---


# ---- Maps ---


# ---- Constructors ---


# ---- Functions ---
def CreatePalette(*args):
	"""CreatePalette([]object colors) []object
	
	CreatePalette creates a palette slice of variable amount
	of color.RGBA structures.
	
	WARNING: Always create color.RGBA values with CreateRGBA() function
	to avoid accessing invalid memory addresses.
	"""
	colors = Slice_color_Color(args)
	return Slice_color_Color(handle=_dither_go.dither_go_CreatePalette(colors.handle))
def CreateRGBA(r, g, b, a):
	"""CreateRGBA(int r, int g, int b, int a) object
	
	CreateRGBA creates new color.RGBA structure with
	provided (r,g,b,a) color channels.
	
	NOTE: Argument types are set to unint8, values higher than 255 will result
	in 'Out of range' errors.
	"""
	return go.color_RGBA(handle=_dither_go.dither_go_CreateRGBA(r, g, b, a))
def OpenImage(path):
	"""OpenImage(str path) object, str
	
	OpenImage opens image file and decodes its contents
	using image.Decode function.
	"""
	return go.image_Image(handle=_dither_go.dither_go_OpenImage(path))
def SaveImage(img_data, output_path, encode_format):
	"""SaveImage(object img_data, str output_path, str encode_format) str
	
	SaveImage saves provided image data in specified output path and
	encodes it to the supported format.
	"""
	return _dither_go.dither_go_SaveImage(img_data.handle, output_path, encode_format)


