Python

プログラミング

【Python】2次元配列を1次元配列に変換する(平坦化)

周辺のセル(ムーア近傍)の生きているセルの合計を求めるため、2次元配列を1次元配列に変換(平坦化)するflattenメソッドを作成する。 class LifeGame: def __init__(self): self.cells = [[...
プログラミング

【Python】周辺のセル(ムーア近傍)を取得する

任意のセルの周辺のセル(ムーア近傍)を取得するためにget_around_cellsメソッドを作成する。 class LifeGame: def __init__(self): self.cells = [[0, 1, 0, 0, 0], ...
プログラミング

【Python】ライフゲームの初期状態を作成する

ライフゲームの初期状態を2次元配列で作成する。 class LifeGame: def __init__(self): self.cells = [[0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 0,...
プログラミング

【Blender】オブジェクトを統合する

import bpy import bmesh import math for item in bpy.data.meshes: bpy.data.meshes.remove(item) bpy.ops.mesh.primitive_cub...
プログラミング

【Blender】メッシュを細分化する

import bpy import bmesh import math for item in bpy.data.meshes: bpy.data.meshes.remove(item) bpy.ops.mesh.primitive_cub...
プログラミング

【Blender】モディファイアーを追加する

import bpy import bmesh for item in bpy.data.meshes: bpy.data.meshes.remove(item) bpy.ops.mesh.primitive_cube_add() bpy....
プログラミング

【Blender】オブジェクトを複製する

import bpy import bmesh for item in bpy.data.meshes: bpy.data.meshes.remove(item) bpy.ops.mesh.primitive_cube_add() bpy....
プログラミング

【Blender】スクリプトでオブジェクトを生成する

import bpy for item in bpy.data.meshes: bpy.data.meshes.remove(item) bpy.ops.mesh.primitive_cube_add() 参考
プログラミング

【Pillow】PNG画像からGIFアニメーションを作成する

以下の記事で保存したPNG画像からGIFアニメーションを作成する。 from PIL import Image import glob files = sorted(glob.glob('./*.png')) images = list(m...
プログラミング

【Pillow】ゲーミングカラーの画像を作成する

import numpy as np from PIL import Image line_data = np.arange(256) hue = np.tile(line_data, (256, 1)) sat = np.tile(255...