Class | Limelight::Pen |
In: |
lib/limelight/pen.rb
|
Parent: | Object |
The Pen is acquired from Prop.pen. It is used to draw directly on the screen withing the bounds of the prop from which the Pen was acquired.
All points used by the Pen are relative to the bounds of the Prop. The top left corner of the Prop is represented by the point (0, 0). If a Prop has margin, border, or padding, the point (0, 0) may appear to be outside the Prop.
context | [RW] |
It is constructed with a context which is essentially a java.awt.Graphic2D object. Defaults are set:
# File lib/limelight/pen.rb, line 21 21: def initialize(context) 22: @context = context 23: self.color = "black" 24: self.width = 1 25: self.smooth = false 26: end
Draws a line from the point (x1, y1) to the point (x2, y2)
# File lib/limelight/pen.rb, line 52 52: def draw_line(x1, y1, x2, y2) 53: @context.drawLine(x1, y1, x2, y2) 54: end
Draws the largest oval that will fit in the specified rectangle. The top left corner of the bounding rectangle is at (x, y). The center of the oval will be at (x + width/2, y + height/2).
# File lib/limelight/pen.rb, line 71 71: def draw_oval(x, y, width, height) 72: @context.drawOval(x, y, width, height) 73: end
Draws a rectangle with the top left corner at (x, y).
# File lib/limelight/pen.rb, line 58 58: def draw_rectangle(x, y, width, height) 59: @context.drawRect(x, y, width, height) 60: end
Specifies whether the pen will use anti-aliasing to draw smooth shapes or not. Shapes will appear pixilated when smooth is set to false.
# File lib/limelight/pen.rb, line 45 45: def smooth=(value) 46: hint = value ? java.awt.RenderingHints::VALUE_ANTIALIAS_ON : java.awt.RenderingHints::VALUE_ANTIALIAS_OFF 47: @context.setRenderingHint(java.awt.RenderingHints::KEY_ANTIALIASING, hint) 48: end