Giter Club home page Giter Club logo

shapes's Introduction

Shapes

You can download and run the file and it will run a demo program.

Alternatively, create a new Python file in the same folder as shapes.py and use it like this:

from shapes import Triangle, Rectangle, Oval

# Random size and location triangle
tri = Triangle()
tri.randomize()
tri.draw()

# Specific size and location rectangle
rect = Rectangle(height=40, width=90, x=110, y=20, color="yellow")
rect.draw()

# Default oval
oval = Oval()
oval.draw()

# Oval with setters
oval2 = Oval()
oval2.set_height(200)
oval2.set_width(100)
oval2.set_color("fuchsia")
oval2.set_x(30)
oval2.set_y(90)
oval2.draw()

shapes's People

Contributors

lawsie avatar rik-cross avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shapes's Issues

The shapes.html has several bad links

top of page 'Index' causes a download result of: 400: Invalid request

top of page has shows c:\users\laura\documents\github\shapes\shapes.py

modules -> 'Random' gets Error: Cannot load file - it is trying to load 'random.html' which becomes https://raw.githubusercontent.com/raspberrypilearning/shapes/master/random.html which doesn't exist

class Oval(Shapes) -> builtins.object - goes nowhere
class Rectangle(Shapes) -> builtins.object - goes nowhere
class Shapes(builtins.object) - goes nowhere
class Triangle(Shapes) -> builtins.object - goes nowhere

Note: there are 27 places in the code where - having define anchors) you reference them using 'xxxxx.html#name' syntax instead of just '#name'. For example on line 154 of the raw source you have:
class Shape(builtins.object)
so you have defined the anchor as 'Shape' but on line 215 you have
Methods inherited from Shape:

which should be code as:
Methods inherited from Shape:

Here is the html with all the 'xxxxx.html#name' occurrences changed to '#name'

<title>Python: module shapes</title>


shapes
index
c:\users\laura\documents\github\shapes\shapes.py

# This code requires Python 3 and tkinter (which is usually installed by default)
# This code will NOT work on trinket.io as the tkinter module is not supported
# Raspberry Pi Foundation 2017
# CC-BY-SA 4.0


Modules
random


Classes
builtins.object
Shape
Oval
Rectangle
Triangle


class Oval(Shape)
Method resolution order:
Oval
Shape
builtins.object

Methods defined here:
draw(self)
Draws an oval on the canvas. The properties of the oval
can be set using the getter and setter methods in Shape

Methods inherited from Shape:
__init__(self, width=50, height=50, x=None, y=None, color='black')
Creates a generic 'shape' which contains properties common to all
shapes such as height, width, x y coordinates and colour.
get_color(self)
Returns the colour of the shape
randomise(self, width=20, height=200)
Randomly generates width, height, position and colour for a shape
set_color(self, color)
Sets the colour of the shape
set_height(self, height)
Sets the height of the shape
set_width(self, width)
Sets the width of the shape
set_x(self, x)
Sets the x position of the shape
set_y(self, y)
Sets the y position of the shape

Data descriptors inherited from Shape:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from Shape:
paper = <shapes.Paper object .>


class Rectangle(Shape)
# Rectangle class is a subclass of Shape
Method resolution order:
Rectangle
Shape
builtins.object

Methods defined here:
draw(self)
Draws a rectangle on the canvas. The properties of the rectangle
can be set using the getter and setter methods in Shape

Methods inherited from Shape:
__init__(self, width=50, height=50, x=None, y=None, color='black')
Creates a generic 'shape' which contains properties common to all
shapes such as height, width, x y coordinates and colour.
get_color(self)
Returns the colour of the shape
randomise(self, width=20, height=200)
Randomly generates width, height, position and colour for a shape
set_color(self, color)
Sets the colour of the shape
set_height(self, height)
Sets the height of the shape
set_width(self, width)
Sets the width of the shape
set_x(self, x)
Sets the x position of the shape
set_y(self, y)
Sets the y position of the shape

Data descriptors inherited from Shape:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from Shape:
paper = <shapes.Paper object .>


class Shape(builtins.object)
Methods defined here:
__init__(self, width=50, height=50, x=None, y=None, color='black')
Creates a generic 'shape' which contains properties common to all
shapes such as height, width, x y coordinates and colour.
get_color(self)
Returns the colour of the shape
randomise(self, width=20, height=200)
Randomly generates width, height, position and colour for a shape
set_color(self, color)
Sets the colour of the shape
set_height(self, height)
Sets the height of the shape
set_width(self, width)
Sets the width of the shape
set_x(self, x)
Sets the x position of the shape
set_y(self, y)
Sets the y position of the shape

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
paper = <shapes.Paper object .>


class Triangle(Shape)
Method resolution order:
Triangle
Shape
builtins.object

Methods defined here:
__init__(self, x1=0, y1=0, x2=20, y2=0, x3=20, y3=20, color='black')
Overrides the Shape constructor because triangles require three
coordinate points to be drawn, unlike rectangles and ovals.
draw(self)
Draws a triangle on the canvas. The properties of the triangle
can be set using the getter and setter methods in Shape
randomise(self)
Randomly chooses the location of all 3 triangle points as well
as the colour of the triangle
set_height(self, height)
Overrides the setter method for height
set_width(self, width)
Overrides the setter method for width

Methods inherited from Shape:
get_color(self)
Returns the colour of the shape
set_color(self, color)
Sets the colour of the shape
set_x(self, x)
Sets the x position of the shape
set_y(self, y)
Sets the y position of the shape

Data descriptors inherited from Shape:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from Shape:
paper = <shapes.Paper object .>


Data
BOTH = 'both'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.