Skip to content

Commit

Permalink
Merge pull request #69 from Schulich-Ignite/dev
Browse files Browse the repository at this point in the history
Version 0.1.0 Release
  • Loading branch information
AlphaRLee authored Nov 11, 2020
2 parents 0a2e481 + e239dd1 commit 9a6048d
Show file tree
Hide file tree
Showing 41 changed files with 6,199 additions and 688 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
- Shamis Ali
- Richard Lee
- Kieran Wood
- Liam Wrubleski
Binary file added docs/img/key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/key_pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/key_released.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/key_repeated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/keys_held.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
188 changes: 184 additions & 4 deletions docs/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def draw():

Results in:

![Mouse position example example](img/mouse_position.png)
![Mouse position example example](img/mouse_position.png){: loading=lazy }


### Mouse pressed
Expand Down Expand Up @@ -58,7 +58,7 @@ def draw():

Results in:

![Mouse pressed example](img/mouse_pressed.png)
![Mouse pressed example](img/mouse_pressed.png){: loading=lazy }

### Getting text from user

Expand Down Expand Up @@ -90,7 +90,7 @@ def setup(): # Only drawn once, so just using setup()

which results in:

![Write Name](img/write_name.png)
![Write Name](img/write_name.png){: loading=lazy }


*Ask the user for a diameter. We need to convert the string to an integer, we can do this using int(). Draw a circle of that diameter at (100, 100):*
Expand All @@ -106,4 +106,184 @@ def setup(): # Only drawn once, so just using setup()

which results in:

![Ask circle diameter](img/circle_radius.png)
![Ask circle diameter](img/circle_radius.png){: loading=lazy }

### Check for key presses

Spark features multiple ways to check for user key presses:

| Name | Type | Description |
|---------------------------------|-----------------------|--------------------------------------------------------------|
| [key](#key) | Variable | A string of what key was last pressed |
| [keys_held()](#keys_held) | Function | A function that returns True if the provided key is held |
| [key_pressed()](#key_pressed) | User defined function | A definable function that activates when any key is pressed |
| [key_released()](#key_released) | User defined function | A definable function that activates when any key is released |
| [key_repeated()](#key_repeated) | User defined function | A definable function that activates when any key is held |

#### key

A string that is the last key event (a key being pressed, released, or held down). So for example if you press, hold or release ++shift++ then `#!python key == "Shift"`.

##### Notes
- This variable **does not clear**, meaning if a key is pressed it will remain the value until a **new key** is pressed
- This variable will be the uppercase letter if ++shift++ + a letter is pressed i.e. ++shift++ + ++a++ would be `#!python key == "A"`
- This variable will be a symbol if ++shift++ + a number is pressed i.e. ++shift++ + ++3++ would be `#!python key == "$"`


##### Special Keys

| Key | Value |
|------------------------|--------------------------------|
| ++up++ | `#!python key == "ArrowUp"` |
| ++down++ | `#!python key == "ArrowDown"` |
| ++left++ | `#!python key == "ArrowLeft"` |
| ++right++ | `#!python key == "ArrowRight"` |
| ++tab++ | `#!python key == "Tab"` |
| ++ctrl++ | `#!python key == "Control"` |
| ++alt++ or ++option++ | `#!python key == "Alt"` |
| ++esc++ | `#!python key == "Escape"` |
| ++win++ or ++command++ | `#!python key == "Meta"` |
| ++backspace++ | `#!python key == "Backspace"` |

**Example(s):**

*Print out each key as they are pressed (I pressed **just** the ++a++ key in this example)*


```python hl_lines="8"
%%ignite
def setup():
size(500,500)

def draw():
background(255)
text_size(32)
text(key, 250, 200)
```

Results in:

![key example](img/key.png){: loading=lazy }

#### keys_held()

```python
keys_held(key)
```

**Parameters**

- key: (str) The key you want to check for

**Returns**

bool; Returns True if the provided key is held, else False.



*Print `#!python "b key held"` if the ++b++ key is held*

```python hl_lines="7"
%%ignite

def setup():
size(200, 200)

def draw():
if keys_held("b"):
print("b key held")
```

Results in:

![keys_held() example](img/keys_held.png){: loading=lazy }

#### key_pressed()

```python
def key_pressed():
# Your code goes here
```

This is a user definable function that activates when **any** key is held.

Example(s):

*Print a key if it's pressed*

```python hl_lines="9 10"
%%ignite

def setup():
size(200, 200)

def draw():
... # Does nothing

def key_pressed():
print(key)
```

Results in:

![key_pressed() example](img/key_pressed.png){: loading=lazy }

#### key_released()

```python
def key_released():
# Your code goes here
```

This is a user definable function that activates when **any** key is released.

Example(s):

*Print a key if it's pressed*

```python hl_lines="9 10"
%%ignite

def setup():
size(200, 200)

def draw():
... # Does nothing

def key_released():
print(key)
```

Results in:

![key_released() example](img/key_released.png){: loading=lazy }

#### key_repeated()

```python
def key_repeated():
# Your code goes here
```

This is a user definable function that activates when **any** key is held. Note this function **continuously activates** for as long as the key is held.

Example(s):

*Print a key if it's held*

```python hl_lines="9 10"
%%ignite

def setup():
size(200, 200)

def draw():
... # Does nothing

def key_repeated():
print(key)
```

Results in:

![key_repeated() example](img/key_repeated.png){: loading=lazy }
2 changes: 1 addition & 1 deletion docs/shapes_text.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ All of the examples below assume you have the boilerplate from [the notebook set

To create a rectangle there are 3 options:

| Function | Description |
| Function | Description |
|-----------------------------------------|-------------------------------------------------------|
| [rect(x, y, w, l)](#rect) | Draw a rectangle filled with color, and with a stroke |
| [fill_rect(x, y, w, l)](#fill_rect) | Draw an rectangle filled with a color |
Expand Down
Loading

0 comments on commit 9a6048d

Please sign in to comment.