Jelajahi Sumber

Update 'README.md'

Init
tBKwtWS 1 hari lalu
induk
melakukan
1d05fcd95e
1 mengubah file dengan 100 tambahan dan 2 penghapusan
  1. 100 2
      README.md

+ 100 - 2
README.md

@@ -1,4 +1,102 @@
 # karel_asset
 
-A package to draw Karel in graphics projects.
-For use by students who want to make art or games with Karel as a character.
+A package to draw Karel in graphics projects.
+For use by students who want to make art or games with Karel as a character.
+
+## Getting started
+1. In CIP6 click on **["Code / You own"](https://codeinplace.stanford.edu/cip6/create)**, or on CIP self-guided clock on **["Code / You own"](https://codeinplace.stanford.edu/public/create)**
+1. Create a new or open an existing **graphics project**
+1. Go to the **Project Files** view by clicking the "**Files**" button in the ribbon on the left
+1. Add the karel_asset.py file by:
+    * Either clicking the CIP icon of a file with a plus sign (+) in it to add a new file and paste the content of [karel_asset.py](https://git.h0v1n8.nl/Stanford/karel_asset/src/master/karel_asset.py)
+    * Or by downloading/cloning this project and uploading the karel_asset.py file with the upload button on the CIP IDE
+
+## Using karel_asset.py when it is added to a CIP project
+1. In your main.py or any other project file on CIP, add: `from karel_asset import *`
+### Drawing Karel
+To simply draw a Karel in the top left corner use: `draw_karel(canvas)`
+But surely this will not suffice for any project so there are optional arguments to pass:
+* centre_x
+* centre_y
+* size
+* orientation
+* colour
+* background
+* transparent
+
+#### Coordinates
+To draw a Karel in the middle of X / Y coordinates 100 / 100, use the optional arguments centre_x, centre_y:
+```
+draw_karel(canvas, 100, 100)
+```
+#### Size
+To draw a Karel of size 200, use the optional argument size:
+```
+draw_karel(canvas, size=200)
+```
+#### Orientation
+To draw a Karel facing north, use the optional argument orientation:
+```
+draw_karel(canvas, orientation="north")
+```
+Orientation options:
+* "east"
+* "east-flipped"
+* "north"
+* "north-flipped"
+* "west"
+* "west-flipped"
+* "south"
+* "south-flipped"
+Flipped makes Karel appear upside down.
+#### Colour
+To draw a Karel in any colour use the optional argument colour:
+```
+draw_karel(canvas, colour="red", background="#FF8833")
+```
+Colour names and hex codes are accepted, just like normal for any CIP graphical object.
+
+#### Transparancy
+To draw a transparant Karel, which only has outlines and no fill, use the optional argument transparent:
+```
+draw_karel(canvas, transparent=True)
+```
+
+#### Examples
+Draw a Karel at 85x and 35y upside down facing east with a red outline and blue filling:
+```
+karel_east_mirrored = draw_karel(canvas, 85, 35, 100, "east-flipped", "red", "blue")
+```
+Draw a Karel at 135X and 35y, facing west with a red background:
+```
+karel_west = draw_karel(canvas, centre_x=135, centre_y=35, orientation="west", background="red")
+```
+### Changing colour
+To change the colour of any created Karel, use recolour_karel(karel, colour, background).
+For example changing a red/blue Karel to a green/yellow Karel:
+```
+my_karel = draw_karel(canvas, colour="red", background="blue")
+my_karel = recolour_karel(my_karel, colour="green", background="yellow) 
+```
+
+### Changing position
+To change the position of a Karel on the canvas, use move_karel(karel, dx, dy).
+Where dx is the amout of pixels shifted horizontally, and dy is the amount of pixels shifted vertically.
+To move a Karel up 10 pixes:
+```
+my_karel = draw_karel(canvas, colour="red", background="blue")
+my_karel = move_karel(my_karel, dy=-10,)
+```
+
+To move a Karel down 10 and left 10 pixels:
+```
+my_karel = draw_karel(canvas, colour="red", background="blue")
+my_karel = move_karel(my_karel, 10, -10)
+```
+
+### Erasing a Karel
+To remove a Karel from the canvas, use erase_karel(karel):
+```
+my_karel = draw_karel(canvas, colour="red", background="blue")
+my_karel = erase_karel(my_karel)
+```