[[花とだんご] の画像を、作る] , Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり
Python(パイソン) プログラム作ってみた インデックス へ
-----
2024.10.15 presented in [note] ( //note.com/runningWater/ )
----------
これ以降に記述されている内容は、このようなコンピューター・プログラムを制作した、というような事を、ただ、述べているに過ぎない。
以下の記述を読んだ人が、それを単に参考にする、というのであれば、問題は無いと、思われる。
しかし、記述されている内容に沿って、その人が、そこに記されているのと同様の制作や作業を行った際に、その制作、作業、コンピューターの作動の結果、使用されたコンピューター等、様々な方面において、何らかの問題が発生しない、という保証は、全くない。
その制作、作業、コンピューターの作動の結果、その人や、その人が所属している組織、その人が使用した様々な機器、インフラストラクチャー等の、身の上にどのような事が起ころうとも、私は一切、責任を負わない。
このプログラムは、Python(パイソン) 言語を使って、記述されている。
----------
2 どのようなものを作ったのか
下記 [Fig 1] にあるように、[Fig 1]上部にある画像から、[Fig 1]下部にある1個の画像を、作成した。
この作成は、以下のように、三段がまえで、行った。
-----
第1段階(DoPhase1MakeFlower)
下記 [Fig 2] にあるように、
[花弁の外側部分] を作成するための画像
[花弁の内側部分] を作成するための画像
と、
そのためのパターン画像を使って、
[花弁] 1枚分の部分を作成し
それを、5個、回転させながら、重ね合わせて、
[花] 1個分 ( = [花弁] 5個)
の画像を、作った。
-----
第2段階(DoPhase1MakeDango)
下記 [Fig 3] にあるように、
[くし] を作成するための画像と、そのためのパターン画像を使って、
[くし]の部分を作成し
[だんご] を作成するための画像と、そのためのパターン画像を使って、
[だんご]の部分(3個分)を作成し
それらを、重ね合わせて、
[くし付・だんご] 1個分 ( = [だんご] 3個 + [くし] 1個)
の画像を、作った。
-----
第3段階(do_phase_2)
下記 [Fig 4] にあるように、
第1段階 で作られた画像
と
第2段階 で作られた画像
を、
[ベース画像 phase_2] (緑色の画像)
の上に、
規則的に、順にコピーしていった(回転させながら)
そのようにして、[Fig 1]下部にある画像が、作成された。
----------
3 構成
このモジュール群は、下記で説明されているモジュール群を、改造することにより、構成されている。
[寄木細工(よせぎざいく)]のような、スタイルの画像を、作る] , Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり
改造の過程において、新たに、加えられたモジュールは、下記の通りである。
[ DoPhase1MakeFlower ]
これは、
2 で述べた、 第1段階(DoPhase1MakeFlower)
に、対応する処理である。
[ DoPhase1MakeDango ]
これは、
2 で述べた、 第2段階(DoPhase1MakeDango)
に、対応する処理である。
[ MakeFlowerAndDango ]
2 で述べた、 第3段階(do_phase_2)
に対応する処理は、このモジュールにおいて、行われる
以降に、これらのモジュールの内容を、記す。
----------
4 [ DoPhase1MakeDango ]
ファイル名 [ DoPhase1MakeDango.py ]
----------
import time
import CopyAndInsertImageDataV2
import ImageDataTwoDimensionHandlingV3
#=====================================
# DoPhase1MakeDango
#=====================================
global_module_name = "DoPhase1MakeDango"
global_abs_path_of_directory_Part_1 = "E:ForPython/ForTest/Test_B/"
global_path_of_sub_directory_for_making_Dango = "Dango/"
global_path_of_directory_Input = "Input/"
global_path_of_directory_Output = "Output/"
global_path_of_directory_BaseImage = "BaseImage/"
global_path_of_directory_CopySource = "CopySource/"
global_path_of_directory_Pattern = "Pattern/"
#----------------------------------------------
def do_phase_1_Dango ( ) :
function_name = "do_phase_1_Dango"
global global_module_name
global global_abs_path_of_directory_Part_1
global global_path_of_sub_directory_for_making_Dango
global global_path_of_directory_Input
global global_path_of_directory_Output
global global_path_of_directory_BaseImage
global global_path_of_directory_CopySource
global global_path_of_directory_Pattern
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
abs_path_of_BaseImage \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Input \
+ "Phase_1/" \
+ global_path_of_sub_directory_for_making_Dango \
+ global_path_of_directory_BaseImage \
+ "White_200_200.png"
abs_path_of_InsertedSide_ImageData_Output \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Output \
+ "OutputImageData_Dango.png"
#-----------------------------------
list_information_of_using_ImageData = [ \
[ "OneBar_200_200.png" \
, "Pattern_OneBar_200_200.png" \
, 100 , 100 \
, 100 , 100 \
, 1.0 \
] \
, [ "For_Dango_Green_200_200.png" \
, "Pattern_OneDango_200_200.png" \
, 100 , 100 \
, 100 , 60 \
, 0.25 \
] \
, [ "For_Dango_White_200_200.png" \
, "Pattern_OneDango_200_200.png" \
, 100 , 100 \
, 100 , 110 \
, 0.25 \
] \
, [ "For_Dango_Red_200_200.png" \
, "Pattern_OneDango_200_200.png" \
, 100 , 100 \
, 100 , 160 \
, 0.25 \
] \
]
#------------------------------------------
ins_CopyAndInsertImageDataV2 \
= CopyAndInsertImageDataV2 \
.CopyAndInsertImageDataV2 ( )
#---------------------------------------
ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 2 )
ins_CopyAndInsertImageDataV2 \
.load_ImageData ( 2 , abs_path_of_BaseImage )
#---------------------------------------
ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 3 )
ins_CopyAndInsertImageDataV2 \
.load_ImageData ( 3 , abs_path_of_BaseImage )
#-----------------------
for i in range ( 0 , 4 ) :
list_information_for_one_Dango_part \
= list_information_of_using_ImageData [ i ]
set_image_of_one_Dango_part ( \
i
, list_information_for_one_Dango_part
, ins_CopyAndInsertImageDataV2
)
#-------------------------------------------
ins_CopyAndInsertImageDataV2 \
.write_InsertedSide_Generated_ImageData ( \
abs_path_of_InsertedSide_ImageData_Output
)
#-------------------------------------------
ins_ImageDataTwoDimensionHandlingV3 \
= ins_CopyAndInsertImageDataV2 \
.get_ImageData ( 3 )
return ins_ImageDataTwoDimensionHandlingV3
#================================
def set_image_of_one_Dango_part ( \
arg_setting_part_number
, arg_list_information_for_one_Dango_part
, arg_ins_CopyAndInsertImageDataV2
) :
function_name = " set_image_of_one_Dango_part"
global global_module_name
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "arg_setting_part_number = " , arg_setting_part_number )
print ( "==================================" )
global global_abs_path_of_directory_Part_1
global global_path_of_sub_directory_for_making_Dango
global global_path_of_directory_Input
global global_path_of_directory_CopySource
#------------------- set image data of CopySource
abs_path_of_CopySource_ImageData \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Input \
+ "Phase_1/" \
+ global_path_of_sub_directory_for_making_Dango \
+ global_path_of_directory_CopySource \
+ arg_list_information_for_one_Dango_part [ 0 ]
arg_ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 0 )
arg_ins_CopyAndInsertImageDataV2 \
.load_ImageData ( 0 , abs_path_of_CopySource_ImageData )
#------------------- set image data of Pattern
abs_path_of_CopySource_Pattern_ImageData \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Input \
+ "Phase_1/" \
+ global_path_of_sub_directory_for_making_Dango \
+ global_path_of_directory_Pattern \
+ arg_list_information_for_one_Dango_part [ 1 ]
arg_ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 1 )
arg_ins_CopyAndInsertImageDataV2 \
.load_ImageData ( 1 , abs_path_of_CopySource_Pattern_ImageData )
#---------------------------------------
list_directed_x_and_y_on_PatternImageData \
= [ arg_list_information_for_one_Dango_part [ 2 ] \
, arg_list_information_for_one_Dango_part [ 3 ] \
]
#---------------------------------------
list_CopySource_From_and_To_xy = [ [ 0 , 0 ] , [ 199 , 199 ] ]
list_color_copying = [ [ 0 , 0 , 0 ] , [ 253 , 253 , 253 ] ]
scale_rate_CopySource_to_InsertedSide \
= arg_list_information_for_one_Dango_part [ 6 ]
color_rate_CopySource_to_InsertedSide = 1.0
list_Center_xy_of_inserting_on_InsertedSide_Source = [ \
arg_list_information_for_one_Dango_part [ 4 ] \
, arg_list_information_for_one_Dango_part [ 5 ] \
]
print ( "==================================" )
print ( "Module = " + global_module_name
+ " , function = " + function_name )
print ( "arg_setting_part_number = " , arg_setting_part_number )
print ( "list_directed_x_and_y_on_PatternImageData = " \
, list_directed_x_and_y_on_PatternImageData )
print ( "==================================" )
# time.sleep ( 5 )
#--------------------------------------
arg_ins_CopyAndInsertImageDataV2 \
.copy_and_insert_ImageData ( \
"Y" # use_or_not_PatternImageData
, list_directed_x_and_y_on_PatternImageData
, list_color_copying
, list_CopySource_From_and_To_xy
, scale_rate_CopySource_to_InsertedSide
, color_rate_CopySource_to_InsertedSide
, list_Center_xy_of_inserting_on_InsertedSide_Source
, "N" # do_rotation
, 0 # arg_set_angle_degree
)
#======================================
----------
----------
5 [ DoPhase1MakeFlower ]
ファイル名 [ DoPhase1MakeFlower.py ]
----------
import math
import CopyAndInsertImageDataV2
import ImageDataTwoDimensionHandlingV3
#=====================================
# DoPhase1MakeFlower
#=====================================
global_module_name = "DoPhase1MakeFlower"
global_abs_path_of_directory_Part_1 = "E:ForPython/ForTest/Test_B/"
global_path_of_sub_directory_for_making_Flower = "Flower/"
global_path_of_directory_Input = "Input/"
global_path_of_directory_Output = "Output/"
global_path_of_directory_BaseImage = "BaseImage/"
global_path_of_directory_CopySource = "CopySource/"
global_path_of_directory_Pattern = "Pattern/"
global_distance_of_petal_base_from_Center = 50
#----------------------------------------------
def do_phase_1_Flower ( ) :
function_name = "do_phase_1_Flower"
global global_module_name
global global_abs_path_of_directory_Part_1
global global_path_of_sub_directory_for_making_Flower
global global_path_of_directory_Input
global global_path_of_directory_Output
global global_path_of_directory_BaseImage
global global_path_of_directory_CopySource
global global_path_of_directory_Pattern
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
abs_path_of_CopySource_ImageData_A \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Input \
+ "Phase_1/" \
+ global_path_of_sub_directory_for_making_Flower \
+ global_path_of_directory_CopySource \
+ "Pink_200_170.png"
abs_path_of_CopySource_ImageData_B \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Input \
+ "Phase_1/" \
+ global_path_of_sub_directory_for_making_Flower \
+ global_path_of_directory_CopySource \
+ "RedPurple_200_170.png"
abs_path_of_CopySource_Pattern_ImageData \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Input \
+ "Phase_1/" \
+ global_path_of_sub_directory_for_making_Flower \
+ global_path_of_directory_Pattern \
+ "Pattern_OnePetal_200_170.png"
abs_path_of_BaseImage \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Input \
+ "Phase_1/" \
+ global_path_of_sub_directory_for_making_Flower \
+ global_path_of_directory_BaseImage \
+ "White_200_200.png"
abs_path_of_InsertedSide_ImageData_Output \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Output \
+ "OutputImageData_Flower.png"
#---------------------------------------
list_CopySource_From_and_To_xy = [ [ 0 , 0 ] , [ 199 , 169 ] ]
list_color_copying = [ [ 0 , 0 , 0 ] , [ 253 , 253 , 253 ] ]
scale_rate_CopySource_to_InsertedSide = 0.4
color_rate_CopySource_to_InsertedSide = 1.0
list_Center_xy_of_inserting_on_InsertedSide_Source = [ 100 , 100 ]
#--------------------------------------
ins_CopyAndInsertImageDataV2 \
= CopyAndInsertImageDataV2 \
.CopyAndInsertImageDataV2 ( )
#------------------- set image data of Pattern
ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 1 )
ins_CopyAndInsertImageDataV2 \
.load_ImageData ( 1 , abs_path_of_CopySource_Pattern_ImageData )
#-------------------------------
ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 2 )
ins_CopyAndInsertImageDataV2 \
.load_ImageData ( 2 , abs_path_of_BaseImage )
#-------------------------------
ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 3 )
ins_CopyAndInsertImageDataV2 \
.load_ImageData ( 3 , abs_path_of_BaseImage )
#---------------------------------------------------------------------------
#----- for setting outer part of petal ------------------
list_directed_x_and_y_on_PatternImageData_for_OuterPetal = [ 0 , 0 ]
# 200 ( width of Pattern Image Data ) / 2 = 100
list_directed_x_and_y_on_PatternImageData_for_OuterPetal [ 0 ] = 100
# 170 ( height of Pattern Image Data ) / 2 = 85
list_directed_x_and_y_on_PatternImageData_for_OuterPetal [ 1 ] = 85
#----- for setting inner part of petal ------------------
list_directed_x_and_y_on_PatternImageData_for_InnerPetal = [ 0 , 0 ]
list_directed_x_and_y_on_PatternImageData_for_InnerPetal [ 0 ] = 10
# 170 ( height of Pattern Image Data ) / 2 = 85
list_directed_x_and_y_on_PatternImageData_for_InnerPetal [ 1 ] = 85
#---------------------------------------
do_CopyAndInsertImageData_for_Flower ( \
ins_CopyAndInsertImageDataV2
, list_directed_x_and_y_on_PatternImageData_for_OuterPetal
, list_directed_x_and_y_on_PatternImageData_for_InnerPetal
, list_color_copying
, list_CopySource_From_and_To_xy
, scale_rate_CopySource_to_InsertedSide
, color_rate_CopySource_to_InsertedSide
, list_Center_xy_of_inserting_on_InsertedSide_Source
, abs_path_of_CopySource_ImageData_A
, abs_path_of_CopySource_ImageData_B
)
#-------------------------------------------
ins_CopyAndInsertImageDataV2 \
.write_InsertedSide_Generated_ImageData ( \
abs_path_of_InsertedSide_ImageData_Output
)
# ------------------------------------------
# get output ImageData of Phase_1 , setting petal
ins_ImageDataTwoDimensionHandlingV3_after_setting_petal \
= ins_CopyAndInsertImageDataV2 \
.get_ImageData ( 3 )
print ( "==================================" )
print ( "Exit from , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
return ins_ImageDataTwoDimensionHandlingV3_after_setting_petal
#==============================================
def do_CopyAndInsertImageData_for_Flower ( \
arg_ins_CopyAndInsertImageDataV2
, arg_list_directed_x_and_y_on_PatternImageData_for_OuterPetal
, arg_list_directed_x_and_y_on_PatternImageData_for_InnerPetal
, arg_list_color_copying
, arg_list_CopySource_From_and_To_xy
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, arg_list_Center_xy_of_inserting_on_InsertedSide_Source
, arg_abs_path_of_CopySource_ImageData_A
, arg_abs_path_of_CopySource_ImageData_B
) :
function_name = "do_CopyAndInsertImageData_for_Flower"
global global_module_name
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
#------------------- get image data of CopySource
ins_ImageDataTwoDimensionHandling_CopySource_for_OuterPetal \
= ImageDataTwoDimensionHandlingV3 \
.ImageDataTwoDimensionHandlingV3 ( \
global_module_name
, function_name )
ins_ImageDataTwoDimensionHandling_CopySource_for_OuterPetal \
.load_image_data ( \
global_module_name
, function_name
, arg_abs_path_of_CopySource_ImageData_A
)
#---------------------------
ins_ImageDataTwoDimensionHandling_CopySource_for_InnerPetal \
= ImageDataTwoDimensionHandlingV3 \
.ImageDataTwoDimensionHandlingV3 ( \
global_module_name
, function_name )
ins_ImageDataTwoDimensionHandling_CopySource_for_InnerPetal \
.load_image_data ( \
global_module_name
, function_name
, arg_abs_path_of_CopySource_ImageData_B
)
#---------------------------------------------
arg_ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 0 )
#-------------------------------------------------
set_angle_degree = 0
for i in range ( 0 , 5 ) :
list_Center_xy \
= decide_Center ( arg_list_Center_xy_of_inserting_on_InsertedSide_Source \
, set_angle_degree )
#--------- set outer petal -------------------
arg_ins_CopyAndInsertImageDataV2 \
.set_ImageData ( 0 \
, ins_ImageDataTwoDimensionHandling_CopySource_for_OuterPetal )
set_one_petal_part_image ( \
arg_ins_CopyAndInsertImageDataV2
, arg_list_directed_x_and_y_on_PatternImageData_for_OuterPetal
, arg_list_color_copying
, arg_list_CopySource_From_and_To_xy
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, list_Center_xy
, set_angle_degree
)
#--------- set inner petal -------------------
arg_ins_CopyAndInsertImageDataV2 \
.set_ImageData ( 0 , \
ins_ImageDataTwoDimensionHandling_CopySource_for_InnerPetal )
set_one_petal_part_image ( \
arg_ins_CopyAndInsertImageDataV2
, arg_list_directed_x_and_y_on_PatternImageData_for_InnerPetal
, arg_list_color_copying
, arg_list_CopySource_From_and_To_xy
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, list_Center_xy
, set_angle_degree
)
#------------------------------------------
set_angle_degree += 72
#----------------------------------------------
def decide_Center ( arg_list_Center_xy_of_inserting_on_InsertedSide_Source \
, arg_set_angle_degree ) :
global global_distance_of_petal_base_from_Center
set_angle_radian = ( math.pi / 180.0 ) * arg_set_angle_degree
list_return = [ 0 , 0 ]
list_return [ 0 ] = \
arg_list_Center_xy_of_inserting_on_InsertedSide_Source [ 0 ] \
+ ( global_distance_of_petal_base_from_Center \
* math.cos ( set_angle_radian ) )
list_return [ 1 ] = \
arg_list_Center_xy_of_inserting_on_InsertedSide_Source [ 1 ] \
+ ( global_distance_of_petal_base_from_Center \
* math.sin ( set_angle_radian ) )
return list_return
#----------------------------------------------
def set_one_petal_part_image ( \
arg_ins_CopyAndInsertImageDataV2
, arg_list_directed_x_and_y_on_PatternImageData
, arg_list_color_copying
, arg_list_CopySource_From_and_To_xy
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, arg_list_Center_xy_of_inserting_on_InsertedSide_Source
, arg_set_angle_degree \
# , arg_abs_path_of_InsertedSide_ImageData_Output
) :
function_name = "set_one_petal_image"
global global_module_name
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "arg_set_angle_degree = " , arg_set_angle_degree )
print ( "==================================" )
arg_ins_CopyAndInsertImageDataV2 \
.copy_and_insert_ImageData ( \
"Y" # use_or_not_PatternImageData
, arg_list_directed_x_and_y_on_PatternImageData
, arg_list_color_copying
, arg_list_CopySource_From_and_To_xy
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, arg_list_Center_xy_of_inserting_on_InsertedSide_Source
, "Y" # do_rotation
, arg_set_angle_degree
#rotation_degree_of_inserting_on_InsertedSide_Source
)
#----------------------------------------------
----------
6 [ MakeFlowerAndDango ]
ファイル名 [ MakeFlowerAndDango.py ]
----------
import CopyAndInsertImageDataV2
import ImageDataTwoDimensionHandlingV3
import DoPhase1MakeFlower
import DoPhase1MakeDango
#=====================================
# MakeFlowerAndDango
#=====================================
global_module_name = "MakeFlowerAndDango"
global_abs_path_of_directory_Part_1 = "E:ForPython/ForTest/Test_B/"
global_path_of_directory_Input = "Input/"
global_path_of_directory_Output = "Output/"
global_path_of_directory_BaseImage = "BaseImage/"
global_path_of_directory_CopySource = "CopySource/"
global_path_of_directory_Pattern = "Pattern/"
#------------------------------------------------
def main ( ) :
function_name = "main"
global global_module_name
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
list_ins_ImageDataTwoDimensionHandlingV3_output_of_phase_1 = [ ]
ins_ImageDataTwoDimensionHandlingV3_Flower \
= DoPhase1MakeFlower \
.do_phase_1_Flower ( )
list_ins_ImageDataTwoDimensionHandlingV3_output_of_phase_1 \
.append ( ins_ImageDataTwoDimensionHandlingV3_Flower )
#-----------------------------
ins_ImageDataTwoDimensionHandlingV3_Dango \
= DoPhase1MakeDango \
.do_phase_1_Dango ( )
list_ins_ImageDataTwoDimensionHandlingV3_output_of_phase_1 \
.append ( ins_ImageDataTwoDimensionHandlingV3_Dango )
#------------------------------------------
do_phase_2 ( \
list_ins_ImageDataTwoDimensionHandlingV3_output_of_phase_1 )
print ( "==================================" )
print ( "Exit from , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
#----------------------------------------------------------
def do_phase_2 ( \
arg_list_ins_ImageDataTwoDimensionHandlingV3_by_phase_1 ) :
function_name = "do_phase_2"
global global_module_name
global global_abs_path_of_directory_Part_1
global global_path_of_directory_Input
global global_path_of_directory_Output
global global_path_of_directory_BaseImage
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
#----------------------------------------
list_rotating_angle_degree = [ ]
list_rotating_angle_degree \
.append ( [ 0 , 90 , 180 , 270 , 0 , 90 ] )
list_rotating_angle_degree \
.append ( [ 90 , 180 , 270 , 0 , 90 , 180 ] )
list_rotating_angle_degree \
.append ( [ 180 , 270 , 0 , 90 , 180 , 270 ] )
list_rotating_angle_degree \
.append ( [ 270 , 0 , 90 , 180 , 270 , 0 ] )
#--------------------------------
abs_path_of_BaseImage \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Input \
+ "Phase_2/" \
+ global_path_of_directory_BaseImage \
+ "Green_1200_1600.png"
abs_path_of_InsertedSide_ImageData_Output \
= global_abs_path_of_directory_Part_1 \
+ global_path_of_directory_Output \
+ "OutputImageData_Phase_2.png"
#--------------------------------------
ins_CopyAndInsertImageDataV2 \
= CopyAndInsertImageDataV2 \
.CopyAndInsertImageDataV2 ( )
#--------------------------------------
ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 0 )
#--------------------------------------
ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 2 )
ins_CopyAndInsertImageDataV2 \
.load_ImageData ( 2 , abs_path_of_BaseImage )
#-------------------
ins_CopyAndInsertImageDataV2 \
.construct_ImageData ( 3 )
ins_CopyAndInsertImageDataV2 \
.load_ImageData ( 3 , abs_path_of_BaseImage )
#-------------------
use_or_not_PatternImageData = "N"
list_directed_x_and_y_on_PatternImageData = [ 0 , 0 ]
list_CopySource_From_and_To_xy = [ [ 0 , 0 ] , [ 199 , 199 ] ]
list_color_copying = [ [ 0 , 0 , 0 ] , [ 253 , 253 , 253 ] ]
scale_rate_CopySource_to_InsertedSide = 1.0
color_rate_CopySource_to_InsertedSide = 1.0
do_rotation = "Y"
#-----------------------------------------------
for i in range ( 0 , 4 ) :
for j in range ( 0 , 6 ) :
print ( "==================================" )
print ( "Module = " + global_module_name
+ " , function = " + function_name )
print ( "i = " , i , " , j = " , j )
print ( "==================================" )
# ------------ set Flower Image -------------------
order_number_of_setting_ImageData = 1
set_image_of_Phase_1_Output_to_BaseImage ( \
order_number_of_setting_ImageData
, ins_CopyAndInsertImageDataV2
, arg_list_ins_ImageDataTwoDimensionHandlingV3_by_phase_1 [ 0 ]
, i
, j
, use_or_not_PatternImageData
, list_directed_x_and_y_on_PatternImageData
, list_CopySource_From_and_To_xy
, list_color_copying
, scale_rate_CopySource_to_InsertedSide
, color_rate_CopySource_to_InsertedSide
, do_rotation
, list_rotating_angle_degree [ i ] [ j ]
)
# ------------ set Dango Image ----------------------
order_number_of_setting_ImageData = 2
set_image_of_Phase_1_Output_to_BaseImage ( \
order_number_of_setting_ImageData
, ins_CopyAndInsertImageDataV2
, arg_list_ins_ImageDataTwoDimensionHandlingV3_by_phase_1 [ 1 ]
, i
, j
, use_or_not_PatternImageData
, list_directed_x_and_y_on_PatternImageData
, list_CopySource_From_and_To_xy
, list_color_copying
, scale_rate_CopySource_to_InsertedSide
, color_rate_CopySource_to_InsertedSide
, do_rotation
, list_rotating_angle_degree [ i ] [ j ]
)
#-------------------------------------------
ins_CopyAndInsertImageDataV2 \
.write_InsertedSide_Generated_ImageData ( \
abs_path_of_InsertedSide_ImageData_Output
)
print ( "==================================" )
print ( "Exit from , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
#------------------------------------------------------
def set_image_of_Phase_1_Output_to_BaseImage ( \
arg_order_number_of_setting_ImageData
, arg_ins_CopyAndInsertImageDataV2
, arg_ins_ImageDataTwoDimensionHandlingV3_by_phase_1
, arg_i
, arg_j
, arg_use_or_not_PatternImageData
, arg_list_directed_x_and_y_on_PatternImageData
, arg_list_CopySource_From_and_To_xy
, arg_list_color_copying
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, arg_do_rotation
, arg_rotating_angle_degree
) :
arg_ins_CopyAndInsertImageDataV2 \
.set_ImageData ( 0 \
, arg_ins_ImageDataTwoDimensionHandlingV3_by_phase_1 )
#----------------------------
center_x = 100 + ( arg_j * 200 )
if ( arg_order_number_of_setting_ImageData == 1 ) :
# set Flower Image
center_y = 100 + ( arg_i * 200 * 2 )
else :
# set Dango Image
center_y = 300 + ( arg_i * 200 * 2 )
list_Center_xy_of_inserting_on_InsertedSide_Source \
= [ center_x , center_y ]
#----------------------------
arg_ins_CopyAndInsertImageDataV2 \
.copy_and_insert_ImageData ( \
arg_use_or_not_PatternImageData
, arg_list_directed_x_and_y_on_PatternImageData
, arg_list_color_copying
, arg_list_CopySource_From_and_To_xy
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, list_Center_xy_of_inserting_on_InsertedSide_Source
, arg_do_rotation
, arg_rotating_angle_degree
)
#-------------------------------
#==============================
if __name__ == "__main__":
main ( )
----------
----------
Python(パイソン) プログラム作ってみた インデックス へ