object Pic extends ShapeAPI
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.
- Alphabetic
- By Inheritance
- Pic
- ShapeAPI
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply(pathOrURL: String, anchor: Anchor): Pic
Takes an image file path or URL as a string, loads image data from that location, and constructs an anchored Pic from that data.
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).
- pathOrURL
a classpath-relative path or a URL string that starts with "http://" or "https://". Note that the O1Library project exports its
pics
folder, so the example images in that folder can be loaded using just the file name.- anchor
an anchor for the new
Pic
- returns
the loaded image (a bitmap)
- Annotations
- @inline()
- def apply(pathOrURL: String): Pic
Takes an image file path or URL as a string, loads image data from that location, and constructs a Pic from that data.
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).- pathOrURL
a classpath-relative path or a URL string that starts with "http://" or "https://". Note that the O1Library project exports its
pics
folder, so the example images in that folder can be loaded using just the file name.- returns
the loaded image (a bitmap)
- Annotations
- @inline()
- def asImage(pathOrURL: String): Option[BufferedImage]
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.
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.
- pathOrURL
a classpath-relative path or a URL string that starts with "http://" or "https://".
- returns
the loaded image;
None
in case the attempt failed for any reason
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def asOption(pathOrURL: String, anchor: Anchor = Center): Option[Pic]
Takes an image file path or URL as a string and attempts to load image data from that location and construct a Pic from that data.
Takes an image file path or URL as a string and attempts to load image data from that location and construct a Pic from that data.
- pathOrURL
a classpath-relative path or a URL string that starts with "http://" or "https://".
- anchor
an anchor for the new
Pic
- returns
the loaded Pic (a bitmap);
None
in case the attempt failed for any reason
- See also
- def asTry(pathOrURL: String, anchor: Anchor = Center): Try[Pic]
Takes an image file path or URL as a string and attempts to load image data from that location and construct a Pic from that data.
Takes an image file path or URL as a string and attempts to load image data from that location and construct a Pic from that data.
- pathOrURL
a classpath-relative path or a URL string that starts with "http://" or "https://".
- anchor
an anchor for the new
Pic
- returns
the loaded Pic (a bitmap) or the error that caused the attempt to fail
- See also
- def circle(diameter: Double, color: Color, anchor: Anchor = Center): Pic
Creates a new Pic that portrays a filled circle.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def ellipse(width: Double, height: Double, color: Color, anchor: Anchor = Center): Pic
Creates a new Pic that portrays an ellipse.
- def emptyCanvas(width: Double, height: Double, color: Color = colors.White): Pic
Creates a new Pic that portrays a filled rectangle and sets its Anchor at TopLeft.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def fromColors(width: Int, height: Int, colors: Seq[Color]): Pic
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.- 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)
- def generate(width: Int, height: Int, makeColor: (Int, Int) => Color): Pic
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.
- 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)
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hide(pic: Pic): Unit
Hides the window that has been created (with show) to display the given Pic.
- def hideAll(): Unit
Hides any and all windows that have been created (with show) to display Pics.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def line(from: Pos, to: Pos, color: Color): Pic
Creates a new Pic that portrays a thin 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.
- from
the “starting point” of the line; the Pic will anchor at the corresponding corner
- to
the “end point” of the line
- color
the color of the line
- returns
a Pic of the line (a vector graphic)
- Definition Classes
- ShapeAPI
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def polygon(points: Seq[Pos], color: Color, anchor: Anchor = Center): Pic
Creates a new Pic that portrays a filled polygon.
Creates a new Pic that portrays a filled polygon. The picture is just large enough to contain the polygon; its background is fully transparent.
- points
the polygon’s corners (only their relative positioning matters)
- color
the polygon’s color
- anchor
an anchor for the new Pic
- returns
a Pic of the rectangle (a vector graphic)
- Definition Classes
- ShapeAPI
- def rectangle(bounds: Bounds, color: Color): Pic
Creates a new Pic that portrays a filled rectangle.
- def rectangle(width: Double, height: Double, color: Color, anchor: Anchor = Center): Pic
Creates a new Pic that portrays a filled rectangle.
Creates a new Pic that portrays a filled rectangle.
- width
the width of the rectangle and the Pic
- height
the height of the rectangle and the Pic
- color
the color of the rectangle and thus the only color visible in the Pic
- anchor
an anchor for the new Pic
- returns
a Pic of the rectangle (a vector graphic)
- Definition Classes
- ShapeAPI
- def show(pic: Pic, background: Color, border: Int): Unit
Displays the given Pic in a minimalistic GUI window.
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).
- 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
- def square(side: Double, color: Color, anchor: Anchor = Center): Pic
Creates a new Pic that portrays a filled square.
- def star(width: Double, color: Color, anchor: Anchor = Center): Pic
Creates a new Pic that portrays a five-pointed star.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString: String
- Definition Classes
- AnyRef → Any
- def triangle(width: Double, height: Double, color: Color, anchor: Anchor = Center): Pic
Creates a new Pic that portrays an isosceles triangle.
Creates a new Pic that portrays an isosceles triangle. The triangle’s base is at the bottom of the image and the apex is at the top center. The background is fully transparent.
- width
the width of the triangle’s base, which determines the width of the Pic, too
- height
the height of the triangle, which determines the height of the Pic, too
- color
the color of the triangle
- anchor
an anchor for the new Pic
- returns
a Pic of the triangle (a vector graphic)
- Definition Classes
- ShapeAPI
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
- Deprecated
(Since version ) see corresponding Javadoc for more information.