The primary purpose of this companion object of class Pic
is to provide methods for
creating new Pic instances: (apply, generate, circle, etc.
There is also a small selection of related utility methods.
This object has an alias in the top-level package o1, so it’s accessible to students simply
via import o1.*
. The shape-creating methods of this object (such as circle
) are also available
as functions in package o1.
- Companion:
- class
Value members
Concrete methods
Takes an image file path or URL as a string, loads image data from that location, and constructs an anchored Pic from that data. Throws an error if the file doesn’t exist or could not be accessed (cf. asTry, asOption).
Takes an image file path or URL as a string, loads image data from that location, and constructs
a Pic from that data. Anchors the Pic
at its center. Throws an error if the file
doesn’t exist or could not be accessed (cf. asTry, asOption).
Takes an image file path or URL as a string and attempts to load image data from that location and construct a BufferedImage from that data. Note that this method does not construct a Pic at all.
Takes an image file path or URL as a string and attempts to load image data from that location and construct a BufferedImage from that data. Note that this method does not construct a Pic at all.
Creates a new Pic by setting colors of each individual pixel according to the colors
list.
Creates a new Pic by setting colors of each individual pixel according to the colors
list.
- Value parameters:
- width
the width, in pixels, of the new
Pic
- height
the height, in pixels, of the new
Pic
- colors
a sequence of colors, one per pixel, starting from the upper-left corner and continuing to the right and line-by-line towards the bottom
- Returns:
the new Pic (a bitmap)
Creates a new Pic by applying the given pixel-generating function to each pair coordinates within the new image.
Creates a new Pic by applying the given pixel-generating function to each pair coordinates within the new image.
- Value parameters:
- width
the width, in pixels, of the new
Pic
- height
the height, in pixels, of the new
Pic
- makeColor
a function that
generate
calls on every pixel location of the newPic
to produce the color at that location
- Returns:
the generated Pic (a bitmap)
Displays the given Pic in a minimalistic GUI window. Calling this method repeatedly on the same Pic doesn’t display multiple windows but reuses the existing one. This method is meant only for experimentation and debugging; not for GUI construction (cf. views).
Displays the given Pic in a minimalistic GUI window. Calling this method repeatedly on the same Pic doesn’t display multiple windows but reuses the existing one. This method is meant only for experimentation and debugging; not for GUI construction (cf. views).
- Value parameters:
- pic
the image to display; should have a height and width of at least one pixel
- background
the color to appear behind the
Pic
in the frame (where thePic
is transparent)- border
the width of the simple black window frame, in pixels
- See also:
Inherited methods
Creates a new Pic that portrays a thin line. The line is specified in terms of two Pos objects: imagine drawing a line between the two points on a plane and then cropping the plane to just the part that contains the line.
Creates a new Pic that portrays a thin line. The line is specified in terms of two Pos objects: imagine drawing a line between the two points on a plane and then cropping the plane to just the part that contains the line.
The line always runs from one corner of the resulting Pic to another. The
Anchor of the Pic is at one of the four corners:
the one that’s closest to from
.
The background is fully transparent.
Creates a new Pic that portrays an isosceles triangle. The triangle’s base is at the bottom of the image and its apex is at the top center. The background is fully transparent.