概要
windows11に、sketchup6を入れてみた。
rubyで、3Dを書く。
練習問題やってみた。
練習問題
九九をアニメーションせよ。
写真
サンプルコード
class Kuku2
def initialize
model = Sketchup.active_model
@entities = model.active_entities
coordinates = [10, 10, 10]
@point = Geom::Point3d.new coordinates
@text = @entities.add_text "This is a Test", @point
@group = @entities.add_group
pts = []
pts[0] = [0.5, 0.5, 0.5]
pts[1] = [ 1, 0.5, 0.5]
pts[2] = [ 1, 1, 0.5]
pts[3] = [0.5, 1, 0.5]
base = @group.entities.add_face pts
base.pushpull 0.5
@k = 0
@tid = UI.start_timer(2.9, true) {
tick
}
end
def tick
@text.erase!
@group.erase!
i = Integer(@k / 9) + 1
j = @k % 9 + 1
@text = @entities.add_text "#{i}x#{j}=#{i * j}", @point
@group = @entities.add_group
(1..i).each { |x|
(1..j).each { |y|
puts "#{x} #{y}"
pts = []
pts[0] = [x + 0.5, y + 0.5, 0.5]
pts[1] = [x + 1, y + 0.5, 0.5]
pts[2] = [x + 1, y + 1, 0.5]
pts[3] = [x + 0.5, y + 1, 0.5]
base = @group.entities.add_face pts
base.pushpull 0.5
}
}
@k += 1
end
end
以上。