-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add screenshot 1342 #2039
Draft
sabadam32
wants to merge
46
commits into
pythonarcade:development
Choose a base branch
from
sabadam32:add_screenshot_1342
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+666
−7
Draft
Add screenshot 1342 #2039
Changes from 40 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
e2c8b46
fixed the header levels in the sprite doc
sabadam32 c2dcc0f
Revert "fixed the header levels in the sprite doc"
sabadam32 b0d6718
Merge branch 'pythonarcade:development' into development
sabadam32 5377d26
Merge branch 'development' of https://github.com/pythonarcade/arcade …
sabadam32 b8ff2f4
Merge branch 'development' of https://github.com/pythonarcade/arcade …
sabadam32 6d5b217
Merge branch 'development' of https://github.com/pythonarcade/arcade …
sabadam32 37a5224
Merge branch 'development' of https://github.com/pythonarcade/arcade …
sabadam32 7523e89
added screenshot functions
sabadam32 cc598c8
fix tests
sabadam32 3d47991
fix locations
sabadam32 e061b0c
removed stash file and updated screenshot oath
sabadam32 ce14121
fix tests
sabadam32 3472eab
Use cleaner pytest screenshot fixtures
pushfoo d38d28e
Try to make Window.save_screenshot friendlier + better documented
pushfoo b104c00
Use shorter intersphinx mapping instead of full URL
pushfoo 931075e
Phrasing tweak for Window.save_screenshot docstring
pushfoo 6811519
Sync implementation + docstring for window_command.save_screenshot
pushfoo b377f88
Use intersphinx link in screenshot kwargs field
pushfoo 0dcdcf1
Add Window.save_timestamped_screenshot method + doc
pushfoo 161566e
Add creenshot / helper doc, helpers, and examples
pushfoo 29ccec7
Revert get_timestamped_screenshot
pushfoo 2b74056
Spacing in Window.__init__
pushfoo f70685a
Revert whitespace noise in application.py
pushfoo 6741ea9
Commit overlooked example py file + screenshot for doc
pushfoo eb900a6
Fix code-block directive spacing
pushfoo b6b5341
Better date and time section tweaks
pushfoo b53b413
Intro block revision
pushfoo c42872a
Second pair of intro tweaks
pushfoo ae00a90
Add module-level spacing above get_timestamp
pushfoo 2dfd5b5
Put format string first in get_timestamp
pushfoo 09a363e
Add tzinfo to get_timestamp
pushfoo 50d38ee
Account for DX + Sabadam32's suggestions
pushfoo e6a708a
Add timezone to format string + clean up tests
pushfoo d7eeecb
Phrasing tweak to intro
pushfoo 8e92ac5
Merge pull request #1 from pushfoo/screenshot_pr_cleaning
sabadam32 f585d83
add in get_image
sabadam32 37b0962
Merge branch 'development' of https://github.com/pythonarcade/arcade …
sabadam32 caa493e
Merge branch 'development' into add_screenshot_1342
sabadam32 5aafe39
fix typing errors
sabadam32 90164e8
fix type error
sabadam32 58f2d70
removed datetime type
sabadam32 ff1abb1
Merge branch 'development' of https://github.com/pythonarcade/arcade …
sabadam32 a2278d3
Merge branch 'development' of https://github.com/pythonarcade/arcade …
sabadam32 d9c0178
Merge branch 'development' into add_screenshot_1342
sabadam32 856689a
Merge branch 'development' of https://github.com/pythonarcade/arcade …
sabadam32 43e6ac5
Merge branch 'development' into add_screenshot_1342
sabadam32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"""Take screenshots for debugging. | ||
|
||
This example shows you how to take debug screenshots by: | ||
|
||
1. Setting the window's background to a non-transparent color | ||
2. Randomly arranging sprites to display a pattern over it | ||
3. Using arcade.save_screenshot | ||
|
||
After installing arcade version 3.0.0 or higher, this example can be run | ||
from the command line with: | ||
python -m arcade.examples.debug_screenshot | ||
""" | ||
import random | ||
import arcade | ||
from arcade.types import Color | ||
|
||
|
||
SCREENSHOT_FILE_NAME = "debug_screenshot_image.png" | ||
|
||
# How many sprites to draw and how big they'll be | ||
NUM_SPRITES = 100 | ||
MIN_RADIUS_PX = 5 | ||
MAX_RADIUS_PX = 50 | ||
|
||
# Window size | ||
WIDTH_PX = 800 | ||
HEIGHT_PX = 600 | ||
|
||
|
||
class ScreenshotWindow(arcade.Window): | ||
|
||
def __init__(self): | ||
super().__init__(WIDTH_PX, HEIGHT_PX, "Press space to save a screenshot") | ||
|
||
# Important: we have to set a non-transparent background color, | ||
# or else the screenshot will have a transparent background. | ||
self.background_color = arcade.color.AMAZON | ||
|
||
# Randomize circle sprite positions, sizes, and colors | ||
self.sprites = arcade.SpriteList() | ||
for i in range(NUM_SPRITES): | ||
sprite = arcade.SpriteCircle( | ||
random.randint(MIN_RADIUS_PX, MAX_RADIUS_PX), | ||
Color.random(a=255) | ||
) | ||
sprite.position = ( | ||
random.uniform(0, self.width), | ||
random.uniform(0, self.height) | ||
) | ||
self.sprites.append(sprite) | ||
|
||
def on_draw(self): | ||
self.clear() | ||
self.sprites.draw() | ||
|
||
def on_key_press(self, key, modifiers): | ||
if key == arcade.key.SPACE: | ||
arcade.save_screenshot(SCREENSHOT_FILE_NAME) | ||
# You can also use the format below instead. | ||
# self.save_screenshot(SCREENSHOT_FILE_NAME) | ||
|
||
|
||
if __name__ == "__main__": | ||
window = ScreenshotWindow() | ||
arcade.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HasStrftime
not matchdatetime
? Was it only pyright which complained?|
syntax is a 3.9+ feature, but we support 3.8+There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it didn't. pyright complained for sure, but I don't remember if the build failed due to this check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? I see references to line 41 in the GitHub CI builds on the previous commits. That's the other line it seems.