Class: Shoes::Shape

Inherits:
Slot show all
Defined in:
lacci/lib/shoes/drawables/shape.rb

Overview

A Shape acts as a sort of union type for drawn shapes. In Shoes you can use it to merge multiple ovals, arcs, stars, etc. into a single drawn shape.

In Shoes3, a Shape isn't really a Slot. It's a kind of DSL with drawing commands that happen to have the same name as the Art drawables like star, arc, etc. Here we're treating it as a slot containing those drawables, which is wrong but not too wrong.

Incompatibilities with Shoes:

  • A Shoes3 Shape is not a slot; Scarpe does not do union shapes

Constant Summary

Constants inherited from Drawable

Drawable::DRAW_CONTEXT_STYLES

Constants included from Log

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

Instance Attribute Summary

Attributes inherited from Slot

#children, #draw_context

Attributes inherited from Drawable

#debug_id, #destroyed, #parent

Attributes inherited from Linkable

#linkable_id

Instance Method Summary collapse

Methods inherited from Slot

#add_child, #append, #clear, #contents, #current_draw_context, #fill, #method_missing, #nofill, #nostroke, #remove_child, #respond_to_missing?, #rotate, #stroke, #strokewidth

Methods inherited from Drawable

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, use_current_app, validate_as, with_current_app

Methods included from MarginHelper

#margin_parse

Methods included from Colors

#gray, #rgb, #to_rgb

Methods included from Log

configure_logger, #log_init, logger

Methods inherited from Linkable

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

Constructor Details

#initialize(**kwargs, &block) ⇒ Shape

Returns a new instance of Shape.

[View source]

17
18
19
20
21
22
23
24
25
# File 'lacci/lib/shoes/drawables/shape.rb', line 17

def initialize(**kwargs, &block)
  @shape_commands = []

  super
  @draw_context = @app.current_draw_context
  create_display_drawable

  @app.with_slot(self, &block) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Shoes::Slot

Instance Method Details

#add_shape_command(cmd) ⇒ Object

The cmd should be an array of the form:

[cmd_name, *args]

such as ["move_to", 50, 50]. Note that these must be JSON-serializable.

[View source]

33
34
35
# File 'lacci/lib/shoes/drawables/shape.rb', line 33

def add_shape_command(cmd)
  @shape_commands << cmd
end