-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Canvim/new_shapes
New shapes
- Loading branch information
Showing
18 changed files
with
348 additions
and
43 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,7 @@ name: PyPen CI | |
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test: | ||
|
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,42 @@ | ||
from pypen import * | ||
|
||
|
||
def start(): | ||
settings.fps = 60 | ||
|
||
|
||
def update(): | ||
fill_screen("#343434") | ||
|
||
begin_shape() | ||
vertex(40, 40) | ||
vertex(40, 140) | ||
vertex(FRAME, 140) | ||
end_shape("red") | ||
|
||
begin_shape() | ||
vertex(40+FRAME, 240+FRAME) | ||
vertex(40, 340) | ||
vertex(FRAME, 340) | ||
vertex(340, 280) | ||
|
||
end_shape("yellow", "blue", 5) | ||
|
||
reset_style() | ||
|
||
angle = 0 | ||
points = 10 + sin(TIME*2)*5 | ||
radius = 100 | ||
|
||
save() | ||
translate(WIDTH/2, HEIGHT/2) | ||
|
||
begin_shape() | ||
|
||
while angle <= TAU: | ||
angle += TAU/points | ||
vertex(sin(angle)*radius, cos(angle)*radius) | ||
|
||
end_shape("orange") | ||
restore() | ||
reset_style() |
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,19 @@ | ||
from pypen import * | ||
|
||
|
||
def start(): | ||
settings.fps = 60 | ||
|
||
def update(): | ||
save() | ||
translate(WIDTH/2, HEIGHT/2) | ||
|
||
x1 = 200 * cos(TIME - 10 * sin(TIME)) * cos(TIME) | ||
y1 = 200 * sin(TIME - FRAME/10) * sin(TIME) | ||
|
||
x2 = 200 * cos(TIME + FRAME ** 0.5) * cos(TIME-0.5) | ||
y2 = 200 * sin(TIME + FRAME/10 - 10*cos(TIME/10)) * sin(TIME - 0.5) | ||
|
||
line(x1, y1, x2, y2, (150, 30, 230, 10), 0.2) | ||
|
||
restore() |
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,22 @@ | ||
from pypen import * | ||
|
||
|
||
def pseudo_random(seed: float): | ||
return abs(sin(seed % 478562)*cos(seed % 3579)) | ||
|
||
def update(): | ||
clear_screen() | ||
|
||
i = 0 | ||
offset_y = TIME*170 | ||
|
||
for x, y in grid(spacing=30): | ||
seed = i+x*y | ||
|
||
actual_y = (y + offset_y) % HEIGHT - 30 | ||
percentage = (1-(actual_y/HEIGHT)**5) | ||
color = (80, 130, 50, pseudo_random(seed)*255*percentage) | ||
|
||
circle(x, actual_y, pseudo_random(seed)*14*percentage, color) | ||
|
||
i += 1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,126 @@ | ||
|
||
def rotate(angle): | ||
"""Rotates the context. | ||
Args: | ||
angle (float): The amount by which the context should be rotated. | ||
""" | ||
raise NotImplementedError("rotate() is not implemented") | ||
|
||
|
||
def translate(x, y): | ||
"""Translates the context by x and y. | ||
Args: | ||
x (float): Horizontal coordinate. | ||
y (float): Vertical coordinate. | ||
""" | ||
raise NotImplementedError("translate() is not implemented") | ||
|
||
|
||
def scale(factor): | ||
"""Scales the context by the provided factor | ||
Args: | ||
factor (float): The amount by which the current context should be scaled. | ||
""" | ||
raise NotImplementedError("scale() is not implemented") | ||
|
||
|
||
def save(): | ||
"""Saves the current context's translation, rotation and scaling""" | ||
raise NotImplementedError("save() is not implemented") | ||
|
||
|
||
def restore(): | ||
"""Restores the context's translation, rotation and scaling to that of the latest save""" | ||
raise NotImplementedError("restore() is not implemented") | ||
|
||
|
||
def reset_style(): | ||
"""Resets PyPen's current setting surrounding style to their default_values, which includes fill_color, stroke_color, stroke_width""" | ||
raise NotImplementedError("reset_style() is not implemented") | ||
|
||
|
||
def clear_screen(): | ||
"""Clears the screen""" | ||
raise NotImplementedError("clear_screen() not implemented") | ||
|
||
|
||
def clear(): | ||
"""Clears the screen""" | ||
raise NotImplementedError("clear() not implemented") | ||
|
||
|
||
def fill_screen(fill_color): | ||
"""Fills the screen with the specified color | ||
Args: | ||
fill_color (Color): The color by which to fill the screen. Defaults to the theme's default background color. | ||
""" | ||
raise NotImplementedError("fill_screen() not implemented") | ||
|
||
|
||
def fill(): | ||
"""Fills the current path. Different from fill_screen.""" | ||
raise NotImplementedError("fill() not implemented") | ||
|
||
|
||
def rectangle(x, y, width, height, fill_color, stroke_color, stroke_width): | ||
"""Draws a rectangle on the given coordinate with the given width, height and color | ||
Args: | ||
x (float): Horizontal coordinate. | ||
y (float): Vertical coordinate. | ||
width (float): Width of the triangle. | ||
height (float): Height of the triangle. | ||
fill_color (Color, optional): The color by which to fill the rectangle. | ||
stroke_color (Color, optional): The color of the rectangle's outline | ||
stroke_width (float, optional): The width of the outline. | ||
""" | ||
raise NotImplementedError("rectangle() not implemented") | ||
|
||
|
||
def circle(x, y, radius, fill_color, stroke_color, stroke_width): | ||
"""Draws a circle on the given coordinate with the given radius and color | ||
Args: | ||
x (float): Horizontal coordinate. | ||
y (float): Vertical coordinate. | ||
radius (float): Radius of the circle. | ||
fill_color (Color, optional): The color by which to fill the circle. | ||
stroke_color (Color, optional): The color of the circle's outline | ||
stroke_width (float, optional): The width of the outline. | ||
""" | ||
raise NotImplementedError("circle() not implemented") | ||
|
||
|
||
def ellipse(x, y, width, height, fill_color="", stroke_color="", stroke_width=-1): | ||
"""Draws an ellipse on the given coordinate with the given width, height and color | ||
Args: | ||
x (float): Horizontal coordinate. | ||
y (float): Vertical coordinate. | ||
width (float): Width of the ellipse. | ||
height (float): Height of the ellipse. | ||
fill_color (Color, optional): The color by which to fill the ellipse. | ||
stroke_color (Color, optional): The color of the ellipse's outline | ||
stroke_width (float, optional): The width of the outline. | ||
""" | ||
raise NotImplementedError("ellipse() not implemented") | ||
|
||
|
||
def arc(x, y, radius, start_angle, stop_angle, fill_color="", stroke_color="", stroke_width=-1): | ||
"""Draws an arc on the given coordinate with the given radius, angles and color | ||
Args: | ||
x (float): Horizontal coordinate. | ||
y (float): Vertical coordinate. | ||
radius (float): Radius of the arc. | ||
start_angle (float): The angle from which to begin drawing the arc. | ||
stop_angle (float): The angle at which to stop drawing the arc. | ||
fill_color (Color, optional): The color by which to fill the arc. | ||
stroke_color (Color, optional): The color of the arc's outline | ||
stroke_width (float, optional): The width of the outline. | ||
""" | ||
raise NotImplementedError("arc() not implemented") |
Oops, something went wrong.