Sha256: 24fb6ee9daa3e4898d949b4b4d81366cb9a066bd4eed84cb1fc512e9b75ccb65

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

# 「ペン」ジャンル

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

# ペンを下ろす
# ペンを上げる
# <%
  [
    ['down_pen', 'ペンを下ろす'],
    ['up_pen', 'ペンを上げる'],
  ].each do |suffix, label|
    n = "#{category}_#{suffix}"
%>

Blockly.Blocks['<%= n %>'] =
  init: ()->
    @setHelpUrl('')
    @setColour(<%= color %>)
    @appendDummyInput()
      .appendField('<%= label %>')
    @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 %>)
    @appendDummyInput()
      .appendField('ペンの色を')
      .appendField(new Blockly.FieldColour('#ff0000'), 'COLOUR')
      .appendField('にする')
    @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

4 entries across 4 versions & 1 rubygems

Version Path
smalruby-editor-0.1.22-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.1.22 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.1.21-x86-mingw32 app/assets/javascripts/blocks/pen.js.coffee.erb
smalruby-editor-0.1.21 app/assets/javascripts/blocks/pen.js.coffee.erb