source: EcnlProtoTool/trunk/webapp/webmrbc/Ruby/Colour.cs@ 270

Last change on this file since 270 was 270, checked in by coas-nagasima, 7 years ago

mruby版ECNLプロトタイピング・ツールを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csharp
File size: 1.6 KB
Line 
1// Porting from
2// https://github.com/jeanlazarou/blockly2ruby
3// Copyright (c) 2014 Jean Lazarou
4// MIT Lisence
5using System;
6using Bridge;
7using System.Collections.Generic;
8
9namespace WebMrbc
10{
11 partial class Ruby
12 {
13 public node colour_picker(ColourPickerBlock block)
14 {
15 // Colour picker.
16 var value_colour = block.getFieldValue("COLOUR");
17 return new str_node(this, value_colour);
18 }
19
20 public node colour_random(ColourRandomBlock block)
21 {
22 // Generate a random colour.
23 var p = new node[0];
24 return new fcall_node(this, intern("colour_random"), p, null);
25 }
26
27 public node colour_rgb(ColourRGBBlock block)
28 {
29 // Compose a colour from RGB components expressed as percentages.
30 var r = valueToCode(block, "RED");
31 if (r == null) r = new int_node(this, 0);
32 var g = valueToCode(block, "GREEN");
33 if (g == null) g = new int_node(this, 0);
34 var b = valueToCode(block, "BLUE");
35 if (b == null) b = new int_node(this, 0);
36 var p = new node[] { r, g, b };
37 return new fcall_node(this, intern("colour_rgb"), p, null);
38 }
39
40 public node colour_blend(ColourBlendBlock block)
41 {
42 // Blend two colours together.
43 var colour1 = valueToCode(block, "COLOUR1");
44 if (colour1 == null) colour1 = new str_node(this, "#000000");
45 var colour2 = valueToCode(block, "COLOUR2");
46 if (colour2 == null) colour2 = new str_node(this, "#000000");
47 var ratio = valueToCode(block, "RATIO");
48 if (ratio == null) ratio = new int_node(this, 0);
49 var p = new node[] { colour1, colour2, ratio };
50 return new fcall_node(this, intern("colour_blend"), p, null);
51 }
52 }
53}
Note: See TracBrowser for help on using the repository browser.