// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// MediaAreaCoordinates represents TL type `mediaAreaCoordinates#3d1ea4e`.
// Coordinates and size of a clicable rectangular area on top of a story.
//
// See https://core.telegram.org/constructor/mediaAreaCoordinates for reference.
type MediaAreaCoordinates struct {
	// The abscissa of the rectangle's center, as a percentage of the media width (0-100).
	X float64
	// The ordinate of the rectangle's center, as a percentage of the media height (0-100).
	Y float64
	// The width of the rectangle, as a percentage of the media width (0-100).
	W float64
	// The height of the rectangle, as a percentage of the media height (0-100).
	H float64
	// Clockwise rotation angle of the rectangle, in degrees (0-360).
	Rotation float64
}

// MediaAreaCoordinatesTypeID is TL type id of MediaAreaCoordinates.
const MediaAreaCoordinatesTypeID = 0x3d1ea4e

// Ensuring interfaces in compile-time for MediaAreaCoordinates.
var (
	_ bin.Encoder     = &MediaAreaCoordinates{}
	_ bin.Decoder     = &MediaAreaCoordinates{}
	_ bin.BareEncoder = &MediaAreaCoordinates{}
	_ bin.BareDecoder = &MediaAreaCoordinates{}
)

func ( *MediaAreaCoordinates) () bool {
	if  == nil {
		return true
	}
	if !(.X == 0) {
		return false
	}
	if !(.Y == 0) {
		return false
	}
	if !(.W == 0) {
		return false
	}
	if !(.H == 0) {
		return false
	}
	if !(.Rotation == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *MediaAreaCoordinates) () string {
	if  == nil {
		return "MediaAreaCoordinates(nil)"
	}
	type  MediaAreaCoordinates
	return fmt.Sprintf("MediaAreaCoordinates%+v", (*))
}

// FillFrom fills MediaAreaCoordinates from given interface.
func ( *MediaAreaCoordinates) ( interface {
	() ( float64)
	() ( float64)
	() ( float64)
	() ( float64)
	() ( float64)
}) {
	.X = .()
	.Y = .()
	.W = .()
	.H = .()
	.Rotation = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MediaAreaCoordinates) () uint32 {
	return MediaAreaCoordinatesTypeID
}

// TypeName returns name of type in TL schema.
func (*MediaAreaCoordinates) () string {
	return "mediaAreaCoordinates"
}

// TypeInfo returns info about TL type.
func ( *MediaAreaCoordinates) () tdp.Type {
	 := tdp.Type{
		Name: "mediaAreaCoordinates",
		ID:   MediaAreaCoordinatesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "X",
			SchemaName: "x",
		},
		{
			Name:       "Y",
			SchemaName: "y",
		},
		{
			Name:       "W",
			SchemaName: "w",
		},
		{
			Name:       "H",
			SchemaName: "h",
		},
		{
			Name:       "Rotation",
			SchemaName: "rotation",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MediaAreaCoordinates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode mediaAreaCoordinates#3d1ea4e as nil")
	}
	.PutID(MediaAreaCoordinatesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MediaAreaCoordinates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode mediaAreaCoordinates#3d1ea4e as nil")
	}
	.PutDouble(.X)
	.PutDouble(.Y)
	.PutDouble(.W)
	.PutDouble(.H)
	.PutDouble(.Rotation)
	return nil
}

// Decode implements bin.Decoder.
func ( *MediaAreaCoordinates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode mediaAreaCoordinates#3d1ea4e to nil")
	}
	if  := .ConsumeID(MediaAreaCoordinatesTypeID);  != nil {
		return fmt.Errorf("unable to decode mediaAreaCoordinates#3d1ea4e: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MediaAreaCoordinates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode mediaAreaCoordinates#3d1ea4e to nil")
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#3d1ea4e: field x: %w", )
		}
		.X = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#3d1ea4e: field y: %w", )
		}
		.Y = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#3d1ea4e: field w: %w", )
		}
		.W = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#3d1ea4e: field h: %w", )
		}
		.H = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#3d1ea4e: field rotation: %w", )
		}
		.Rotation = 
	}
	return nil
}

// GetX returns value of X field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .X
}

// GetY returns value of Y field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .Y
}

// GetW returns value of W field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .W
}

// GetH returns value of H field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .H
}

// GetRotation returns value of Rotation field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .Rotation
}