Module: Processing::GraphicsContext
Overview
Drawing context
Constant Summary collapse
- PI =
PI
Math::PI
- HALF_PI =
PI / 2
PI / 2
- QUARTER_PI =
PI / 4
PI / 4
- TWO_PI =
PI * 2
PI * 2
- TAU =
PI * 2
PI * 2
- PROCESSING =
Processing mode for renderMode().
:processing
- P5JS =
p5.js mode for renderMode().
:p5js
- RGBA =
RGBA format for createImage().
:rgba
- RGB =
RGB format for createImage, or RGB mode for colorMode().
:rgb
- HSB =
HSB mode for colorMode().
:hsb
- RADIANS =
Radian mode for angleMode().
:radians
- DEGREES =
Degree mode for angleMode().
:degrees
- CORNER =
Mode for rectMode(), ellipseMode(), imageMode(), and shapeMode().
:corner
- CORNERS =
Mode for rectMode(), ellipseMode(), imageMode(), and shapeMode().
:corners
- CENTER =
Mode for rectMode(), ellipseMode(), imageMode(), shapeMode(), and textAlign().
:center
- RADIUS =
Mode for rectMode() and ellipseMode().
:radius
- ROUND =
Mode for strokeCap() and strokeJoin().
:round
- SQUARE =
Mode for strokeCap().
:butt
- PROJECT =
Mode for strokeCap().
:square
- MITER =
Mode for strokeJoin().
:miter
- BEVEL =
Mode for strokeCap() and strokeJoin().
:square
- BLEND =
Mode for blendMode().
:normal
- ADD =
Mode for blendMode().
:add
- SUBTRACT =
Mode for blendMode().
:subtract
- LIGHTEST =
Mode for blendMode().
:lightest
- DARKEST =
Mode for blendMode().
:darkest
- EXCLUSION =
Mode for blendMode().
:exclusion
- MULTIPLY =
Mode for blendMode().
:multiply
- SCREEN =
Mode for blendMode().
:screen
- REPLACE =
Mode for blendMode().
:replace
- LEFT =
Key code or Mode for textAlign().
:left
- RIGHT =
Key code or Mode for textAlign().
:right
- TOP =
Mode for textAlign().
:top
- BOTTOM =
Mode for textAlign().
:bottom
- BASELINE =
Mode for textAlign().
:baseline
- IMAGE =
Mode for textureMode().
:image
- NORMAL =
Mode for textureMode().
:normal
- CLAMP =
Mode for textureWrap().
:clamp
- REPEAT =
Mode for textureWrap().
:repeat
- THRESHOLD =
Filter type for filter()
:threshold
- GRAY =
Filter type for filter()
:gray
- INVERT =
Filter type for filter()
:invert
- BLUR =
Filter type for filter()
:blur
- LINE =
Shape mode for createShape()
:line
- RECT =
Shape mode for createShape()
:rect
- ELLIPSE =
Shape mode for createShape()
:ellipse
- ARC =
Shape mode for createShape()
:arc
- TRIANGLE =
Shape mode for createShape()
:triangle
- QUAD =
Shape mode for createShape()
:quad
- GROUP =
Shape mode for createShape()
:group
- POINTS =
Shape mode for beginShape()
:points
- LINES =
Shape mode for beginShape()
:lines
- TRIANGLES =
Shape mode for beginShape()
:triangles
- TRIANGLE_FAN =
Shape mode for beginShape()
:triangle_fan
- TRIANGLE_STRIP =
Shape mode for beginShape()
:triangle_strip
- QUADS =
Shape mode for beginShape()
:quads
- QUAD_STRIP =
Shape mode for beginShape()
:quad_strip
- TESS =
Shape mode for beginShape()
:tess
- OPEN =
OPEN flag for endShape()
:open
- CLOSE =
CLOSE flag for endShape()
:close
- ENTER =
Key codes.
:enter
- SPACE =
:space
- TAB =
:tab
- DELETE =
:delete
- BACKSPACE =
:backspace
- ESC =
:escape
- HOME =
:home
- PAGEUP =
END = :end
:pageup
- PAGEDOWN =
:pagedown
- CLEAR =
:clear
- SHIFT =
:shift
- CONTROL =
:control
- ALT =
:alt
- WIN =
:win
- COMMAND =
:command
- OPTION =
:option
- FUNCTION =
:function
- CAPSLOCK =
:capslock
- SECTION =
:section
- HELP =
:help
- F1 =
:f1
- F2 =
:f2
- F3 =
:f3
- F4 =
:f4
- F5 =
:f5
- F6 =
:f6
- F7 =
:f7
- F8 =
:f8
- F9 =
:f9
- F10 =
:f10
- F11 =
:f11
- F12 =
:f12
- F13 =
:f13
- F14 =
:f14
- F15 =
:f15
- F16 =
:f16
- F17 =
:f17
- F18 =
:f18
- F19 =
:f19
- F20 =
:f20
- F21 =
:f21
- F22 =
:f22
- F23 =
:f23
- F24 =
:f24
- UP =
:up
- DOWN =
:down
- COLOR_CODES =
{ aliceblue: '#f0f8ff', antiquewhite: '#faebd7', aqua: '#00ffff', aquamarine: '#7fffd4', azure: '#f0ffff', beige: '#f5f5dc', bisque: '#ffe4c4', black: '#000000', blanchedalmond: '#ffebcd', blue: '#0000ff', blueviolet: '#8a2be2', brown: '#a52a2a', burlywood: '#deb887', cadetblue: '#5f9ea0', chartreuse: '#7fff00', chocolate: '#d2691e', coral: '#ff7f50', cornflowerblue: '#6495ed', cornsilk: '#fff8dc', crimson: '#dc143c', cyan: '#00ffff', darkblue: '#00008b', darkcyan: '#008b8b', darkgoldenrod: '#b8860b', darkgray: '#a9a9a9', darkgreen: '#006400', darkgrey: '#a9a9a9', darkkhaki: '#bdb76b', darkmagenta: '#8b008b', darkolivegreen: '#556b2f', darkorange: '#ff8c00', darkorchid: '#9932cc', darkred: '#8b0000', darksalmon: '#e9967a', darkseagreen: '#8fbc8f', darkslateblue: '#483d8b', darkslategray: '#2f4f4f', darkslategrey: '#2f4f4f', darkturquoise: '#00ced1', darkviolet: '#9400d3', deeppink: '#ff1493', deepskyblue: '#00bfff', dimgray: '#696969', dimgrey: '#696969', dodgerblue: '#1e90ff', firebrick: '#b22222', floralwhite: '#fffaf0', forestgreen: '#228b22', fuchsia: '#ff00ff', gainsboro: '#dcdcdc', ghostwhite: '#f8f8ff', goldenrod: '#daa520', gold: '#ffd700', gray: '#808080', green: '#008000', greenyellow: '#adff2f', grey: '#808080', honeydew: '#f0fff0', hotpink: '#ff69b4', indianred: '#cd5c5c', indigo: '#4b0082', ivory: '#fffff0', khaki: '#f0e68c', lavenderblush: '#fff0f5', lavender: '#e6e6fa', lawngreen: '#7cfc00', lemonchiffon: '#fffacd', lightblue: '#add8e6', lightcoral: '#f08080', lightcyan: '#e0ffff', lightgoldenrodyellow: '#fafad2', lightgray: '#d3d3d3', lightgreen: '#90ee90', lightgrey: '#d3d3d3', lightpink: '#ffb6c1', lightsalmon: '#ffa07a', lightseagreen: '#20b2aa', lightskyblue: '#87cefa', lightslategray: '#778899', lightslategrey: '#778899', lightsteelblue: '#b0c4de', lightyellow: '#ffffe0', lime: '#00ff00', limegreen: '#32cd32', linen: '#faf0e6', magenta: '#ff00ff', maroon: '#800000', mediumaquamarine: '#66cdaa', mediumblue: '#0000cd', mediumorchid: '#ba55d3', mediumpurple: '#9370db', mediumseagreen: '#3cb371', mediumslateblue: '#7b68ee', mediumspringgreen: '#00fa9a', mediumturquoise: '#48d1cc', mediumvioletred: '#c71585', midnightblue: '#191970', mintcream: '#f5fffa', mistyrose: '#ffe4e1', moccasin: '#ffe4b5', navajowhite: '#ffdead', navy: '#000080', oldlace: '#fdf5e6', olive: '#808000', olivedrab: '#6b8e23', orange: '#ffa500', orangered: '#ff4500', orchid: '#da70d6', palegoldenrod: '#eee8aa', palegreen: '#98fb98', paleturquoise: '#afeeee', palevioletred: '#db7093', papayawhip: '#ffefd5', peachpuff: '#ffdab9', peru: '#cd853f', pink: '#ffc0cb', plum: '#dda0dd', powderblue: '#b0e0e6', purple: '#800080', rebeccapurple: '#663399', red: '#ff0000', rosybrown: '#bc8f8f', royalblue: '#4169e1', saddlebrown: '#8b4513', salmon: '#fa8072', sandybrown: '#f4a460', seagreen: '#2e8b57', seashell: '#fff5ee', sienna: '#a0522d', silver: '#c0c0c0', skyblue: '#87ceeb', slateblue: '#6a5acd', slategray: '#708090', slategrey: '#708090', snow: '#fffafa', springgreen: '#00ff7f', steelblue: '#4682b4', tan: '#d2b48c', teal: '#008080', thistle: '#d8bfd8', tomato: '#ff6347', turquoise: '#40e0d0', violet: '#ee82ee', wheat: '#f5deb3', white: '#ffffff', whitesmoke: '#f5f5f5', yellow: '#ffff00', yellowgreen: '#9acd32', none: '#00000000', }
Instance Method Summary collapse
-
#abs(value) ⇒ Numeric
Returns the absolute number of the value.
-
#acos(value) ⇒ Numeric
Returns the inverse of cos().
-
#alpha(color) ⇒ Numeric
Returns the red value of the color.
-
#angleMode(mode = nil) ⇒ RADIANS, DEGREES
Sets angle mode.
-
#applyMatrix(*args) ⇒ nil
Reset current transformation matrix with 2x3, or 4x4 matrix.
-
#arc(a, b, c, d, start, stop) ⇒ nil
(also: #drawArc)
Draws an arc.
-
#asin(value) ⇒ Numeric
Returns the inverse of sin().
-
#atan(value) ⇒ Numeric
Returns the inverse of tan().
-
#atan2(y, x) ⇒ Numeric
Returns the angle from a specified point.
-
#background(*args) ⇒ nil
Clears screen.
-
#beginContour ⇒ nil
Begins drawing a hole inside shape.
-
#beginShape(type = nil) ⇒ nil
Begins drawing complex shapes.
-
#bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2) ⇒ nil
(also: #drawBezier)
Draws a Bezier spline curve.
-
#bezierDetail(detail) ⇒ nil
Sets the resolution at which Bezier’s curve is displayed.
-
#bezierPoint(a, b, c, d, t) ⇒ Numeric
Evaluates the Bezier at point t for points a, b, c, d.
-
#bezierTangent(a, b, c, d, t) ⇒ Numeric
Calculates the tangent of a point on a Bezier curve.
-
#bezierVertex(x2, y2, x3, y3, x4, y4) ⇒ nil
Append bezier vertex for shape polygon.
-
#blend(img = nil, sx, sy, sw, sh, dx, dy, dw, dh, mode) ⇒ nil
Blends image.
-
#blendMode(mode = nil) ⇒ nil
Sets blend mode.
-
#blue(color) ⇒ Numeric
Returns the blue value of the color.
-
#brightness(color) ⇒ Numeric
Returns the brightness value of the color.
-
#ceil(value) ⇒ Numeric
Returns the closest integer number greater than or equal to the value.
-
#circle(x, y, extent) ⇒ nil
(also: #drawCircle)
Draws a circle.
- #clear ⇒ Object
-
#clip(a, b, c, d) ⇒ nil
Limits the drawable rectangle.
-
#color(*args) ⇒ Integer
Creates color value.
-
#colorMode(mode = nil, *maxes) ⇒ RGB, HSB
Sets color mode and max color values.
-
#constrain(value, min, max) ⇒ Numeric
Constrains the number between min..max.
-
#copy(img = nil, sx, sy, sw, sh, dx, dy, dw, dh) ⇒ nil
Copies image.
-
#cos(angle) ⇒ Numeric
Returns the cosine of an angle.
-
#createCapture(*args) ⇒ Capture
Creates a camera object as a video input device.
-
#createFont(name, size) ⇒ Font
Creates a new font object.
-
#createGraphics(width, height, pixelDensity = 1) ⇒ Graphics
Creates a new off-screen graphics context object.
-
#createImage(w, h, format = RGBA) ⇒ Image
Creates a new image object.
-
#createShader(vert, frag) ⇒ Shader
Creates a shader object.
-
#createShape(kind = nil, *args) ⇒ Shape
Creates a new shape object.
-
#createVector(*args) ⇒ Vector
Creates a new vector object.
-
#curve(cx1, cy1, x1, y1, x2, y2, cx2, cy2) ⇒ nil
(also: #drawCurve)
Draws a Catmull-Rom spline curve.
-
#curveDetail(detail) ⇒ nil
Sets the resolution at which curves display.
-
#curvePoint(a, b, c, d, t) ⇒ Numeric
Evaluates the curve at point t for points a, b, c, d.
-
#curveTangent(a, b, c, d, t) ⇒ Numeric
Calculates the tangent of a point on a curve.
-
#curveTightness(tightness) ⇒ nil
Sets the quality of curve forms.
-
#curveVertex(x, y) ⇒ nil
Append curve vertex for shape polygon.
-
#degrees(radian) ⇒ Numeric
Converts radian to degree.
-
#dist(*args) ⇒ Numeric
Returns distance between 2 points.
-
#ellipse(a, b, c, d) ⇒ nil
(also: #drawEllipse)
Draws an ellipse.
-
#ellipseMode(mode) ⇒ nil
Sets ellipse mode.
-
#endContour ⇒ nil
Ends drawing a hole.
-
#endShape(mode = nil) ⇒ nil
Ends drawing complex shapes.
-
#exp(n) ⇒ Numeric
Returns Euler’s number e raised to the power of value.
-
#fill(*args) ⇒ nil
Sets fill color.
-
#filter(*args) ⇒ nil
Applies an image filter to screen.
-
#floor(value) ⇒ Numeric
Returns the closest integer number less than or equal to the value.
-
#green(color) ⇒ Numeric
Returns the green value of the color.
-
#height ⇒ Numeric
Returns the height of the graphics object.
-
#hue(color) ⇒ Numeric
Returns the hue value of the color.
-
#image(img, a, b, c = nil, d = nil) ⇒ nil
(also: #drawImage)
Draws an image.
-
#imageMode(mode) ⇒ nil
Sets image mode.
-
#lerp(start, stop, amount) ⇒ Numeric
Returns the interpolated number between range start..stop.
-
#lerpColor(color1, color2, amount) ⇒ Integer
Returns the interpolated color between color1 and color2.
-
#line(x1, y1, x2, y2) ⇒ nil
(also: #drawLine)
Draws a line.
-
#loadFont(filename) ⇒ Font
Loads font from file.
-
#loadImage(filename, extension = nil) ⇒ Image
Loads image.
-
#loadPixels ⇒ nil
Loads all pixels to the ‘pixels’ array.
-
#loadShader(fragPath, vertPath = nil) ⇒ Shader
Loads shader file.
- #loadShape(filename) ⇒ Object
-
#log(n) ⇒ Numeric
Returns the natural logarithm (the base-e logarithm) of a number.
-
#mag(*args) ⇒ Numeric
Returns the magnitude (or length) of a vector.
-
#map(value, start1, stop1, start2, stop2) ⇒ Numeric
Maps a number from range start1..stop1 to range start2..stop2.
-
#max(*args) ⇒ Numeric
Returns maximum value.
-
#min(*args) ⇒ Numeric
Returns minimum value.
-
#noClip ⇒ nil
Disables clipping.
-
#noFill ⇒ nil
Disables filling.
-
#noise(x, y = 0, z = 0) ⇒ Numeric
Returns the perlin noise value.
-
#noiseDetail(lod, falloff = nil) ⇒ nil
Adjusts the character and level of detail produced by the Perlin noise function.
-
#noiseSeed(seed) ⇒ nil
Sets the seed value for noise().
-
#norm(value, start, stop) ⇒ Numeric
Normalize the value from range start..stop into 0..1.
-
#noStroke ⇒ nil
Disables drawing stroke.
-
#noTint ⇒ nil
Resets tint color.
-
#pixelDensity ⇒ Numeric
Returns the pixel density of the graphics object.
-
#pixelHeight ⇒ Numeric
Returns the height of the graphics object in pixels.
-
#pixels ⇒ Array
An array of all pixels.
-
#pixelWidth ⇒ Numeric
Returns the width of the graphics object in pixels.
-
#point(x, y) ⇒ nil
(also: #drawPoint)
Draws a point.
-
#pop ⇒ nil
Restore styles and transformations from stack.
-
#popMatrix ⇒ nil
Pops the current transformation matrix from stack.
-
#popStyle ⇒ nil
Restore style values from the style stack.
-
#pow(value, exponent) ⇒ Numeric
Returns value raised to the power of exponent.
-
#printMatrix ⇒ nil
Prints matrix elements to console.
-
#push(&block) ⇒ Object
Save current styles and transformations to stack.
-
#pushMatrix(&block) ⇒ Object
Pushes the current transformation matrix to stack.
-
#pushStyle(&block) ⇒ Object
Save current style values to the style stack.
-
#quad(x1, y1, x2, y2, x3, y3, x4, y4) ⇒ nil
(also: #drawQuad)
Draws a quad.
-
#quadraticVertex(cx, cy, x3, y3) ⇒ nil
Append quadratic vertex for shape polygon.
-
#radians(degree) ⇒ Numeric
Converts degree to radian.
-
#random(*args) ⇒ Float
Returns a random number in range low…high.
-
#randomGaussian(mean = 0, sd = 1) ⇒ Float
Returns a random number fitting a Gaussian, or normal, distribution.
-
#randomSeed(seed) ⇒ nil
Sets the seed value for random().
-
#rect(a, b, c, d, *args) ⇒ nil
(also: #drawRect)
Draws a rectangle.
-
#rectMode(mode) ⇒ nil
Sets rect mode.
-
#red(color) ⇒ Numeric
Returns the red value of the color.
-
#renderMode(mode = nil) ⇒ PROCESSING, P5JS
Sets render mode.
-
#requestImage(filename, extension = nil) ⇒ Image
Loads image on a new thread.
-
#resetMatrix ⇒ nil
Reset current transformation matrix with identity matrix.
-
#resetShader ⇒ nil
Resets shader.
-
#rotate(angle) ⇒ nil
Applies rotation matrix to current transformation matrix.
-
#rotateX(angle) ⇒ nil
Applies rotation around the x-axis.
-
#rotateY(angle) ⇒ nil
Applies rotation around the y-axis.
-
#rotateZ(angle) ⇒ nil
Applies rotation around the z-axis.
-
#round(value) ⇒ Numeric
Returns the closest integer number.
-
#saturation(color) ⇒ Numeric
Returns the saturation value of the color.
-
#save(filename) ⇒ nil
Saves screen image to file.
-
#scale(x, y = nil, z = 1) ⇒ nil
Applies scale matrix to current transformation matrix.
-
#shader(shader) ⇒ nil
Sets shader.
-
#shape(shp, a = 0, b = 0, c = nil, d = nil) ⇒ nil
(also: #drawShape)
Draws a shape.
-
#shapeMode(mode) ⇒ nil
Sets shape mode.
-
#shearX(angle) ⇒ nil
Applies shear around the x-axis.
-
#shearY(angle) ⇒ nil
Applies shear around the y-axis.
-
#sin(angle) ⇒ Numeric
Returns the sine of an angle.
-
#sq(value) ⇒ Numeric
Returns squared value.
-
#sqrt(value) ⇒ Numeric
Returns squared value.
-
#square(x, y, extent) ⇒ nil
(also: #drawSquare)
Draws a square.
-
#stroke(*args) ⇒ nil
Sets stroke color.
-
#strokeCap(cap) ⇒ nil
Sets stroke cap mode.
-
#strokeJoin(join) ⇒ nil
Sets stroke join mode.
-
#strokeWeight(weight) ⇒ nil
Sets stroke weight.
-
#tan(angle) ⇒ Numeric
Returns the ratio of the sine and cosine of an angle.
-
#text(str, x, y, x2 = nil, y2 = nil) ⇒ nil
(also: #drawText)
Draws a text.
-
#textAlign(horizontal, vertical = BASELINE) ⇒ nil
Sets the alignment for drawing text.
-
#textAscent ⇒ Numeric
Returns ascent of the current font at its current size.
-
#textDescent ⇒ Numeric
Returns descent of the current font at its current size.
-
#textFont(font = nil, size = nil) ⇒ Font
Sets text font.
-
#textLeading(leading = nil) ⇒ Numeric
Sets the spacing between lines of text in units of pixels.
-
#textSize(size) ⇒ nil
Sets text size.
-
#texture(image) ⇒ nil
Sets texture.
-
#textureMode(mode) ⇒ nil
Sets the coordinate space for texture mapping.
-
#textureWrap(wrap) ⇒ nil
Sets the texture wrapping mode.
-
#textWidth(str) ⇒ Numeric
Returns the width of the text.
-
#tint(*args) ⇒ nil
Sets fill color for drawing images.
-
#translate(x, y, z = 0) ⇒ nil
Applies translation matrix to current transformation matrix.
-
#triangle(x1, y1, x2, y2, x3, y3) ⇒ nil
(also: #drawTriangle)
Draws a triangle.
-
#updatePixels(&block) ⇒ nil
Update the image pixels with the ‘pixels’ array.
-
#vertex(x, y, u = nil, v = nil) ⇒ nil
Append vertex for shape polygon.
-
#width ⇒ Numeric
Returns the width of the graphics object.
Instance Method Details
#abs(value) ⇒ Numeric
Returns the absolute number of the value.
2486 2487 2488 |
# File 'lib/processing/graphics_context.rb', line 2486 def abs(value) value.abs end |
#acos(value) ⇒ Numeric
Returns the inverse of cos().
2857 2858 2859 |
# File 'lib/processing/graphics_context.rb', line 2857 def acos(value) Math.acos value end |
#alpha(color) ⇒ Numeric
Returns the red value of the color.
751 752 753 |
# File 'lib/processing/graphics_context.rb', line 751 def alpha(color) ((color >> 24) & 0xff) / 255.0 * @colorMaxes__[3] end |
#angleMode(mode = nil) ⇒ RADIANS, DEGREES
Sets angle mode.
844 845 846 847 848 849 850 851 852 853 854 855 |
# File 'lib/processing/graphics_context.rb', line 844 def angleMode(mode = nil) if mode != nil @angleMode__ = mode @toRad__, @toDeg__, @fromRad__, @fromDeg__ = case mode.downcase.to_sym when RADIANS then [1.0, RAD2DEG__, 1.0, DEG2RAD__] when DEGREES then [DEG2RAD__, 1.0, RAD2DEG__, 1.0] else raise ArgumentError, "invalid angle mode: #{mode}" end end @angleMode__ end |
#applyMatrix(array) ⇒ nil #applyMatrix(a, b, c, d, e, f) ⇒ nil #applyMatrix(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) ⇒ nil
Reset current transformation matrix with 2x3, or 4x4 matrix.
2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 |
# File 'lib/processing/graphics_context.rb', line 2282 def applyMatrix(*args) assertDrawing__ args = args.first if args.first.kind_of?(Array) if args.size == 6 a, b, c, d, e, f = args args = [ a, b, 0, 0, c, d, 0, 0, 0, 0, 1, 0, e, f, 0, 1 ] end raise ArgumentError unless args.size == 16 m = Rays::Matrix.new(*args) m.transpose! if @p5jsMode__ @painter__.matrix *= m nil end |
#arc(a, b, c, d, start, stop) ⇒ nil Also known as: drawArc
Draws an arc.
The parameters a, b, c, and d are determined by ellipseMode().
1595 1596 1597 1598 1599 1600 1601 |
# File 'lib/processing/graphics_context.rb', line 1595 def arc(a, b, c, d, start, stop) assertDrawing__ x, y, w, h = toXYWH__ @ellipseMode__, a, b, c, d from, to = toDegrees__(-start), toDegrees__(-stop) @painter__.ellipse x, y, w, h, from: from, to: to nil end |
#asin(value) ⇒ Numeric
Returns the inverse of sin().
2844 2845 2846 |
# File 'lib/processing/graphics_context.rb', line 2844 def asin(value) Math.asin value end |
#atan(value) ⇒ Numeric
Returns the inverse of tan().
2870 2871 2872 |
# File 'lib/processing/graphics_context.rb', line 2870 def atan(value) Math.atan value end |
#atan2(y, x) ⇒ Numeric
Returns the angle from a specified point.
2884 2885 2886 |
# File 'lib/processing/graphics_context.rb', line 2884 def atan2(y, x) Math.atan2 y, x end |
#background(str) ⇒ nil #background(str, alpha) ⇒ nil #background(gray) ⇒ nil #background(gray, alpha) ⇒ nil #background(r, g, b) ⇒ nil #background(r, g, b, alpha) ⇒ nil
Clears screen.
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 |
# File 'lib/processing/graphics_context.rb', line 1445 def background(*args) assertDrawing__ rgba = toRGBA__(*args) if rgba[3] == 1 @painter__.background(*rgba) else @painter__.push fill: rgba, stroke: :none do |_| @painter__.rect 0, 0, width, height end end nil end |
#beginContour ⇒ nil
Begins drawing a hole inside shape.
1895 1896 1897 1898 |
# File 'lib/processing/graphics_context.rb', line 1895 def beginContour() (@drawingShape__ or raise "beginContour() must be called after beginShape()") .beginContour end |
#beginShape(type = nil) ⇒ nil
Begins drawing complex shapes.
1849 1850 1851 1852 1853 |
# File 'lib/processing/graphics_context.rb', line 1849 def beginShape(type = nil) raise "beginShape() cannot be called twice" if @drawingShape__ @drawingShape__ = createShape @drawingShape__.beginShape type end |
#bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2) ⇒ nil Also known as: drawBezier
Draws a Bezier spline curve.
1710 1711 1712 1713 1714 1715 1716 |
# File 'lib/processing/graphics_context.rb', line 1710 def bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2) assertDrawing__ @painter__.nsegment = @bezierDetail__ @painter__.bezier x1, y1, cx1, cy1, cx2, cy2, x2, y2 @painter__.nsegment = 0 nil end |
#bezierDetail(detail) ⇒ nil
Sets the resolution at which Bezier’s curve is displayed. The default value is 20.
1134 1135 1136 1137 1138 |
# File 'lib/processing/graphics_context.rb', line 1134 def bezierDetail(detail) detail = 1 if detail < 1 @bezierDetail__ = detail nil end |
#bezierPoint(a, b, c, d, t) ⇒ Numeric
Evaluates the Bezier at point t for points a, b, c, d.
2949 2950 2951 2952 2953 2954 2955 |
# File 'lib/processing/graphics_context.rb', line 2949 def bezierPoint(a, b, c, d, t) tt = 1.0 - t tt ** 3.0 * a + tt ** 2.0 * b * 3.0 * t + t ** 2.0 * c * 3.0 * tt + t ** 3.0 * d end |
#bezierTangent(a, b, c, d, t) ⇒ Numeric
Calculates the tangent of a point on a Bezier curve.
2970 2971 2972 2973 2974 2975 2976 2977 2978 |
# File 'lib/processing/graphics_context.rb', line 2970 def bezierTangent(a, b, c, d, t) tt = 1.0 - t 3.0 * d * t ** 2.0 - 3.0 * c * t ** 2.0 + 6.0 * c * tt * t - 6.0 * b * tt * t + 3.0 * b * tt ** 2.0 - 3.0 * a * tt ** 2.0 end |
#bezierVertex(x2, y2, x3, y3, x4, y4) ⇒ nil
Append bezier vertex for shape polygon.
1957 1958 1959 1960 |
# File 'lib/processing/graphics_context.rb', line 1957 def bezierVertex(x2, y2, x3, y3, x4, y4) (@drawingShape__ or raise "bezierVertex() must be called after beginShape()") .bezierVertex x2, y2, x3, y3, x4, y4 end |
#blend(sx, sy, sw, sh, dx, dy, dw, dh, mode) ⇒ nil #blend(img, sx, sy, sw, sh, dx, dy, dw, dh, mode) ⇒ nil
Blends image.
2022 2023 2024 2025 2026 2027 |
# File 'lib/processing/graphics_context.rb', line 2022 def blend(img = nil, sx, sy, sw, sh, dx, dy, dw, dh, mode) assertDrawing__ (img || self).drawImage__( @painter__, sx, sy, sw, sh, dx, dy, dw, dh, fill: getTint__, stroke: :none, blend_mode: mode) end |
#blendMode(mode = nil) ⇒ nil
Sets blend mode. Default is BLEND.
966 967 968 969 970 971 972 |
# File 'lib/processing/graphics_context.rb', line 966 def blendMode(mode = nil) if mode != nil @blendMode__ = mode @painter__.blend_mode = mode end @blendMode__ end |
#blue(color) ⇒ Numeric
Returns the blue value of the color.
738 739 740 |
# File 'lib/processing/graphics_context.rb', line 738 def blue(color) (color & 0xff) / 255.0 * @colorMaxes__[2] end |
#brightness(color) ⇒ Numeric
Returns the brightness value of the color.
792 793 794 795 |
# File 'lib/processing/graphics_context.rb', line 792 def brightness(color) _, _, b = color2raw__(color).to_hsv b * (@hsbColor__ ? @colorMaxes__[2] : 1) end |
#ceil(value) ⇒ Numeric
Returns the closest integer number greater than or equal to the value.
2499 2500 2501 |
# File 'lib/processing/graphics_context.rb', line 2499 def ceil(value) value.ceil end |
#circle(x, y, extent) ⇒ nil Also known as: drawCircle
Draws a circle.
1573 1574 1575 |
# File 'lib/processing/graphics_context.rb', line 1573 def circle(x, y, extent) ellipse x, y, extent, extent end |
#clear ⇒ Object
1458 1459 1460 1461 1462 |
# File 'lib/processing/graphics_context.rb', line 1458 def clear() assertDrawing__ @painter__.background 0, 0 nil end |
#clip(a, b, c, d) ⇒ nil
Limits the drawable rectangle.
The parameters a, b, c, and d are determined by rectMode().
1196 1197 1198 1199 1200 |
# File 'lib/processing/graphics_context.rb', line 1196 def clip(a, b, c, d) x, y, w, h = toXYWH__ @imageMode__, a, b, c, d @painter__.clip x, y, w, h nil end |
#color(gray) ⇒ Integer #color(gray, alpha) ⇒ Integer #color(v1, v2, v3) ⇒ Integer #color(v1, v2, v3, alpha) ⇒ Integer
Creates color value.
688 689 690 691 692 |
# File 'lib/processing/graphics_context.rb', line 688 def color(*args) toRGBA__(*args) .map {|n| (n * 255).to_i.clamp 0, 255} .then {|r, g, b, a| Image.toColor__ r, g, b, a} end |
#colorMode(mode) ⇒ RGB, HSB #colorMode(mode, max) ⇒ RGB, HSB #colorMode(mode, max1, max2, max3) ⇒ RGB, HSB #colorMode(mode, max1, max2, max3, maxA) ⇒ RGB, HSB
Sets color mode and max color values.
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
# File 'lib/processing/graphics_context.rb', line 654 def colorMode(mode = nil, *maxes) if mode != nil mode = mode.downcase.to_sym raise ArgumentError, "invalid color mode: #{mode}" unless [RGB, HSB].include?(mode) raise ArgumentError unless [0, 1, 3, 4].include?(maxes.size) @colorMode__ = mode @hsbColor__ = mode == HSB case maxes.size when 1 then @colorMaxes__ = [maxes.first.to_f] * 4 when 3, 4 then @colorMaxes__[0...maxes.size] = maxes.map &:to_f end end @colorMode__ end |
#constrain(value, min, max) ⇒ Numeric
Constrains the number between min..max.
2766 2767 2768 |
# File 'lib/processing/graphics_context.rb', line 2766 def constrain(value, min, max) value < min ? min : (value > max ? max : value) end |
#copy(sx, sy, sw, sh, dx, dy, dw, dh) ⇒ nil #copy(img, sx, sy, sw, sh, dx, dy, dw, dh) ⇒ nil
Copies image.
1997 1998 1999 |
# File 'lib/processing/graphics_context.rb', line 1997 def copy(img = nil, sx, sy, sw, sh, dx, dy, dw, dh) blend img, sx, sy, sw, sh, dx, dy, dw, dh, BLEND end |
#cos(angle) ⇒ Numeric
Returns the cosine of an angle.
2818 2819 2820 |
# File 'lib/processing/graphics_context.rb', line 2818 def cos(angle) Math.cos angle end |
#createCapture(*args) ⇒ Capture
Creates a camera object as a video input device.
3280 3281 3282 |
# File 'lib/processing/graphics_context.rb', line 3280 def createCapture(*args) Capture.new(*args) end |
#createFont(name, size) ⇒ Font
Creates a new font object.
3131 3132 3133 3134 |
# File 'lib/processing/graphics_context.rb', line 3131 def createFont(name, size) size = FONT_SIZE_MAX__ if size && size > FONT_SIZE_MAX__ Font.new Rays::Font.new(name, size || FONT_SIZE_DEFAULT__) end |
#createGraphics(width, height, pixelDensity = 1) ⇒ Graphics
Creates a new off-screen graphics context object.
3232 3233 3234 |
# File 'lib/processing/graphics_context.rb', line 3232 def createGraphics(width, height, pixelDensity = 1) Graphics.new width, height, pixelDensity end |
#createImage(w, h) ⇒ Image #createImage(w, h, format) ⇒ Image
Creates a new image object.
3150 3151 3152 3153 3154 |
# File 'lib/processing/graphics_context.rb', line 3150 def createImage(w, h, format = RGBA) colorspace = {RGB => Rays::RGB, RGBA => Rays::RGBA}[format] raise ArgumentError, "Unknown image format" unless colorspace Image.new Rays::Image.new(w, h, colorspace).paint {background 0, 0} end |
#createShader(vertPath, fragPath) ⇒ Shader #createShader(vertSource, fragSource) ⇒ Shader
Creates a shader object.
Passing nil for a vertex shader parameter causes the following default vertex shader to be used. “‘ attribute vec3 position; attribute vec3 texCoord; attribute vec4 color; varying vec4 vertPosition; varying vec4 vertTexCoord; varying vec4 vertColor; uniform mat4 transform; uniform mat4 texMatrix; void main ()
vec4 pos__ = vec4(position, 1.0);
vertPosition = pos__;
vertTexCoord = texMatrix * vec4(texCoord, 1.0);
vertColor = color;
gl_Position = transform * pos__;
“‘
3270 3271 3272 3273 3274 |
# File 'lib/processing/graphics_context.rb', line 3270 def createShader(vert, frag) vert = File.read if vert && File.exist?(vert) frag = File.read if frag && File.exist?(frag) Shader.new vert, frag end |
#createShape ⇒ Shape #createShape(LINE, x1, y1, x2, y2) ⇒ Shape #createShape(RECT, a, b, c, d) ⇒ Shape #createShape(ELLIPSE, a, b, c, d) ⇒ Shape #createShape(ARC, a, b, c, d, start, stop) ⇒ Shape #createShape(TRIANGLE, x1, y1, x2, y2, x3, y3) ⇒ Shape #createShape(QUAD, x1, y1, x2, y2, x3, y3, x4, y4) ⇒ Shape #createShape(GROUP) ⇒ Shape
Creates a new shape object.
3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 |
# File 'lib/processing/graphics_context.rb', line 3173 def createShape(kind = nil, *args) case kind when LINE then createLineShape__( *args) when RECT then createRectShape__( *args) when ELLIPSE then createEllipseShape__( *args) when ARC then createArcShape__( *args) when TRIANGLE then createTriangleShape__(*args) when QUAD then createQuadShape__( *args) when GROUP then Shape.new nil, [], context: self when nil then Shape.new context: self else raise ArgumentError, "Unknown shape kind '#{kind}'" end end |
#createVector ⇒ Vector #createVector(x, y) ⇒ Vector #createVector(x, y, z) ⇒ Vector
Creates a new vector object.
3118 3119 3120 |
# File 'lib/processing/graphics_context.rb', line 3118 def createVector(*args) Vector.new(*args, context: self) end |
#curve(cx1, cy1, x1, y1, x2, y2, cx2, cy2) ⇒ nil Also known as: drawCurve
Draws a Catmull-Rom spline curve.
1684 1685 1686 1687 1688 1689 1690 |
# File 'lib/processing/graphics_context.rb', line 1684 def curve(cx1, cy1, x1, y1, x2, y2, cx2, cy2) assertDrawing__ @painter__.nsegment = @curveDetail__ @painter__.curve cx1, cy1, x1, y1, x2, y2, cx2, cy2 @painter__.nsegment = 0 nil end |
#curveDetail(detail) ⇒ nil
Sets the resolution at which curves display. The default value is 20 while the minimum value is 3.
1104 1105 1106 1107 1108 |
# File 'lib/processing/graphics_context.rb', line 1104 def curveDetail(detail) detail = 3 if detail < 3 @curveDetail__ = detail nil end |
#curvePoint(a, b, c, d, t) ⇒ Numeric
Evaluates the curve at point t for points a, b, c, d.
2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 |
# File 'lib/processing/graphics_context.rb', line 2901 def curvePoint(a, b, c, d, t) s = @curveTightness__ t3 = t * t * t t2 = t * t f1 = ( s - 1.0) / 2.0 * t3 + ( 1.0 - s) * t2 + (s - 1.0) / 2.0 * t f2 = ( s + 3.0) / 2.0 * t3 + (-5.0 - s) / 2.0 * t2 + 1.0 f3 = (-3.0 - s) / 2.0 * t3 + ( s + 2.0) * t2 + (1.0 - s) / 2.0 * t f4 = ( 1.0 - s) / 2.0 * t3 + ( s - 1.0) / 2.0 * t2 a * f1 + b * f2 + c * f3 + d * f4 end |
#curveTangent(a, b, c, d, t) ⇒ Numeric
Calculates the tangent of a point on a curve.
2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 |
# File 'lib/processing/graphics_context.rb', line 2925 def curveTangent(a, b, c, d, t) s = @curveTightness__ tt3 = t * t * 3.0 t2 = t * 2.0 f1 = ( s - 1.0) / 2.0 * tt3 + ( 1.0 - s) * t2 + (s - 1.0) / 2.0 f2 = ( s + 3.0) / 2.0 * tt3 + (-5.0 - s) / 2.0 * t2 f3 = (-3.0 - s) / 2.0 * tt3 + ( s + 2.0) * t2 + (1.0 - s) / 2.0 f4 = ( 1.0 - s) / 2.0 * tt3 + ( s - 1.0) / 2.0 * t2 a * f1 + b * f2 + c * f3 + d * f4 end |
#curveTightness(tightness) ⇒ nil
Sets the quality of curve forms.
1119 1120 1121 1122 |
# File 'lib/processing/graphics_context.rb', line 1119 def curveTightness(tightness) @curveTightness__ = tightness nil end |
#curveVertex(x, y) ⇒ nil
Append curve vertex for shape polygon.
1942 1943 1944 1945 |
# File 'lib/processing/graphics_context.rb', line 1942 def curveVertex(x, y) (@drawingShape__ or raise "curveVertex() must be called after beginShape()") .curveVertex x, y end |
#degrees(radian) ⇒ Numeric
Converts radian to degree.
2792 2793 2794 |
# File 'lib/processing/graphics_context.rb', line 2792 def degrees(radian) radian * RAD2DEG__ end |
#dist(x1, y1, x2, y2) ⇒ Numeric #dist(x1, y1, z1, x2, y2, z2) ⇒ Numeric
Returns distance between 2 points.
2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 |
# File 'lib/processing/graphics_context.rb', line 2635 def dist(*args) case args.size when 4 x1, y1, x2, y2 = *args xx, yy = x2 - x1, y2 - y1 Math.sqrt xx * xx + yy * yy when 3 x1, y1, z1, x2, y2, z2 = *args xx, yy, zz = x2 - x1, y2 - y1, z2 - z1 Math.sqrt xx * xx + yy * yy + zz * zz else raise ArgumentError end end |
#ellipse(a, b, c, d) ⇒ nil Also known as: drawEllipse
Draws an ellipse.
The parameters a, b, c, and d are determined by ellipseMode().
1553 1554 1555 1556 1557 1558 |
# File 'lib/processing/graphics_context.rb', line 1553 def ellipse(a, b, c, d) assertDrawing__ x, y, w, h = toXYWH__ @ellipseMode__, a, b, c, d @painter__.ellipse x, y, w, h nil end |
#ellipseMode(mode) ⇒ nil
Sets ellipse mode. Default is CENTER.
CORNER -> ellipse(left, top, width, height) CORNERS -> ellipse(left, top, right, bottom) CENTER -> ellipse(centerX, centerY, width, height) RADIUS -> ellipse(centerX, centerY, radiusH, radiusV)
909 910 911 |
# File 'lib/processing/graphics_context.rb', line 909 def ellipseMode(mode) @ellipseMode__ = mode end |
#endContour ⇒ nil
Ends drawing a hole.
1907 1908 1909 1910 |
# File 'lib/processing/graphics_context.rb', line 1907 def endContour() (@drawingShape__ or raise "endContour() must be called after beginShape()") .endContour end |
#endShape ⇒ nil #endShape(CLOSE) ⇒ nil
Ends drawing complex shapes.
1866 1867 1868 1869 1870 1871 1872 |
# File 'lib/processing/graphics_context.rb', line 1866 def endShape(mode = nil) s = @drawingShape__ or raise "endShape() must be called after beginShape()" s.endShape mode shape s @drawingShape__ = nil nil end |
#exp(n) ⇒ Numeric
Returns Euler’s number e raised to the power of value.
2551 2552 2553 |
# File 'lib/processing/graphics_context.rb', line 2551 def exp(n) Math.exp n end |
#fill(rgb) ⇒ nil #fill(rgb, alpha) ⇒ nil #fill(gray) ⇒ nil #fill(gray, alpha) ⇒ nil #fill(r, g, b) ⇒ nil #fill(r, g, b, alpha) ⇒ nil
Sets fill color.
995 996 997 998 |
# File 'lib/processing/graphics_context.rb', line 995 def fill(*args) @painter__.fill(*toRGBA__(*args)) nil end |
#filter(*args) ⇒ nil
Applies an image filter to screen.
overload filter(shader) overload filter(type) overload filter(type, param)
1419 1420 1421 1422 |
# File 'lib/processing/graphics_context.rb', line 1419 def filter(*args) @filter__ = Shader.createFilter__(*args) nil end |
#floor(value) ⇒ Numeric
Returns the closest integer number less than or equal to the value.
2512 2513 2514 |
# File 'lib/processing/graphics_context.rb', line 2512 def floor(value) value.floor end |
#green(color) ⇒ Numeric
Returns the green value of the color.
725 726 727 |
# File 'lib/processing/graphics_context.rb', line 725 def green(color) ((color >> 8) & 0xff) / 255.0 * @colorMaxes__[1] end |
#height ⇒ Numeric
Returns the height of the graphics object.
586 587 588 |
# File 'lib/processing/graphics_context.rb', line 586 def height() getInternal__.height end |
#hue(color) ⇒ Numeric
Returns the hue value of the color.
764 765 766 767 |
# File 'lib/processing/graphics_context.rb', line 764 def hue(color) h, = color2raw__(color).to_hsv h * (@hsbColor__ ? @colorMaxes__[0] : 1) end |
#image(img, a, b) ⇒ nil #image(img, a, b, c, d) ⇒ nil Also known as: drawImage
Draws an image.
The parameters a, b, c, and d are determined by imageMode().
1782 1783 1784 1785 1786 1787 |
# File 'lib/processing/graphics_context.rb', line 1782 def image(img, a, b, c = nil, d = nil) assertDrawing__ x, y, w, h = toXYWH__ @imageMode__, a, b, c || img.width, d || img.height img.drawImage__ @painter__, x, y, w, h, fill: getTint__, stroke: :none nil end |
#imageMode(mode) ⇒ nil
Sets image mode. Default is CORNER.
CORNER -> image(img, left, top, width, height) CORNERS -> image(img, left, top, right, bottom) CENTER -> image(img, centerX, centerY, width, height)
926 927 928 |
# File 'lib/processing/graphics_context.rb', line 926 def imageMode(mode) @imageMode__ = mode end |
#lerp(start, stop, amount) ⇒ Numeric
Returns the interpolated number between range start..stop.
2675 2676 2677 |
# File 'lib/processing/graphics_context.rb', line 2675 def lerp(start, stop, amount) start + (stop - start) * amount end |
#lerpColor(color1, color2, amount) ⇒ Integer
Returns the interpolated color between color1 and color2.
2690 2691 2692 2693 2694 2695 2696 |
# File 'lib/processing/graphics_context.rb', line 2690 def lerpColor(color1, color2, amount) color( lerp(red( color1), red( color2), amount), lerp(green(color1), green(color2), amount), lerp(blue( color1), blue( color2), amount), lerp(alpha(color1), alpha(color2), amount)) end |
#line(x1, y1, x2, y2) ⇒ nil Also known as: drawLine
Draws a line.
1494 1495 1496 1497 1498 |
# File 'lib/processing/graphics_context.rb', line 1494 def line(x1, y1, x2, y2) assertDrawing__ @painter__.line x1, y1, x2, y2 nil end |
#loadFont(filename) ⇒ Font
Loads font from file.
3293 3294 3295 3296 3297 3298 3299 |
# File 'lib/processing/graphics_context.rb', line 3293 def loadFont(filename) ext = File.extname filename raise "unsupported font type -- '#{ext}'" unless ext =~ /^\.?(ttf|otf)$/i filename = httpGet__ filename, ext if filename =~ %r|^https?://| Font.new Rays::Font.load filename end |
#loadImage(filename, extension = nil) ⇒ Image
Loads image.
3311 3312 3313 3314 3315 3316 3317 |
# File 'lib/processing/graphics_context.rb', line 3311 def loadImage(filename, extension = nil) ext = extension || File.extname(filename) raise "unsupported image type -- '#{ext}'" unless ext =~ /^\.?(png|jpg|gif)$/i filename = httpGet__ filename, ext if filename =~ %r|^https?://| Image.new Rays::Image.load filename end |
#loadPixels ⇒ nil
Loads all pixels to the ‘pixels’ array.
2036 2037 2038 |
# File 'lib/processing/graphics_context.rb', line 2036 def loadPixels() @pixels__ = getInternal__.pixels end |
#loadShader(fragPath) ⇒ Shader #loadShader(fragPath, vertPath) ⇒ Shader
Loads shader file.
3358 3359 3360 |
# File 'lib/processing/graphics_context.rb', line 3358 def loadShader(fragPath, vertPath = nil) createShader vertPath, fragPath end |
#loadShape(filename) ⇒ Object
3341 3342 3343 |
# File 'lib/processing/graphics_context.rb', line 3341 def loadShape(filename) Processing::SVGLoader.new(self).load filename end |
#log(n) ⇒ Numeric
Returns the natural logarithm (the base-e logarithm) of a number.
2538 2539 2540 |
# File 'lib/processing/graphics_context.rb', line 2538 def log(n) Math.log n end |
#mag(x, y) ⇒ Numeric #mag(x, y, z) ⇒ Numeric
Returns the magnitude (or length) of a vector.
2609 2610 2611 2612 2613 2614 2615 2616 |
# File 'lib/processing/graphics_context.rb', line 2609 def mag(*args) x, y, z = *args case args.size when 2 then Math.sqrt x * x + y * y when 3 then Math.sqrt x * x + y * y + z * z else raise ArgumentError end end |
#map(value, start1, stop1, start2, stop2) ⇒ Numeric
Maps a number from range start1..stop1 to range start2..stop2.
2711 2712 2713 |
# File 'lib/processing/graphics_context.rb', line 2711 def map(value, start1, stop1, start2, stop2) lerp start2, stop2, norm(value, start1, stop1) end |
#max(a, b) ⇒ Numeric #max(a, b, c) ⇒ Numeric #max(array) ⇒ Numeric
Returns maximum value.
2751 2752 2753 |
# File 'lib/processing/graphics_context.rb', line 2751 def max(*args) args.flatten.max end |
#min(a, b) ⇒ Numeric #min(a, b, c) ⇒ Numeric #min(array) ⇒ Numeric
Returns minimum value.
2731 2732 2733 |
# File 'lib/processing/graphics_context.rb', line 2731 def min(*args) args.flatten.min end |
#noClip ⇒ nil
Disables clipping.
1208 1209 1210 1211 |
# File 'lib/processing/graphics_context.rb', line 1208 def noClip() @painter__.no_clip nil end |
#noFill ⇒ nil
Disables filling.
1007 1008 1009 1010 |
# File 'lib/processing/graphics_context.rb', line 1007 def noFill() @painter__.fill nil nil end |
#noise(x) ⇒ Numeric #noise(x, y) ⇒ Numeric #noise(x, y, z) ⇒ Numeric
Returns the perlin noise value.
2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 |
# File 'lib/processing/graphics_context.rb', line 2995 def noise(x, y = 0, z = 0) seed, falloff = @noiseSeed__, @noiseFallOff__ amp = 0.5 @noiseOctaves__.times.reduce(0) do |sum| value = (Rays.perlin(x, y, z, seed) / 2.0 + 0.5) * amp x *= 2 y *= 2 z *= 2 amp *= falloff sum + value end end |
#noiseDetail(lod, falloff = nil) ⇒ nil
Adjusts the character and level of detail produced by the Perlin noise function.
3031 3032 3033 3034 |
# File 'lib/processing/graphics_context.rb', line 3031 def noiseDetail(lod, falloff = nil) @noiseOctaves__ = lod if lod && lod > 0 @noiseFallOff__ = falloff if falloff && falloff > 0 end |
#noiseSeed(seed) ⇒ nil
Sets the seed value for noise()
3017 3018 3019 |
# File 'lib/processing/graphics_context.rb', line 3017 def noiseSeed(seed) @noiseSeed__ = Random.new(seed).rand 0.0..1.0 end |
#norm(value, start, stop) ⇒ Numeric
Normalize the value from range start..stop into 0..1.
2660 2661 2662 |
# File 'lib/processing/graphics_context.rb', line 2660 def norm(value, start, stop) (value.to_f - start.to_f) / (stop.to_f - start.to_f) end |
#noStroke ⇒ nil
Disables drawing stroke.
1045 1046 1047 1048 |
# File 'lib/processing/graphics_context.rb', line 1045 def noStroke() @painter__.stroke nil nil end |
#noTint ⇒ nil
Resets tint color.
1173 1174 1175 |
# File 'lib/processing/graphics_context.rb', line 1173 def noTint() @tint__ = nil end |
#pixelDensity ⇒ Numeric
Returns the pixel density of the graphics object.
617 618 619 |
# File 'lib/processing/graphics_context.rb', line 617 def pixelDensity() @painter__.pixel_density end |
#pixelHeight ⇒ Numeric
Returns the height of the graphics object in pixels.
606 607 608 |
# File 'lib/processing/graphics_context.rb', line 606 def pixelHeight() height * pixelDensity end |
#pixels ⇒ Array
An array of all pixels. Call loadPixels() before accessing the array.
2068 2069 2070 |
# File 'lib/processing/graphics_context.rb', line 2068 def pixels() @pixels__ end |
#pixelWidth ⇒ Numeric
Returns the width of the graphics object in pixels.
596 597 598 |
# File 'lib/processing/graphics_context.rb', line 596 def pixelWidth() width * pixelDensity end |
#point(x, y) ⇒ nil Also known as: drawPoint
Draws a point.
1474 1475 1476 1477 1478 |
# File 'lib/processing/graphics_context.rb', line 1474 def point(x, y) assertDrawing__ @painter__.point x, y nil end |
#pop ⇒ nil
Restore styles and transformations from stack.
2445 2446 2447 2448 |
# File 'lib/processing/graphics_context.rb', line 2445 def pop() popMatrix popStyle end |
#popMatrix ⇒ nil
Pops the current transformation matrix from stack.
2246 2247 2248 2249 2250 2251 |
# File 'lib/processing/graphics_context.rb', line 2246 def popMatrix() assertDrawing__ raise "matrix stack underflow" if @matrixStack__.empty? @painter__.matrix = @matrixStack__.pop nil end |
#popStyle ⇒ nil
Restore style values from the style stack.
2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 |
# File 'lib/processing/graphics_context.rb', line 2382 def popStyle() assertDrawing__ raise "style stack underflow" if @styleStack__.empty? @painter__.fill, @painter__.stroke, @painter__.stroke_width, @painter__.stroke_cap, @painter__.stroke_join, @painter__.miter_limit, @painter__.line_height, @painter__.clip, @painter__.blend_mode, @painter__.font, @painter__.texture, @painter__.texcoord_mode, @painter__.texcoord_wrap, @painter__.shader, @colorMode__, @hsbColor__, @colorMaxes__, @angleMode__, @toRad__, @toDeg__, @fromRad__, @fromDeg__, @rectMode__, @ellipseMode__, @imageMode__, @shapeMode__, @blendMode__, @curveDetail__, @curveTightness__, @bezierDetail__, @textAlignH__, @textAlignV__, @textFont__, @tint__ = @styleStack__.pop @textFont__.setSize__ @painter__.font.size nil end |
#pow(value, exponent) ⇒ Numeric
Returns value raised to the power of exponent.
2565 2566 2567 |
# File 'lib/processing/graphics_context.rb', line 2565 def pow(value, exponent) value ** exponent end |
#printMatrix ⇒ nil
Prints matrix elements to console.
2320 2321 2322 2323 2324 2325 |
# File 'lib/processing/graphics_context.rb', line 2320 def printMatrix() m = @painter__.matrix m.transpose! if @p5jsMode__ print "%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n" % m.to_a nil end |
#push(&block) ⇒ Object
Save current styles and transformations to stack.
2430 2431 2432 2433 2434 2435 2436 |
# File 'lib/processing/graphics_context.rb', line 2430 def push(&block) pushMatrix pushStyle block.call if block ensure pop if block end |
#pushMatrix(&block) ⇒ Object
Pushes the current transformation matrix to stack.
2232 2233 2234 2235 2236 2237 2238 |
# File 'lib/processing/graphics_context.rb', line 2232 def pushMatrix(&block) assertDrawing__ @matrixStack__.push @painter__.matrix block.call if block ensure popMatrix if block end |
#pushStyle(&block) ⇒ Object
Save current style values to the style stack.
2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 |
# File 'lib/processing/graphics_context.rb', line 2333 def pushStyle(&block) assertDrawing__ @styleStack__.push [ @painter__.fill, @painter__.stroke, @painter__.stroke_width, @painter__.stroke_cap, @painter__.stroke_join, @painter__.miter_limit, @painter__.line_height!, @painter__.clip, @painter__.blend_mode, @painter__.font, @painter__.texture, @painter__.texcoord_mode, @painter__.texcoord_wrap, @painter__.shader, @colorMode__, @hsbColor__, @colorMaxes__, @angleMode__, @toRad__, @toDeg__, @fromRad__, @fromDeg__, @rectMode__, @ellipseMode__, @imageMode__, @shapeMode__, @blendMode__, @curveDetail__, @curveTightness__, @bezierDetail__, @textAlignH__, @textAlignV__, @textFont__, @tint__, ] block.call if block ensure popStyle if block end |
#quad(x1, y1, x2, y2, x3, y3, x4, y4) ⇒ nil Also known as: drawQuad
Draws a quad.
1660 1661 1662 1663 1664 |
# File 'lib/processing/graphics_context.rb', line 1660 def quad(x1, y1, x2, y2, x3, y3, x4, y4) assertDrawing__ @painter__.line x1, y1, x2, y2, x3, y3, x4, y4, loop: true nil end |
#quadraticVertex(cx, cy, x3, y3) ⇒ nil
Append quadratic vertex for shape polygon.
1972 1973 1974 1975 |
# File 'lib/processing/graphics_context.rb', line 1972 def quadraticVertex(cx, cy, x3, y3) (@drawingShape__ or raise "quadraticVertex() must be called after beginShape()") .quadraticVertex cx, cy, x3, y3 end |
#radians(degree) ⇒ Numeric
Converts degree to radian.
2779 2780 2781 |
# File 'lib/processing/graphics_context.rb', line 2779 def radians(degree) degree * DEG2RAD__ end |
#random(high) ⇒ Float #random(low, high) ⇒ Float #random(choices) ⇒ Float
Returns a random number in range low…high
3051 3052 3053 3054 3055 3056 3057 3058 3059 |
# File 'lib/processing/graphics_context.rb', line 3051 def random(*args) if args.first.kind_of? Array a = args.first a.empty? ? nil : a[@random__.rand a.size] else high, low = args.reverse @random__.rand (low || 0).to_f...(high || 1).to_f end end |
#randomGaussian(mean = 0, sd = 1) ⇒ Float
Returns a random number fitting a Gaussian, or normal, distribution.
3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 |
# File 'lib/processing/graphics_context.rb', line 3085 def randomGaussian(mean = 0, sd = 1) value = if @nextGaussian__ x, @nextGaussian__ = @nextGaussian__, nil x else a, b, w = 0, 0, 1 until w < 1 a = random(2) - 1 b = random(2) - 1 w = a ** 2 + b ** 2 end w = Math.sqrt(-2 * Math.log(w) / w) @randomGaussian__ = a * w b * w end value * sd + mean end |
#randomSeed(seed) ⇒ nil
Sets the seed value for random()
3070 3071 3072 3073 |
# File 'lib/processing/graphics_context.rb', line 3070 def randomSeed(seed) @random__ = Random.new seed @nextGaussian__ = nil end |
#rect(a, b, c, d) ⇒ nil #rect(a, b, c, d, r) ⇒ nil #rect(a, b, c, d, tl, tr, br, bl) ⇒ nil Also known as: drawRect
Draws a rectangle.
The parameters a, b, c, and d are determined by rectMode().
1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 |
# File 'lib/processing/graphics_context.rb', line 1525 def rect(a, b, c, d, *args) assertDrawing__ x, y, w, h = toXYWH__ @rectMode__, a, b, c, d case args.size when 0 then @painter__.rect x, y, w, h when 1 then @painter__.rect x, y, w, h, round: args[0] when 4 then @painter__.rect x, y, w, h, lt: args[0], rt: args[1], rb: args[2], lb: args[3] else raise ArgumentError # ToDo: refine error message end nil end |
#rectMode(mode) ⇒ nil
Sets rect mode. Default is CORNER.
CORNER -> rect(left, top, width, height) CORNERS -> rect(left, top, right, bottom) CENTER -> rect(centerX, centerY, width, height) RADIUS -> rect(centerX, centerY, radiusH, radiusV)
891 892 893 |
# File 'lib/processing/graphics_context.rb', line 891 def rectMode(mode) @rectMode__ = mode end |
#red(color) ⇒ Numeric
Returns the red value of the color.
712 713 714 |
# File 'lib/processing/graphics_context.rb', line 712 def red(color) ((color >> 16) & 0xff) / 255.0 * @colorMaxes__[0] end |
#renderMode(mode = nil) ⇒ PROCESSING, P5JS
Sets render mode.
627 628 629 630 631 632 633 |
# File 'lib/processing/graphics_context.rb', line 627 def renderMode(mode = nil) if mode @renderMode__ = mode @p5jsMode__ = mode == P5JS end @renderMode__ end |
#requestImage(filename, extension = nil) ⇒ Image
Loads image on a new thread. When the image is loading, its width and height will be 0. If an error occurs while loading the image, its width and height wil be -1.
3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 |
# File 'lib/processing/graphics_context.rb', line 3330 def requestImage(filename, extension = nil) img = Image.new nil Thread.new filename, extension do |fn, ext| loaded = loadImage(fn, ext) or raise img.setInternal__ loaded.getInternal__ rescue img.setInternal__ nil, true end img end |
#resetMatrix ⇒ nil
Reset current transformation matrix with identity matrix.
2308 2309 2310 2311 2312 |
# File 'lib/processing/graphics_context.rb', line 2308 def resetMatrix() assertDrawing__ @painter__.matrix = 1 nil end |
#resetShader ⇒ nil
Resets shader.
1399 1400 1401 1402 |
# File 'lib/processing/graphics_context.rb', line 1399 def resetShader() @painter__.no_shader nil end |
#rotate(angle) ⇒ nil
Applies rotation matrix to current transformation matrix.
2137 2138 2139 2140 2141 |
# File 'lib/processing/graphics_context.rb', line 2137 def rotate(angle) assertDrawing__ @painter__.rotate toDegrees__ angle nil end |
#rotateX(angle) ⇒ nil
Applies rotation around the x-axis.
2152 2153 2154 2155 2156 |
# File 'lib/processing/graphics_context.rb', line 2152 def rotateX(angle) assertDrawing__ @painter__.rotate toDegrees__(angle), 1, 0, 0 nil end |
#rotateY(angle) ⇒ nil
Applies rotation around the y-axis.
2167 2168 2169 2170 2171 |
# File 'lib/processing/graphics_context.rb', line 2167 def rotateY(angle) assertDrawing__ @painter__.rotate toDegrees__(angle), 0, 1, 0 nil end |
#rotateZ(angle) ⇒ nil
Applies rotation around the z-axis.
2182 2183 2184 2185 2186 |
# File 'lib/processing/graphics_context.rb', line 2182 def rotateZ(angle) assertDrawing__ @painter__.rotate toDegrees__(angle), 0, 0, 1 nil end |
#round(value) ⇒ Numeric
Returns the closest integer number.
2525 2526 2527 |
# File 'lib/processing/graphics_context.rb', line 2525 def round(value) value.round end |
#saturation(color) ⇒ Numeric
Returns the saturation value of the color.
778 779 780 781 |
# File 'lib/processing/graphics_context.rb', line 778 def saturation(color) _, s, = color2raw__(color).to_hsv s * (@hsbColor__ ? @colorMaxes__[1] : 1) end |
#save(filename) ⇒ nil
Saves screen image to file.
2081 2082 2083 2084 |
# File 'lib/processing/graphics_context.rb', line 2081 def save(filename) getInternal__.save filename nil end |
#scale(s) ⇒ nil #scale(x, y) ⇒ nil #scale(x, y, z) ⇒ nil
Applies scale matrix to current transformation matrix.
2122 2123 2124 2125 2126 |
# File 'lib/processing/graphics_context.rb', line 2122 def scale(x, y = nil, z = 1) assertDrawing__ @painter__.scale x, (y || x), z nil end |
#shader(shader) ⇒ nil
Sets shader.
1387 1388 1389 1390 |
# File 'lib/processing/graphics_context.rb', line 1387 def shader(shader) @painter__.shader shader&.getInternal__ nil end |
#shape(img, a, b) ⇒ nil #shape(img, a, b, c, d) ⇒ nil Also known as: drawShape
Draws a shape.
The parameters a, b, c, and d are determined by shapeMode().
1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 |
# File 'lib/processing/graphics_context.rb', line 1808 def shape(shp, a = 0, b = 0, c = nil, d = nil) assertDrawing__ return nil unless shp.isVisible drawWithTexture__ do |_| if c || d || @shapeMode__ != CORNER x, y, w, h = toXYWH__ @shapeMode__, a, b, c || shp.width, d || shp.height shp.draw__ @painter__, x, y, w, h else shp.draw__ @painter__, a, b end end nil end |
#shapeMode(mode) ⇒ nil
Sets shape mode. Default is CORNER.
CORNER -> shape(shp, left, top, width, height) CORNERS -> shape(shp, left, top, right, bottom) CENTER -> shape(shp, centerX, centerY, width, height)
942 943 944 |
# File 'lib/processing/graphics_context.rb', line 942 def shapeMode(mode) @shapeMode__ = mode end |
#shearX(angle) ⇒ nil
Applies shear around the x-axis.
2197 2198 2199 2200 2201 2202 2203 2204 2205 |
# File 'lib/processing/graphics_context.rb', line 2197 def shearX(angle) t = Math.tan toRadians__(angle) @painter__.matrix *= Rays::Matrix.new( 1, t, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) nil end |
#shearY(angle) ⇒ nil
Applies shear around the y-axis.
2216 2217 2218 2219 2220 2221 2222 2223 2224 |
# File 'lib/processing/graphics_context.rb', line 2216 def shearY(angle) t = Math.tan toRadians__(angle) @painter__.matrix *= Rays::Matrix.new( 1, 0, 0, 0, t, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) nil end |
#sin(angle) ⇒ Numeric
Returns the sine of an angle.
2805 2806 2807 |
# File 'lib/processing/graphics_context.rb', line 2805 def sin(angle) Math.sin angle end |
#sq(value) ⇒ Numeric
Returns squared value.
2578 2579 2580 |
# File 'lib/processing/graphics_context.rb', line 2578 def sq(value) value * value end |
#sqrt(value) ⇒ Numeric
Returns squared value.
2591 2592 2593 |
# File 'lib/processing/graphics_context.rb', line 2591 def sqrt(value) Math.sqrt value end |
#square(x, y, extent) ⇒ nil Also known as: drawSquare
Draws a square.
1616 1617 1618 |
# File 'lib/processing/graphics_context.rb', line 1616 def square(x, y, extent) rect x, y, extent, extent end |
#stroke(rgb) ⇒ nil #stroke(rgb, alpha) ⇒ nil #stroke(gray) ⇒ nil #stroke(gray, alpha) ⇒ nil #stroke(r, g, b) ⇒ nil #stroke(r, g, b, alpha) ⇒ nil
Sets stroke color.
1033 1034 1035 1036 |
# File 'lib/processing/graphics_context.rb', line 1033 def stroke(*args) @painter__.stroke(*toRGBA__(*args)) nil end |
#strokeCap(cap) ⇒ nil
Sets stroke cap mode. The default cap if ROUND.
1074 1075 1076 1077 |
# File 'lib/processing/graphics_context.rb', line 1074 def strokeCap(cap) @painter__.stroke_cap cap nil end |
#strokeJoin(join) ⇒ nil
Sets stroke join mode. The default join is MITER.
1089 1090 1091 1092 |
# File 'lib/processing/graphics_context.rb', line 1089 def strokeJoin(join) @painter__.stroke_join join nil end |
#strokeWeight(weight) ⇒ nil
Sets stroke weight.
1059 1060 1061 1062 |
# File 'lib/processing/graphics_context.rb', line 1059 def strokeWeight(weight) @painter__.stroke_width weight nil end |
#tan(angle) ⇒ Numeric
Returns the ratio of the sine and cosine of an angle.
2831 2832 2833 |
# File 'lib/processing/graphics_context.rb', line 2831 def tan(angle) Math.tan angle end |
#text(str) ⇒ nil #text(str, x, y) ⇒ nil #text(str, a, b, c, d) ⇒ nil Also known as: drawText
Draws a text.
The parameters a, b, c, and d are determined by rectMode().
1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 |
# File 'lib/processing/graphics_context.rb', line 1741 def text(str, x, y, x2 = nil, y2 = nil) assertDrawing__ if x2 raise ArgumentError, "missing y2 parameter" unless y2 x, y, w, h = toXYWH__ @rectMode__, x, y, x2, y2 case @textAlignH__ when RIGHT then x += w - @painter__.font.width(str) when CENTER then x += (w - @painter__.font.width(str)) / 2 end case @textAlignV__ when BOTTOM then y += h - @painter__.font.height when CENTER then y += (h - @painter__.font.height) / 2 else end else y -= @painter__.font.ascent end @painter__.text str, x, y nil end |
#textAlign(horizontal, vertical = BASELINE) ⇒ nil
Sets the alignment for drawing text.
1304 1305 1306 1307 1308 |
# File 'lib/processing/graphics_context.rb', line 1304 def textAlign(horizontal, vertical = BASELINE) @textAlignH__ = horizontal @textAlignV__ = vertical nil end |
#textAscent ⇒ Numeric
Returns ascent of the current font at its current size.
1279 1280 1281 |
# File 'lib/processing/graphics_context.rb', line 1279 def textAscent() @painter__.font.ascent end |
#textDescent ⇒ Numeric
Returns descent of the current font at its current size.
1290 1291 1292 |
# File 'lib/processing/graphics_context.rb', line 1290 def textDescent() @painter__.font.descent end |
#textFont ⇒ Font #textFont(font) ⇒ Font #textFont(name) ⇒ Font #textFont(font, size) ⇒ Font #textFont(name, size) ⇒ Font
Sets text font. (Passing a font name as the first parameter is deprecated)
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 |
# File 'lib/processing/graphics_context.rb', line 1231 def textFont(font = nil, size = nil) if font != nil || size != nil size = FONT_SIZE_MAX__ if size && size > FONT_SIZE_MAX__ if font.nil? || font.kind_of?(String) font = createFont font, size elsif size font.setSize__ size end @painter__.font = font.getInternal__ @textFont__ = font end @textFont__ end |
#textLeading ⇒ Numeric #textLeading(leading) ⇒ Numeric
Sets the spacing between lines of text in units of pixels.
1322 1323 1324 1325 |
# File 'lib/processing/graphics_context.rb', line 1322 def textLeading(leading = nil) @painter__.line_height = leading if leading @painter__.line_height end |
#textSize(size) ⇒ nil
Sets text size.
1254 1255 1256 1257 |
# File 'lib/processing/graphics_context.rb', line 1254 def textSize(size) textFont @textFont__, size nil end |
#texture(image) ⇒ nil
Sets texture.
1336 1337 1338 1339 |
# File 'lib/processing/graphics_context.rb', line 1336 def texture(image) @painter__.texture image&.getInternal__ nil end |
#textureMode(mode) ⇒ nil
Sets the coordinate space for texture mapping.
1359 1360 1361 1362 |
# File 'lib/processing/graphics_context.rb', line 1359 def textureMode(mode) @painter__.texcoord_mode = mode nil end |
#textureWrap(wrap) ⇒ nil
Sets the texture wrapping mode.
1373 1374 1375 1376 |
# File 'lib/processing/graphics_context.rb', line 1373 def textureWrap(wrap) @painter__.texcoord_wrap = wrap nil end |
#textWidth(str) ⇒ Numeric
Returns the width of the text.
1268 1269 1270 |
# File 'lib/processing/graphics_context.rb', line 1268 def textWidth(str) @painter__.font.width str end |
#tint(rgb) ⇒ nil #tint(rgb, alpha) ⇒ nil #tint(gray) ⇒ nil #tint(gray, alpha) ⇒ nil #tint(r, g, b) ⇒ nil #tint(r, g, b, alpha) ⇒ nil
Sets fill color for drawing images.
1161 1162 1163 1164 |
# File 'lib/processing/graphics_context.rb', line 1161 def tint(*args) @tint__ = args nil end |
#translate(x, y) ⇒ nil #translate(x, y, z) ⇒ nil
Applies translation matrix to current transformation matrix.
2100 2101 2102 2103 2104 |
# File 'lib/processing/graphics_context.rb', line 2100 def translate(x, y, z = 0) assertDrawing__ @painter__.translate x, y, z nil end |
#triangle(x1, y1, x2, y2, x3, y3) ⇒ nil Also known as: drawTriangle
Draws a triangle.
1636 1637 1638 1639 1640 |
# File 'lib/processing/graphics_context.rb', line 1636 def triangle(x1, y1, x2, y2, x3, y3) assertDrawing__ @painter__.line x1, y1, x2, y2, x3, y3, loop: true nil end |
#updatePixels(&block) ⇒ nil
Update the image pixels with the ‘pixels’ array.
2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 |
# File 'lib/processing/graphics_context.rb', line 2047 def updatePixels(&block) return if !block && !@pixels__ if block loadPixels block.call pixels end getInternal__.tap do |img| img.pixels = @pixels__ img.paint {} # update texture and set modifiied end @pixels__ = nil end |
#vertex(x, y) ⇒ nil #vertex(x, y, u, v) ⇒ nil
Append vertex for shape polygon.
1927 1928 1929 1930 |
# File 'lib/processing/graphics_context.rb', line 1927 def vertex(x, y, u = nil, v = nil) (@drawingShape__ or raise "vertex() must be called after beginShape()") .vertex x, y, u, v end |
#width ⇒ Numeric
Returns the width of the graphics object.
575 576 577 |
# File 'lib/processing/graphics_context.rb', line 575 def width() getInternal__.width end |