Basic graphics functions to simplify use of Graphics2D.
Basic graphics functions to simplify use of Graphics2D.
(anti-alias g2d)
Enable anti-aliasing on the given Graphics2D object.
Returns g2d.
Enable anti-aliasing on the given Graphics2D object. Returns g2d.
(circle x y radius)
Create a circle with the given center and radius
Create a circle with the given center and radius
(draw g2d)
(draw g2d shape style)
(draw g2d shape style & more)
Draw a one or more shape/style pairs to the given graphics context.
shape should be an object that implements Draw protocol (see (rect), (ellipse), etc.
style is a style object created with (style). If the style's :foreground is non-nil, the border of the shape is drawn with the given stroke. If the style's :background is non-nil, the shape is filled with that color.
Returns g2d.
Draw a one or more shape/style pairs to the given graphics context. shape should be an object that implements Draw protocol (see (rect), (ellipse), etc. style is a style object created with (style). If the style's :foreground is non-nil, the border of the shape is drawn with the given stroke. If the style's :background is non-nil, the shape is filled with that color. Returns g2d.
(ellipse x y w)
(ellipse x y w h)
Create an ellipse that occupies the given rectangular region
Create an ellipse that occupies the given rectangular region
(linear-gradient &
{:keys [start end fractions colors cycle]
:or {start default-start
end default-end
fractions default-fractions
colors default-colors
cycle :none}
:as opts})
Creates a linear gradient suitable for use on the :foreground and :background properties of a (seesaw.graphics/style), or anywhere a java.awt.Paint is required. Has the following options:
:start The start [x y] point, defaults to [0 0] :end The end [x y] point, defaults to [1 0] :fractions Sequence of fractional values indicating color transition points in the gradient. Defaults to [0.0 1.0]. Must have same number of entries as :colors. :colors Sequence of color values correspoding to :fractions. Value is passed through (seesaw.color/to-color). e.g. :blue, "#fff", etc. :cycle The cycle behavior of the gradient, :none, :repeat, or :reflect. Defaults to :none.
Examples:
; create a horizontal red, white and blue gradiant with three equal parts (linear-gradient :fractions [0 0.5 1.0] :colors [:red :white :blue])
See: http://docs.oracle.com/javase/6/docs/api/java/awt/LinearGradientPaint.html
Creates a linear gradient suitable for use on the :foreground and :background properties of a (seesaw.graphics/style), or anywhere a java.awt.Paint is required. Has the following options: :start The start [x y] point, defaults to [0 0] :end The end [x y] point, defaults to [1 0] :fractions Sequence of fractional values indicating color transition points in the gradient. Defaults to [0.0 1.0]. Must have same number of entries as :colors. :colors Sequence of color values correspoding to :fractions. Value is passed through (seesaw.color/to-color). e.g. :blue, "#fff", etc. :cycle The cycle behavior of the gradient, :none, :repeat, or :reflect. Defaults to :none. Examples: ; create a horizontal red, white and blue gradiant with three equal parts (linear-gradient :fractions [0 0.5 1.0] :colors [:red :white :blue]) See: http://docs.oracle.com/javase/6/docs/api/java/awt/LinearGradientPaint.html
(polygon & points)
Create a polygonal shape with the given set of vertices. points is a list of x/y pairs, e.g.:
(polygon [1 2] [3 4] [5 6])
Create a polygonal shape with the given set of vertices. points is a list of x/y pairs, e.g.: (polygon [1 2] [3 4] [5 6])
(push g2d & forms)
Push a Graphics2D context (Graphics2d/create) and automatically dispose it.
For example, in a paint handler:
(fn [c g2d] (.setColor g2d java.awt.Color/RED) (.drawString g2d "This string is RED" 0 20) (push g2d (.setColor g2d java.awt.Color/BLUE) (.drawString g2d "This string is BLUE" 0 40)) (.drawString g2d "This string is RED again" 0 60))
Push a Graphics2D context (Graphics2d/create) and automatically dispose it. For example, in a paint handler: (fn [c g2d] (.setColor g2d java.awt.Color/RED) (.drawString g2d "This string is RED" 0 20) (push g2d (.setColor g2d java.awt.Color/BLUE) (.drawString g2d "This string is BLUE" 0 40)) (.drawString g2d "This string is RED again" 0 60))
(radial-gradient &
{:keys [center focus radius fractions colors cycle]
:or {center default-center
radius default-radius
fractions default-fractions
colors default-colors
cycle :none}
:as opts})
Creates a radial gradient suitable for use on the :foreground and :background properties of a (seesaw.graphics/style), or anywhere a java.awt.Paint is required. Has the following options:
:center The center [x y] point, defaults to [0 0] :focus The focus [x y] point, defaults to :center :radius The radius. Defaults to 1.0 :fractions Sequence of fractional values indicating color transition points in the gradient. Defaults to [0.0 1.0]. Must have same number of entries as :colors. :colors Sequence of color values correspoding to :fractions. Value is passed through (seesaw.color/to-color). e.g. :blue, "#fff", etc. :cycle The cycle behavior of the gradient, :none, :repeat, or :reflect. Defaults to :none.
Examples:
; create a red, white and blue gradiant with three equal parts (radial-gradient :radius 100.0 :fractions [0 0.5 1.0] :colors [:red :white :blue])
See: http://docs.oracle.com/javase/6/docs/api/java/awt/RadialGradientPaint.html
Creates a radial gradient suitable for use on the :foreground and :background properties of a (seesaw.graphics/style), or anywhere a java.awt.Paint is required. Has the following options: :center The center [x y] point, defaults to [0 0] :focus The focus [x y] point, defaults to :center :radius The radius. Defaults to 1.0 :fractions Sequence of fractional values indicating color transition points in the gradient. Defaults to [0.0 1.0]. Must have same number of entries as :colors. :colors Sequence of color values correspoding to :fractions. Value is passed through (seesaw.color/to-color). e.g. :blue, "#fff", etc. :cycle The cycle behavior of the gradient, :none, :repeat, or :reflect. Defaults to :none. Examples: ; create a red, white and blue gradiant with three equal parts (radial-gradient :radius 100.0 :fractions [0 0.5 1.0] :colors [:red :white :blue]) See: http://docs.oracle.com/javase/6/docs/api/java/awt/RadialGradientPaint.html
(rect x y w)
(rect x y w h)
Create a rectangular shape with the given upper-left corner, width and height.
Create a rectangular shape with the given upper-left corner, width and height.
(rotate g2d degrees)
Apply a rotation to the graphics context by degrees
Returns g2d
Apply a rotation to the graphics context by degrees Returns g2d
(rounded-rect x y w h)
(rounded-rect x y w h rx)
(rounded-rect x y w h rx ry)
Create a rectangular shape with the given upper-left corner, width, height and corner radii.
Create a rectangular shape with the given upper-left corner, width, height and corner radii.
(scale g2d s)
(scale g2d sx sy)
Apply a scale factor to the graphics context
Returns g2d
Apply a scale factor to the graphics context Returns g2d
(stroke &
{:keys [width cap join miter-limit dashes dash-phase]
:or {width 1
cap :square
join :miter
miter-limit 10.0
dashes nil
dash-phase 0.0}})
Create a new stroke with the given properties:
:width Width of the stroke
Create a new stroke with the given properties: :width Width of the stroke
(style & {:keys [foreground background stroke font]})
Create a new style object for use with (seesaw.graphics/draw). Takes a list of key/value pairs:
:foreground A color value (see seesaw.color) for the foreground (stroke) :background A color value (see seesaw.color) for the background (fill) :stroke A stroke value used to draw outlines (see seesaw.graphics/stroke) :font Font value used for drawing text shapes
The default value for all properties is nil. See (seesaw.graphics/draw) for interpretation of nil values.
Notes:
Style objects are immutable so they can be efficiently "pre-compiled" and used for drawing multiple shapes.
Examples:
; Red on black (style :foreground :red :background :black :font :monospace)
; Red, 8-pixel line with no fill. (style :foreground :red :stroke 8)
See: (seesaw.graphics/update-style) (seesaw.graphics/draw)
Create a new style object for use with (seesaw.graphics/draw). Takes a list of key/value pairs: :foreground A color value (see seesaw.color) for the foreground (stroke) :background A color value (see seesaw.color) for the background (fill) :stroke A stroke value used to draw outlines (see seesaw.graphics/stroke) :font Font value used for drawing text shapes The default value for all properties is nil. See (seesaw.graphics/draw) for interpretation of nil values. Notes: Style objects are immutable so they can be efficiently "pre-compiled" and used for drawing multiple shapes. Examples: ; Red on black (style :foreground :red :background :black :font :monospace) ; Red, 8-pixel line with no fill. (style :foreground :red :stroke 8) See: (seesaw.graphics/update-style) (seesaw.graphics/draw)
(to-stroke v)
Convert v to a stroke. As follows depending on v:
nil - returns nil java.awt.Stroke instance - returns v
Throws IllegalArgumentException if it can't figure out what to do.
Convert v to a stroke. As follows depending on v: nil - returns nil java.awt.Stroke instance - returns v Throws IllegalArgumentException if it can't figure out what to do.
(translate g2d dx dy)
Apply a translation to the graphics context
Returns g2d
Apply a translation to the graphics context Returns g2d
(update-style s
&
{:keys [foreground background stroke font]
:or {foreground (:foreground s)
background (:background s)
stroke (:stroke s)
font (:font s)}})
Update a style with new properties and return a new style. This is basically exactly the same as (clojure.core/assoc) with the exception that color, stroke, and font values are interpreted by Seesaw.
Examples:
(def start (style :foreground blue :background :white)) (def no-fill (update-style start :background nil)) (def red-line (update-style no-fill :foreground :red))
See: (seesaw.graphics/style) (seesaw.graphics/draw)
Update a style with new properties and return a new style. This is basically exactly the same as (clojure.core/assoc) with the exception that color, stroke, and font values are interpreted by Seesaw. Examples: (def start (style :foreground blue :background :white)) (def no-fill (update-style start :background nil)) (def red-line (update-style no-fill :foreground :red)) See: (seesaw.graphics/style) (seesaw.graphics/draw)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close