Skip to content

Commit

Permalink
* add: Image.copy() method
Browse files Browse the repository at this point in the history
  • Loading branch information
royqh1979 committed May 9, 2020
1 parent 00edf67 commit 6d5df51
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
History
===========
1.0.20
-----------
* add: Image.copy() method

1.0.19
-----------
* add: Image.scaled() method


1.0.18
-----------
* add: put_image()
Expand Down
2 changes: 1 addition & 1 deletion easygraphics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = 'Roy Qu'
__email__ = 'royqh1979@gmail.com'
__version__ = '1.0.19'
__version__ = '1.0.20'

from .easygraphics import *

Expand Down
13 changes: 13 additions & 0 deletions easygraphics/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,19 @@ def to_bytes(self, with_background=True, format: str = "PNG") -> bytes:
buffer.close()
return ba.data()

def copy(self,x:int,y:int,width:int,height:int) -> "Image":
"""
Create an copy of the image.
:param x: left-top of the copied area
:param y: left-top of the copied area
:param width: width of the copy area
:param height: height of the copy area
:return: new copy
"""
new_image = self._image.copy(x,y,width,height)
return Image(new_image)

def scaled(self,width:int,height:int) -> "Image":
"""
Create a scaled copy with the specified width and height.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='easygraphics',
version='1.0.18',
version='1.0.20',
description='"A TC Graphics style like Graphics Library"',
long_description=readme + '\n\n' + history,
author='Roy Qu',
Expand Down

0 comments on commit 6d5df51

Please sign in to comment.