この資料は、「2023 年度 Ruby アソシエーション開発助成金」制度で採択された「CRuby 用 Processing Gem の、本家 Processing との互換性向上に向けた取り組み」についての最終報告書になります。
この資料は、「2023 年度 Ruby アソシエーション開発助成金」制度で採択された「CRuby 用 Processing Gem の、本家 Processing との互換性向上に向けた取り組み」についての中間報告書になります。
クリエイティブコーディングの世界では Processing や p5.js のようなフレームワークが広く利用されています。これらを利用することで、フレームワーク利用者はグラフィックスと視覚的な表現を駆使したアートやインタラクティブなアプリケーションを簡単に作成することができます。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubysketch' | |
using RubySketch | |
STEP = 20 | |
SIZE_RANGE = 20..100 | |
def nextSize() | |
SIZE_RANGE.step(STEP).to_a.sample | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SAVE_PATH = 'ToonData' | |
class Button < Sprite | |
def initialize(w: 100, h: 44, label: nil, rgb: [200] * 3, &block) | |
super 0, 0, w, h | |
@label, @rgb, @select = label, rgb, false | |
pressing = false | |
includeMouse = ->x, y { (0...self.w).include?(x) && (0..self.h).include?(y) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CHECKER_SHADER = createShader nil, <<END | |
varying vec4 vertPosition; | |
void main() { | |
float x = mod(vertPosition.x, 32.) / 16. - 1.; | |
float y = mod(vertPosition.y, 32.) / 16. - 1.; | |
float c = x * y >= 0. ? 0.8 : 0.7; | |
gl_FragColor = vec4(c, c, c, 1.); | |
} | |
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubysketch' | |
using RubySketch | |
class Canvas < Sprite | |
def initialize(width, height, scale: 1) | |
super 0, 0, width, height | |
@width, @height, @scale = width, height, scale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'rexml' | |
require 'processing' | |
using Processing | |
UNITS_DIR = 'units' | |
UNIT_URL_BASE = 'https://raw.githubusercontent.com/open-duelyst/duelyst/87bf66f414c476e3002857af2d1ed295f0d2471c/app/resources/units' | |
def next_unit() | |
@units ||= UNITS.dup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rexml' | |
def parse_plist(plist) | |
dict2hash REXML::Document.new(plist).elements['/plist'] | |
end | |
def dict2hash(dict) | |
dict.reduce([{}, :root]) do |(hash, key), element| | |
case (element.name rescue nil) | |
when 'key' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
%w[xot beeps rays reflex] | |
.map {|s| File.expand_path "../../../../#{s}/lib", __FILE__} | |
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)} | |
require 'reflexion/include' | |
$player = | |
$ground = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <vector> | |
class View | |
{ | |
public: | |
View (size_t count, int level) | |
{ | |
if (level <= 0) return; |