kopia lustrzana https://github.com/sepandhaghighi/samila
New `GenerateMode` (#222)
* fix : f1,f2 renamed to f1_vs_index and f2_vs_index * feat : 2 new generate mode added * fix : overall_test.py updated * doc : README.md updated * fix : minor typo in overall_test.py fixed * fix : minor edit in generate methodpull/232/head
rodzic
3e17e35f10
commit
3c0144d045
|
@ -114,7 +114,7 @@ Samila is a generative art generator written in Python, Samila lets you create i
|
|||
```pycon
|
||||
>>> from samila import GenerateMode
|
||||
>>> g = GenerativeImage(f1, f2)
|
||||
>>> g.generate(mode=GenerateMode.F1)
|
||||
>>> g.generate(mode=GenerateMode.F1_VS_INDEX)
|
||||
>>> g.plot()
|
||||
>>> g.seed
|
||||
883114
|
||||
|
@ -122,7 +122,7 @@ Samila is a generative art generator written in Python, Samila lets you create i
|
|||
```
|
||||
<img src="https://github.com/sepandhaghighi/samila/raw/master/otherfiles/images/10.png">
|
||||
|
||||
* Supported modes : `F1_VS_F2`, `F2_VS_F1`, `F1`, and `F2`
|
||||
* Supported modes : `F1_VS_F2`, `F2_VS_F1`, `F1_VS_INDEX`, `F2_VS_INDEX`, `INDEX_VS_F1` and `INDEX_VS_F2`
|
||||
* Default mode is `F1_VS_F2`
|
||||
|
||||
### Projection
|
||||
|
|
|
@ -103,18 +103,24 @@ class GenerativeImage:
|
|||
for index, point in enumerate(range_prod):
|
||||
random.seed(self.seed)
|
||||
try:
|
||||
if self.generate_mode == "f1_vs_f2":
|
||||
if self.generate_mode == GenerateMode.F1_VS_F2.value:
|
||||
data1_ = self.function1(point[0], point[1]).real
|
||||
data2_ = self.function2(point[0], point[1]).real
|
||||
elif self.generate_mode == "f2_vs_f1":
|
||||
elif self.generate_mode == GenerateMode.F2_VS_F1.value:
|
||||
data2_ = self.function1(point[0], point[1]).real
|
||||
data1_ = self.function2(point[0], point[1]).real
|
||||
elif self.generate_mode == "f2":
|
||||
elif self.generate_mode == GenerateMode.F2_VS_INDEX.value:
|
||||
data2_ = index
|
||||
data1_ = self.function2(point[0], point[1]).real
|
||||
elif self.generate_mode == "f1":
|
||||
elif self.generate_mode == GenerateMode.F1_VS_INDEX.value:
|
||||
data2_ = index
|
||||
data1_ = self.function1(point[0], point[1]).real
|
||||
elif self.generate_mode == GenerateMode.INDEX_VS_F1.value:
|
||||
data1_ = index
|
||||
data2_ = self.function1(point[0], point[1]).real
|
||||
elif self.generate_mode == GenerateMode.INDEX_VS_F2.value:
|
||||
data1_ = index
|
||||
data2_ = self.function2(point[0], point[1]).real
|
||||
self.data1.append(data1_)
|
||||
self.data2.append(data2_)
|
||||
except Exception:
|
||||
|
|
|
@ -68,8 +68,10 @@ class GenerateMode(Enum):
|
|||
DEFAULT = DEFAULT_GENERATE_MODE
|
||||
F1_VS_F2 = "f1_vs_f2"
|
||||
F2_VS_F1 = "f2_vs_f1"
|
||||
F1 = "f1"
|
||||
F2 = "f2"
|
||||
F1_VS_INDEX = "f1_vs_index"
|
||||
F2_VS_INDEX = "f2_vs_index"
|
||||
INDEX_VS_F1 = "index_vs_f1"
|
||||
INDEX_VS_F2 = "index_vs_f2"
|
||||
|
||||
|
||||
class Gateway(Enum):
|
||||
|
|
|
@ -372,14 +372,20 @@ True
|
|||
True
|
||||
>>> random.seed(22)
|
||||
>>> g = GenerativeImage()
|
||||
>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2, mode=GenerateMode.F1)
|
||||
>>> g.generate_mode == GenerateMode.F1.value
|
||||
>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2, mode=GenerateMode.F1_VS_INDEX)
|
||||
>>> g.generate_mode == GenerateMode.F1_VS_INDEX.value
|
||||
True
|
||||
>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2, mode=GenerateMode.F2)
|
||||
>>> g.generate_mode == GenerateMode.F2.value
|
||||
>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2, mode=GenerateMode.F2_VS_INDEX)
|
||||
>>> g.generate_mode == GenerateMode.F2_VS_INDEX.value
|
||||
True
|
||||
>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2, mode=GenerateMode.F2)
|
||||
>>> g.generate_mode == GenerateMode.F2.value
|
||||
>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2, mode=GenerateMode.INDEX_VS_F1)
|
||||
>>> g.generate_mode == GenerateMode.INDEX_VS_F1.value
|
||||
True
|
||||
>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2, mode=GenerateMode.INDEX_VS_F2)
|
||||
>>> g.generate_mode == GenerateMode.INDEX_VS_F2.value
|
||||
True
|
||||
>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2, mode=GenerateMode.F1_VS_F2)
|
||||
>>> g.generate_mode == GenerateMode.F1_VS_F2.value
|
||||
True
|
||||
>>> g.generate(start=-2*math.pi, step=0.1, stop=math.pi/2, mode=GenerateMode.F2_VS_F1)
|
||||
>>> g.generate_mode == GenerateMode.F2_VS_F1.value
|
||||
|
|
Ładowanie…
Reference in New Issue