Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

img_to_script-mk90_client_api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

img_to_script-mk90_client_api

  • 0.1.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

img_to_script-mk90_client_api

Provides a handy API between an img_to_mk90_bas application and the img_to_script gem. Instead of working with the img_to_script objects directly, just pass a hash with parameters to the img_to_script-mk90_client_api. This is handy when you get the parameters as a JSON string, e.g. from a web front-end.

Installation

Add this line to your application's Gemfile:

gem "img_to_script-mk90_client_api"

And then execute:

$ bundle install

Or install it yourself as:

$ gem install img_to_script-mk90_client_api

Usage

ImgToScript::MK90ClientAPI.call(query) -> Array<String>

Argument

query: hash with parameters.

Returns

Generated BASIC program.

Raises

  • ImgToScript::MK90ClientAPI::QueryError

    A key is missing, has a value of an unsupported type, or has an illegal value.

  • ImgToScript::MK90ClientAPI::InvalidImage

    Invalid image: the image can't be decoded from the base64 string.

Query description

KeyTypeNecessityDescriptionAllowed values
:basic_versionStringRequiredDefines target BASIC version
  • 1.0
  • 2.0
:encoding_methodStringRequiredDefines target encoding method
  • hex_mask_enhanced
  • hex_mask_default
  • rle_v
  • rle_h
  • segmental_direct_v
  • segmental_direct_h
  • segmental_data_v
  • segmental_data_h
:imageStringRequiredImage to convertA base64-encoded image
:output_formatStringRequiredDefines output format
  • bas
:generator_optionsHash{ Symbol => Object }OptionalDefines script generator options-
:formatter_optionsHash{ Symbol => Object }OptionalDefines script formatter options-

Generator options

KeyTypeNecessityDescriptionAllowed values
:x_offsetIntegerOptionalDefines image horizontal offset-120..120
:y_offsetIntegerOptionalDefines image vertical offset-64..64
:clear_screenBooleanOptionalAdd a clear screen statementtrue/false
:pause_programBooleanOptionalAdd a pause statementtrue/false

Formatter options

KeyTypeNecessityDescriptionAllowed values
:line_offsetIntegerOptionalDefines first BASIC line offset1..8000
:line_stepIntegerOptionalDefines step between BASIC lines1..100

Usage example

require "img_to_script/mk90_client_api"
require "rmagick"

def self.read_image(filename)
  img = Magick::Image.read(filename).first
  img.colorspace = Magick::GRAYColorspace
  Base64.strict_encode64(
    img.to_blob
  )
end

script = ImgToScript::MK90ClientAPI.call(
  {
    basic_version: "1.0",
    encoding_method: "hex_mask_enhanced",
    image: read_image("my_image.png"),
    output_format: "bas",
    generator_options: {
      x_offset: -5,
      y_offset: -10
    },
    formatter_options: {
      line_offset: 10,
      line_step: 5
    }
  }
)

puts script

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/8bit-mate/img_to_script-mk90_client_api.rb.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 29 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc