Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor blendmode_enum for v6 compatibility #45

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/zif/services/action_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def reset_actionables
# @param [Zif::Actions::Actionable] actionable
def register_actionable(actionable)
unless actionable.is_a?(Zif::Actions::Actionable)
raise ArgumentError, 'Zif::Services::ActionService#register_actionable:' /
raise ArgumentError, 'Zif::Services::ActionService#register_actionable:' \
" #{actionable} is not a Zif::Actions::Actionable"
end

Expand Down
18 changes: 3 additions & 15 deletions lib/zif/sprite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def initialize(name=Zif.unique_name('sprite'))
@g = 255
@b = 255
@angle = 0
self.blend = :alpha
self.blendmode_enum = :alpha
end

# @param [Hash<Symbol, Object>] sprite A hash of key-values to mass assign to a copy of this sprite.
Expand All @@ -169,22 +169,10 @@ def dup_and_assign(sprite)
# Set blend mode using either symbol names or the enum integer values.
# @param [Symbol, Integer] new_blendmode {blend} +:none+, +:alpha+, +:add+, +:mod+, +:multiply+ or +0+, +1+, +2+, +3+, +4+. See {BLENDMODE}
# @return [Integer] The integer value for the specified blend mode
def blend=(new_blendmode)
@blendmode = BLENDMODE.fetch(new_blendmode, new_blendmode)
def blendmode_enum=(new_blendmode)
@blendmode_enum = BLENDMODE.fetch(new_blendmode, new_blendmode)
end

alias blendmode_enum= blend=

# @return [Integer] The integer value for the specified blend mode. See {BLENDMODE}
# @example This always returns an integer, even if you set it using a symbol
# mysprite.blend = :alpha # => 1
# mysprite.blend # => 1
def blend
@blendmode
end

alias blendmode_enum blend

# Sets {a} alpha to 255 (fully opaque)
def show
@a = 255
Expand Down