Skip to content

Commit 05ebe09

Browse files
Merge pull request #1 from karam-mustafa/main
v1.0.3
2 parents 2baead7 + aaffc83 commit 05ebe09

File tree

11 files changed

+163
-7
lines changed

11 files changed

+163
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
v1.0.0
2+
---------
3+
* First release

README.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,55 @@
1-
# python-oak-leaf-drawer
1+
<p align="center">
2+
<img src="https://github.com/karam-mustafa/python-oak-leaf-drawer/blob/main/assets/logo.png" />
3+
</p>
4+
5+
Python oak leaf drawer
6+
----------------------
27
Python package making you able to draw OAK Leaf depending on an angle.
8+
9+
##### Dependency
10+
The first step is using composer to install the package and automatically update your composer.json file, you can do this by running:
11+
12+
```shell
13+
14+
pip install python-oak-leaf-drawer
15+
16+
```
17+
18+
Usage
19+
-----------
20+
```
21+
from python_oak_leaf_drawer.oak import drawPattern
22+
23+
# The first parameter is the rotation angle.
24+
# The second parameter is the title.
25+
drawPattern(15 , "syrian open source 😎, oak package")
26+
27+
```
28+
Examples:
29+
----------
30+
```
31+
drawPattern(15 , "syrian open source 😎, oak package")
32+
```
33+
![example1](assets/example1.png)
34+
```
35+
drawPattern(30 , "syrian open source 😎, oak package")
36+
```
37+
![example2](assets/example2.png)
38+
```
39+
drawPattern(45 , "syrian open source 😎, oak package")
40+
```
41+
![example3](assets/example3.png)
42+
43+
Changelog
44+
---------
45+
Please see the [CHANGELOG](https://github.com/syrian-open-source/python-oak-leaf-drawer/blob/master/CHANGELOG.md) for more information about what has changed or updated or added recently.
46+
47+
Security
48+
--------
49+
If you discover any security related issues, please email them first to "[email protected]",
50+
if we do not fix it within a short period of time please open a new issue describing your problem.
51+
52+
Credits
53+
-------
54+
* [Karam Mustafa](https://www.linkedin.com/in/karam2mustafa/)
55+
* [All contributors](https://github.com/syrian-open-source/python-oak-leaf-drawer/graphs/contributors)

assets/example1.png

85.7 KB
Loading

assets/example2.png

61.5 KB
Loading

assets/example3.png

50.8 KB
Loading

assets/logo.png

21.1 KB
Loading

python_oak_leaf_drawer/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from python_oak_leaf_drawer.oak import drawPattern

python_oak_leaf_drawer/oak.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import math
2+
import matplotlib.pyplot as plt
3+
4+
5+
# declare the functions a,b,c,d,e,f,g
6+
def resolveA(teta):
7+
return 0.01 * (math.cos(teta) ** 9) * (math.cos(5.0 * teta) ** 10)
8+
9+
10+
def resolveB(teta):
11+
return 0.25 * math.sin(2 * teta)
12+
13+
14+
def resolveC(teta):
15+
return 1 - 0.5 * math.sin(10 * teta) ** 2
16+
17+
18+
def resolveD(teta):
19+
return 1 - (math.cos(teta) * math.cos(3 * teta)) ** 8
20+
21+
22+
def resolveE(teta):
23+
return math.sin(teta)
24+
25+
26+
def resolveF(teta):
27+
return 0.2 * math.sin(10 * teta) ** 2
28+
29+
30+
def resolveG(teta):
31+
return 0.5 + math.sin(2 * teta) ** 2
32+
33+
34+
35+
xRotatedList = []
36+
yRotatedList = []
37+
xList = []
38+
yList = []
39+
40+
def OakLeafX(teta):
41+
return resolveA(teta) + (resolveB(teta) * resolveC(teta) * resolveD(teta))
42+
43+
44+
def OakLeafY(teta):
45+
return resolveE(teta) * (1 - (resolveF(teta) * resolveG(teta)))
46+
47+
48+
def generateOakLeaf():
49+
for i in range(1, 180):
50+
xList.append(OakLeafX(math.radians(i)))
51+
for i in range(1, 180):
52+
yList.append(OakLeafY(math.radians(i)))
53+
54+
return xList, yList
55+
56+
57+
def plot(xList, yList, title):
58+
plt.plot(xList, yList)
59+
plt.title(title)
60+
plt.show()
61+
62+
63+
xList, yList = generateOakLeaf()
64+
# plot(xList, yList, "One Oak Leaf")
65+
66+
xRotatedList = []
67+
yRotatedList = []
68+
69+
70+
def generateRotatedList(xList, yList, angle):
71+
for i in range(1, 180):
72+
xRotatedList.append((yList[i] * math.sin(math.radians(angle))) + (xList[i] * math.cos(math.radians(angle))))
73+
yRotatedList.append((yList[i] * math.cos(math.radians(angle))) - (xList[i] * math.sin(math.radians(angle))))
74+
75+
return xRotatedList, yRotatedList
76+
77+
xRotatedList = []
78+
yRotatedList = []
79+
80+
81+
def generateOakLeafPattern(rotationAngle):
82+
xPatternList = []
83+
yPatternList = []
84+
85+
xList, yList = generateOakLeaf()
86+
if rotationAngle <= 0:
87+
count = 1
88+
else:
89+
count = 360 / rotationAngle
90+
91+
for j in range(0, math.ceil(count)):
92+
xPatternList += generateRotatedList(xList, yList, (rotationAngle * j))[0]
93+
yPatternList += generateRotatedList(xList, yList, (rotationAngle * j))[1]
94+
95+
return xRotatedList, yRotatedList
96+
97+
98+
def drawPattern(rotationAngle, text):
99+
plot(generateOakLeafPattern(rotationAngle)[0], generateOakLeafPattern(rotationAngle)[1], text)

setup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
88
long_description = "\n" + fh.read()
99

10-
VERSION = '1.0.0'
10+
VERSION = '1.0.3'
1111
DESCRIPTION = 'Python module depending on matplotlib to draw oak leaf.'
1212
LONG_DESCRIPTION = 'Python module depending on matplotlib and angle to draw oak leaf wih specific title.'
1313

1414
setup(
15-
name="python-oak-leaf-drawer",
16-
version="1.0.0",
15+
name="python_oak_leaf_drawer",
16+
version=VERSION,
1717
author="Karam Mustafa",
1818
author_email="[email protected]",
19-
description="Python module depending on matplotlib to draw oak leaf.",
20-
long_description_content_type="Python module depending on matplotlib and angle to draw oak leaf wih specific title.",
21-
long_description="Python module depending on matplotlib and angle to draw oak leaf wih specific title.",
19+
description=DESCRIPTION,
20+
long_description_content_type="text/markdown",
21+
long_description=LONG_DESCRIPTION,
2222
packages=find_packages(),
2323
install_requires=['matplotlib'],
2424
keywords=['python', 'oak', 'oak-leaf', 'python-packages', 'matplotib'],

src/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)