Sha256: eddb56c581bf5b5c13d06d3210719e7f730a3449628d92da78ce4fcd2df83f75

Contents?: true

Size: 714 Bytes

Versions: 6

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true

require 'mikunyan/base_object'
require 'mikunyan/decoders/image_decoder'

module Mikunyan
  module CustomTypes
    class Texture2D < Mikunyan::BaseObject
      Mikunyan::CustomTypes.set_custom_type(self, 'Texture2D')

      # Generates an png image (an instance of {ChunkyPNG::Image}) from the texture data
      def generate_png
        Mikunyan::Decoder::ImageDecoder.decode_object(self)
      end

      def width
        @attr['m_Width']&.value
      end

      def height
        @attr['m_Height']&.value
      end

      def texture_format
        @attr['m_TextureFormat']&.value
      end

      def mipmap_count
        @attr['m_MipCount']&.value
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mikunyan-3.9.12 lib/mikunyan/types/texture2d.rb
mikunyan-3.9.11 lib/mikunyan/types/texture2d.rb
mikunyan-3.9.10 lib/mikunyan/types/texture2d.rb
mikunyan-3.9.9 lib/mikunyan/types/texture2d.rb
mikunyan-3.9.8 lib/mikunyan/types/texture2d.rb
mikunyan-3.9.7 lib/mikunyan/types/texture2d.rb