Sha256: 42549dbc97abcc740dfdf53975b811d16fed5cd1c02caf721daf8d4cce8f86c6

Contents?: true

Size: 1.27 KB

Versions: 30

Compression:

Stored size: 1.27 KB

Contents

# 「ペン」ジャンル

<%
  category = 'pen'
  require 'smalruby_editor'
  require 'smalruby_editor/blockly_message_helper'
  color = SmalrubyEditor::COLORS[category.to_sym]
%>

# ペンを下ろす
# ペンを上げる
# <%
  %w(down_pen up_pen).each do |suffix|
    n = "#{category}_#{suffix}"
%>

Blockly.Blocks['<%= n %>'] =
  init: ()->
    @setHelpUrl('')
    @setColour(<%= color %>)
    @appendDummyInput()
      .appendField(<%= bm(".#{suffix}") %>)
    @setPreviousStatement(true)
    @setNextStatement(true)
    @setTooltip('')

Blockly.Ruby['<%= n %>'] = (block) ->
  Blockly.Ruby.characterMethodCall_('<%= suffix %>')
<% end %>

# ペンの色を[カラー]にする
<% n = "#{category}_set_pen_color" %>
Blockly.Blocks['<%= n %>'] =
  init: ()->
    @setHelpUrl('')
    @setColour(<%= color %>)
    @interpolateMsg(<%= bm('.set_pen_color') %>,
                    ['COLOUR', new Blockly.FieldColour('#ff0000')],
                    Blockly.ALIGN_RIGHT)
    @setPreviousStatement(true)
    @setNextStatement(true)
    @setTooltip('')

Blockly.Ruby['<%= n %>'] = (block) ->
  c = @getFieldValue('COLOUR')
  red = parseInt(c[1..2], 16)
  green = parseInt(c[3..4], 16)
  blue = parseInt(c[5..6], 16)
  Blockly.Ruby.characterSetVariable_('pen_color', "[#{red}, #{green}, #{blue}]")

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
smalruby-editor-0.4.1-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.4.2-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.4.2 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.4.1 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.4.0-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.4.0 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.5-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.5 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.4-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.4 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.3-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.3 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.2-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.2 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.1-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.1 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.0-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.3.0 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.2.7-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.2.7 app/assets/javascripts/blocks/pen.js.coffee.erb