Extra "ports" of juce-based plugins using the distrho build system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

777 lines
22KB

  1. --- Graphics drawing target.
  2. -- Is a pointer to a [JUCE Graphics](http://www.juce.com/api/classGraphics.html) object.
  3. -- Received in @{gui.paint} as an argument.
  4. -- @classmod juce.Graphics
  5. local script = require "include/core/script"
  6. local util = require"include/luautil"
  7. util.requireCdef(script.protoplugDir.."/include/protojuce/cdef/graphics.h")
  8. local Justification = require"include/protojuce/justification"
  9. local RectanglePlacement = require"include/protojuce/rectangleplacement"
  10. local AffineTransform = require"include/protojuce/affinetransform"
  11. local Path = require"include/protojuce/path"
  12. local Graphics = setmetatable({}, {
  13. --- Constuct from a @{juce.Image}.
  14. -- Use this constructor to draw directly onto an @{juce.Image} in memory.
  15. --
  16. -- A typical use is to can create a @{juce.Image} object and use it as a
  17. -- backbuffer for pre-rendering graphics.
  18. -- @tparam juce.Image imageToDrawOnto
  19. -- @within Constructors
  20. -- @constructor
  21. -- @function Graphics
  22. __call = function (self, imageToDrawOnto)
  23. return ffi.gc(
  24. protolib.Graphics_new(imageToDrawOnto),
  25. protolib.Graphics_delete)
  26. end
  27. })
  28. local Graphics_mt = {
  29. -- methods
  30. __index = {
  31. --- Set working colour.
  32. -- Set the colour to be used for subsequent calls such as @{drawRect} and @{drawText}.
  33. -- @tparam juce.Colour newColour
  34. -- @function setColour
  35. setColour = function (self, newColour)
  36. protolib.Graphics_setColour(self, newColour)
  37. end;
  38. --- Set working opacity.
  39. -- Set the opacity to be used for subsequent calls.
  40. -- @param newOpacity
  41. -- @function setOpacity
  42. setOpacity = function (self, newOpacity)
  43. protolib.Graphics_setOpacity(self, newOpacity)
  44. end;
  45. --- Set working Gradient.
  46. -- Use a gradient as fill for subsequent calls such as @{fillRect}.
  47. -- @tparam juce.ColourGradient gradient
  48. -- @function setGradientFill
  49. setGradientFill = function (self, gradient)
  50. protolib.Graphics_setGradientFill(self, gradient)
  51. end;
  52. --- Set Tiled Image Fill.
  53. -- Use a tiled image as fill for subsequent calls such as @{fillRect}.
  54. -- @tparam juce.Image imageToUse
  55. -- @param anchorX
  56. -- @param anchorY
  57. -- @param opacity
  58. -- @function setTiledImageFill
  59. setTiledImageFill = function (self, imageToUse,
  60. anchorX, anchorY,
  61. opacity)
  62. protolib.Graphics_setTiledImageFill(self, imageToUse,
  63. anchorX, anchorY,
  64. opacity)
  65. end;
  66. --- Set Fill.
  67. -- @tparam juce.FillType newFill
  68. -- @function setFillType
  69. setFillType = function (self, newFill)
  70. protolib.Graphics_setFillType(self, newFill)
  71. end;
  72. --- Set Font.
  73. -- @tparam juce.Font newFont
  74. -- @function setFont
  75. --- Set Font.
  76. -- @tparam number newFontHeight
  77. -- @function setFont
  78. setFont = function (self, newFont)
  79. if type(newFont) == "number" then -- height
  80. protolib.Graphics_setFont2(self, newFont)
  81. else
  82. protolib.Graphics_setFont(self, newFont)
  83. end
  84. end;
  85. --- Get Current Font.
  86. -- treturn juce.Font the current font
  87. -- @function getCurrentFont
  88. getCurrentFont = function (self)
  89. local f = protolib.Graphics_getCurrentFont(self)
  90. f = ffi.gc(f, protolib.Font_delete)
  91. return f
  92. end;
  93. --- Draw single line of text.
  94. -- @tparam string text
  95. -- @param startX
  96. -- @param baselineY
  97. -- @tparam[opt=Justification.left] juce.Justification justification
  98. -- @function drawSingleLineText
  99. drawSingleLineText = function (self, text,
  100. startX, baselineY,
  101. justification)
  102. justification = justification or Justification.left
  103. protolib.Graphics_drawSingleLineText(self, text,
  104. startX, baselineY,
  105. justification)
  106. end;
  107. --- Draw multiline text.
  108. -- @tparam string text
  109. -- @param startX
  110. -- @param baselineY
  111. -- @param maximumLineWidth
  112. -- @function drawMultiLineText
  113. drawMultiLineText = function (self, text,
  114. startX, baselineY,
  115. maximumLineWidth)
  116. protolib.Graphics_drawMultiLineText(self, text,
  117. startX, baselineY,
  118. maximumLineWidth)
  119. end;
  120. --- Draw text.
  121. -- @param x
  122. -- @param y
  123. -- @param width
  124. -- @param height
  125. -- @tparam[opt=Justification.left] juce.Justification justification
  126. -- @param[opt=false] useEllipsesIfTooBig
  127. -- @function drawText
  128. --- Draw text.
  129. -- @tparam juce.Rectangle_int area
  130. -- @tparam[opt=Justification.left] juce.Justification justification
  131. -- @param[opt=false] useEllipsesIfTooBig
  132. -- @function drawText
  133. drawText = function (self, text, ...)
  134. if select('#',...) >= 4 then
  135. local x, y, width, height, justificationType, useEllipsesIfTooBig = ...
  136. justificationType = justificationType or Justification.left
  137. useEllipsesIfTooBig = useEllipsesIfTooBig or false
  138. protolib.Graphics_drawText(self, text,
  139. x, y, width, height,
  140. justificationType,
  141. useEllipsesIfTooBig)
  142. else -- Rectangle_int
  143. local area, justificationType, useEllipsesIfTooBig = ...
  144. justificationType = justificationType or Justification.left
  145. useEllipsesIfTooBig = useEllipsesIfTooBig or false
  146. protolib.Graphics_drawText2(self, text,
  147. area,
  148. justificationType,
  149. useEllipsesIfTooBig)
  150. end
  151. end;
  152. --- Draw fitted text.
  153. -- Awkwardly squishes the font (up to minimumHorizontalScale) if necessary.
  154. -- @param x
  155. -- @param y
  156. -- @param width
  157. -- @param height
  158. -- @tparam juce.Justification justification
  159. -- @param maximumNumberOfLines
  160. -- @param[opt=0.7] minimumHorizontalScale
  161. -- @function drawFittedText
  162. --- Draw fitted text.
  163. -- Awkwardly squishes the font (up to minimumHorizontalScale) if necessary.
  164. -- @tparam juce.Rectangle_int area
  165. -- @tparam juce.Justification justification
  166. -- @param maximumNumberOfLines
  167. -- @param[opt=0.7] minimumHorizontalScale
  168. -- @function drawFittedText
  169. drawFittedText = function (self, text, ...)
  170. if select('#',...) >= 6 then
  171. local x, y, width, height, justificationFlags, maximumNumberOfLines, minimumHorizontalScale = ...
  172. minimumHorizontalScale = minimumHorizontalScale or 0.7
  173. protolib.Graphics_drawFittedText(self, text,
  174. x, y, width, height,
  175. justificationFlags,
  176. maximumNumberOfLines,
  177. minimumHorizontalScale)
  178. else
  179. local area, justificationFlags, maximumNumberOfLines, minimumHorizontalScale = ...
  180. minimumHorizontalScale = minimumHorizontalScale or 0.7
  181. protolib.Graphics_drawFittedText2(self, text,
  182. area,
  183. justificationFlags,
  184. maximumNumberOfLines,
  185. minimumHorizontalScale)
  186. end
  187. end;
  188. --- Fill the entire graphics target.
  189. -- @tparam[opt] juce.Colour colourToUse
  190. -- @function fillAll
  191. fillAll = function (self, colourToUse)
  192. if colourToUse then
  193. protolib.Graphics_fillAll2(self, colourToUse)
  194. else
  195. protolib.Graphics_fillAll(self)
  196. end
  197. end;
  198. --- Fill rectangle with current fill type.
  199. -- @param x
  200. -- @param y
  201. -- @param width
  202. -- @param height
  203. -- @function fillRect
  204. --- Fill rectangle with current fill type.
  205. -- @tparam juce.Rectangle_int area
  206. -- @function fillRect
  207. fillRect = function (self, ...)
  208. if select('#',...) == 4 then
  209. local x, y, width, height = ...
  210. protolib.Graphics_fillRect3(self, x, y, width, height)
  211. else
  212. local rectangle = ...
  213. if ffi.istype("Rectangle_int", rectangle) then
  214. protolib.Graphics_fillRect(self, rectangle)
  215. else
  216. protolib.Graphics_fillRect2(self, rectangle)
  217. end
  218. end
  219. end;
  220. fillRect_int = function (self, x, y, width, height)
  221. protolib.Graphics_fillRect3(self, x, y, width, height)
  222. end;
  223. --- Fill rectangle (sub-pixel accuracy).
  224. -- @param x
  225. -- @param y
  226. -- @param width
  227. -- @param height
  228. -- @function fillRect_float
  229. fillRect_float = function (self, x, y, width, height)
  230. protolib.Graphics_fillRect4(self, x, y, width, height)
  231. end;
  232. --- Fill rounded rectangle.
  233. -- @param x
  234. -- @param y
  235. -- @param width
  236. -- @param height
  237. -- @param cornerSize
  238. -- @function fillRoundedRectangle
  239. --- Fill rounded rectangle.
  240. -- @tparam juce.Rectangle_int area
  241. -- @param cornerSize
  242. -- @function fillRoundedRectangle
  243. fillRoundedRectangle = function (self, ...)
  244. if select('#',...) == 5 then
  245. local x, y, width, height, cornerSize = ...
  246. protolib.Graphics_fillRoundedRectangle(self, x, y, width, height,
  247. cornerSize)
  248. else
  249. local rectangle, cornerSize = ...
  250. protolib.Graphics_fillRoundedRectangle2(self, rectangle,
  251. cornerSize)
  252. end
  253. end;
  254. --- Fill *chequerboard*.
  255. -- (and i thought juce used British spelling)
  256. -- @tparam juce.Rectangle_int area
  257. -- @param checkWidth
  258. -- @param checkHeight
  259. -- @tparam juce.Colour colour1
  260. -- @tparam juce.Colour colour2
  261. -- @function fillCheckerBoard
  262. fillCheckerBoard = function (self, area,
  263. checkWidth, checkHeight,
  264. colour1, colour2)
  265. protolib.Graphics_fillCheckerBoard(self, area,
  266. checkWidth, checkHeight,
  267. colour1, colour2)
  268. end;
  269. --- Draw rectangle.
  270. -- @param x
  271. -- @param y
  272. -- @param width
  273. -- @param height
  274. -- @param[opt=1] lineThickness
  275. -- @function drawRect
  276. --- Draw rectangle.
  277. -- @tparam juce.Rectangle_int area
  278. -- @param[opt=1] lineThickness
  279. -- @function drawRect
  280. drawRect = function (self, ...)
  281. if select('#',...) >= 4 then
  282. local x, y, width, height, lineThickness = ...
  283. lineThickness = lineThickness or 1
  284. protolib.Graphics_drawRect(self, x, y, width, height, lineThickness)
  285. else
  286. local rectangle, lineThickness = ...
  287. lineThickness = lineThickness or 1
  288. protolib.Graphics_drawRect3(self, rectangle, lineThickness)
  289. end
  290. end;
  291. --- Draw rect (sub-pixel accuracy).
  292. -- @param x
  293. -- @param y
  294. -- @param width
  295. -- @param height
  296. -- @param[opt=1] lineThickness
  297. -- @function drawRect_float
  298. --- Draw rect (sub-pixel accuracy).
  299. -- @tparam juce.Rectangle_int area
  300. -- @param[opt=1] lineThickness
  301. -- @function drawRect_float
  302. drawRect_float = function (self, ...)
  303. if select('#',...) >= 4 then
  304. local x, y, width, height, lineThickness = ...
  305. lineThickness = lineThickness or 1
  306. protolib.Graphics_drawRect2(self, x, y, width, height, lineThickness)
  307. else
  308. local rectangle, lineThickness = ...
  309. lineThickness = lineThickness or 1
  310. protolib.Graphics_drawRect4(self, rectangle, lineThickness)
  311. end
  312. end;
  313. --- Draw rounded rectangle.
  314. -- @param x
  315. -- @param y
  316. -- @param width
  317. -- @param height
  318. -- @param cornerSize
  319. -- @param[opt=1] lineThickness
  320. -- @function drawRoundedRectangle
  321. --- Draw rounded rectangle.
  322. -- @tparam juce.Rectangle_int area
  323. -- @param cornerSize
  324. -- @param[opt=1] lineThickness
  325. -- @function drawRoundedRectangle
  326. drawRoundedRectangle = function (self, ...)
  327. if select('#',...) >= 5 then
  328. local x, y, width, height, cornerSize, lineThickness = ...
  329. lineThickness = lineThickness or 1
  330. protolib.Graphics_drawRoundedRectangle(self, x, y, width, height, cornerSize, lineThickness)
  331. else
  332. local rectangle, cornerSize, lineThickness = ...
  333. lineThickness = lineThickness or 1
  334. protolib.Graphics_drawRoundedRectangle2(self, rectangle, cornerSize, lineThickness)
  335. end
  336. end;
  337. --- Set pixel with current colour.
  338. -- @param x
  339. -- @param y
  340. -- @function setPixel
  341. setPixel = function (self, x, y)
  342. protolib.Graphics_setPixel(self, x, y)
  343. end;
  344. --- Fill ellipse with current fill.
  345. -- @param x
  346. -- @param y
  347. -- @param width
  348. -- @param height
  349. -- @function fillEllipse
  350. fillEllipse = function (self, ...)
  351. if select('#',...) == 4 then
  352. local x, y, width, height = ...
  353. protolib.Graphics_fillEllipse(self, x, y, width, height)
  354. else
  355. local area = ...
  356. protolib.Graphics_fillEllipse2(self, area)
  357. end
  358. end;
  359. --- Draw ellipse with current colour.
  360. -- @param x
  361. -- @param y
  362. -- @param width
  363. -- @param height
  364. -- @param[opt=1] lineThickness
  365. -- @function drawEllipse
  366. drawEllipse = function (self, x, y, width, height,
  367. lineThickness)
  368. lineThickness = lineThickness or 1
  369. protolib.Graphics_drawEllipse(self, x, y, width, height,
  370. lineThickness)
  371. end;
  372. --- Draw line.
  373. -- @param startX
  374. -- @param startY
  375. -- @param endX
  376. -- @param endY
  377. -- @param[opt=1] lineThickness
  378. -- @function drawLine
  379. --- Draw line.
  380. -- @tparam juce.Line line
  381. -- @param[opt=1] lineThickness
  382. -- @function drawLine
  383. drawLine = function (self, ...)
  384. if select('#',...) == 4 then
  385. local startX, startY, endX, endY = ...
  386. protolib.Graphics_drawLine(self, startX, startY, endX, endY)
  387. elseif select('#',...) == 5 then
  388. local startX, startY, endX, endY, lineThickness = ...
  389. protolib.Graphics_drawLine2(self, startX, startY, endX, endY, lineThickness)
  390. elseif select('#',...) == 1 then
  391. local line = ...
  392. protolib.Graphics_drawLine3(self, line)
  393. else
  394. local line, lineThickness = ...
  395. protolib.Graphics_drawLine4(self, line, lineThickness)
  396. end
  397. end;
  398. --- Draw dashed line.
  399. -- @tparam juce.Line line
  400. -- @param dashLengths (const float* ctype)
  401. -- @param numDashLengths
  402. -- @param[opt=1] lineThickness
  403. -- @param[opt=0] dashIndexToStartFrom
  404. -- @function drawDashedLine
  405. drawDashedLine = function (self, line,
  406. dashLengths, numDashLengths,
  407. lineThickness,
  408. dashIndexToStartFrom)
  409. lineThickness = lineThickness or 1
  410. dashIndexToStartFrom = dashIndexToStartFrom or 0
  411. protolib.Graphics_drawDashedLine(self, line,
  412. dashLengths, numDashLengths,
  413. lineThickness,
  414. dashIndexToStartFrom)
  415. end;
  416. --- Draw vertical line.
  417. -- @param x
  418. -- @param top
  419. -- @param bottom
  420. -- @function drawVerticalLine
  421. drawVerticalLine = function (self, x, top, bottom)
  422. protolib.Graphics_drawVerticalLine(self, x, top, bottom)
  423. end;
  424. --- Draw horizontal line.
  425. -- @param y
  426. -- @param left
  427. -- @param right
  428. -- @function drawHorizontalLine
  429. drawHorizontalLine = function (self, y, left, right)
  430. protolib.Graphics_drawHorizontalLine(self, y, left, right)
  431. end;
  432. --- Fill path.
  433. -- @tparam juce.Path path
  434. -- @tparam[opt=juce.AffineTransform.identity] juce.AffineTransform transform
  435. -- @function fillPath
  436. fillPath = function (self, path,
  437. transform)
  438. transform = transform or AffineTransform.identity
  439. protolib.Graphics_fillPath(self, path,
  440. transform)
  441. end;
  442. --- Stroke path.
  443. -- All named arguments are optional
  444. -- @tparam juce.Path path
  445. -- @param[opt] args
  446. -- @param args.thickness
  447. -- @tparam juce.Path.JointStyle args.jointStyle *default* : juce.Path.JointStyle.mitered
  448. -- @tparam juce.Path.EndCapStyle args.endCapStyle *default* : juce.Path.EndCapStyle.butt
  449. -- @tparam juce.AffineTransform args.transform *default* : juce.AffineTransform.identity
  450. -- @function strokePath
  451. strokePath = function (self, path, args)
  452. args = args or {}
  453. args.thickness = args.thickness or 1
  454. args.jointStyle = args.jointStyle or Path.JointStyle.mitered
  455. args.endCapStyle = args.endCapStyle or Path.EndCapStyle.butt
  456. args.transform = args.transform or AffineTransform.identity
  457. local strokeType = ffi.new("PathStrokeType", args.thickness, args.jointStyle, args.endCapStyle)
  458. protolib.Graphics_strokePath(self, path,
  459. strokeType,
  460. args.transform)
  461. end;
  462. --- Draw arrow.
  463. -- @tparam juce.Line line
  464. -- @param lineThickness
  465. -- @param arrowheadWidth
  466. -- @param arrowheadLength
  467. -- @function drawArrow
  468. drawArrow = function (self, line,
  469. lineThickness,
  470. arrowheadWidth,
  471. arrowheadLength)
  472. protolib.Graphics_drawArrow(self, line,
  473. lineThickness,
  474. arrowheadWidth,
  475. arrowheadLength)
  476. end;
  477. --- Set image resampling quality.
  478. -- @tparam juce.Graphics.ResamplingQuality newQuality
  479. -- @function setImageResamplingQuality
  480. setImageResamplingQuality = function (self, newQuality)
  481. protolib.Graphics_setImageResamplingQuality(self, newQuality)
  482. end;
  483. --- Draw unscaled image at location.
  484. -- @tparam juce.Image imageToDraw
  485. -- @param topLeftX
  486. -- @param topLeftY
  487. -- @param[opt=false] fillAlphaChannelWithCurrentBrush
  488. -- @function drawImageAt
  489. drawImageAt = function (self, imageToDraw, topLeftX, topLeftY,
  490. fillAlphaChannelWithCurrentBrush)
  491. fillAlphaChannelWithCurrentBrush = fillAlphaChannelWithCurrentBrush or false
  492. protolib.Graphics_drawImageAt(self, imageToDraw, topLeftX, topLeftY,
  493. fillAlphaChannelWithCurrentBrush)
  494. end;
  495. --- Draw a portion of an image, stretched into a target rectangle.
  496. -- @tparam juce.Image imageToDraw
  497. -- @param destX
  498. -- @param destY
  499. -- @param destWidth
  500. -- @param destHeight
  501. -- @param sourceX
  502. -- @param sourceY
  503. -- @param sourceWidth
  504. -- @param sourceHeight
  505. -- @param[opt=false] fillAlphaChannelWithCurrentBrush
  506. -- @function drawImage
  507. drawImage = function (self, imageToDraw,
  508. destX, destY, destWidth, destHeight,
  509. sourceX, sourceY, sourceWidth, sourceHeight,
  510. fillAlphaChannelWithCurrentBrush)
  511. fillAlphaChannelWithCurrentBrush = fillAlphaChannelWithCurrentBrush or false
  512. protolib.Graphics_drawImage(self, imageToDraw,
  513. destX, destY, destWidth, destHeight,
  514. sourceX, sourceY, sourceWidth, sourceHeight,
  515. fillAlphaChannelWithCurrentBrush)
  516. end;
  517. --- Draw transformed image.
  518. -- @tparam juce.Image imageToDraw
  519. -- @tparam juce.AffineTransform transform
  520. -- @param[opt=false] fillAlphaChannelWithCurrentBrush
  521. -- @function drawImageTransformed
  522. drawImageTransformed = function (self, imageToDraw,
  523. transform,
  524. fillAlphaChannelWithCurrentBrush)
  525. fillAlphaChannelWithCurrentBrush = fillAlphaChannelWithCurrentBrush or false
  526. protolib.Graphics_drawImageTransformed(self, imageToDraw,
  527. transform,
  528. fillAlphaChannelWithCurrentBrush)
  529. end;
  530. --- Draw image within.
  531. -- @tparam juce.Image imageToDraw
  532. -- @param destX
  533. -- @param destY
  534. -- @param destWidth
  535. -- @param destHeight
  536. -- @param[opt=juce.RectanglePlacement.centred] placementWithinTarget
  537. -- @param[opt=false] fillAlphaChannelWithCurrentBrush
  538. -- @function drawImageWithin
  539. drawImageWithin = function (self, imageToDraw,
  540. destX, destY, destWidth, destHeight,
  541. placementWithinTarget,
  542. fillAlphaChannelWithCurrentBrush)
  543. fillAlphaChannelWithCurrentBrush = fillAlphaChannelWithCurrentBrush or false
  544. placementWithinTarget = placementWithinTarget or RectanglePlacement.centred
  545. protolib.Graphics_drawImageWithin(self, imageToDraw,
  546. destX, destY, destWidth, destHeight,
  547. placementWithinTarget,
  548. fillAlphaChannelWithCurrentBrush)
  549. end;
  550. --- Get clip bounds.
  551. -- Get the portion of the graphics target that needs to be redrawn.
  552. -- @treturn juce.Rectangle_int Clipping area
  553. -- @function getClipBounds
  554. getClipBounds = function (self)
  555. return protolib.Graphics_getClipBounds(self)
  556. end;
  557. --- Clip region intersects.
  558. -- Check if a rectangle intersects with the redrawing region
  559. -- @treturn juce.Rectangle_int Clipping area
  560. -- @treturn boolean intersection check
  561. -- @function clipRegionIntersects
  562. clipRegionIntersects = function (self, area)
  563. return protolib.Graphics_clipRegionIntersects(self, area)
  564. end;
  565. reduceClipRegion = function (self, ...)
  566. local control = select(1, ...)
  567. if type(control)=="number" then
  568. local x, y, width, height = ...
  569. return protolib.Graphics_reduceClipRegion(self, x, y, width, height)
  570. elseif ffi.istype("Rectangle_int", control) then
  571. local area = ...
  572. return protolib.Graphics_reduceClipRegion2(self, area)
  573. elseif ffi.istype("pPath", control) then
  574. local path, transform = ...
  575. transform = transform or AffineTransform.identity
  576. return protolib.Graphics_reduceClipRegion4(self, path, transform)
  577. else -- pImage
  578. local image, transform = ...
  579. return protolib.Graphics_reduceClipRegion5(self, image, transform)
  580. end
  581. end;
  582. excludeClipRegion = function (self, rectangleToExclude)
  583. protolib.Graphics_excludeClipRegion(self, rectangleToExclude)
  584. end;
  585. --- Is clipping region empty.
  586. -- @treturn boolean whether the redrawing area is empty
  587. -- @function isClipEmpty
  588. isClipEmpty = function (self)
  589. return protolib.Graphics_isClipEmpty(self)
  590. end;
  591. --- Save state.
  592. -- Saves the current state of the graphics target on a stack.
  593. -- This does not save the actual graphic's contents but its current
  594. -- colour, transform, origin, etc.
  595. -- @function saveState
  596. saveState = function (self)
  597. protolib.Graphics_saveState(self)
  598. end;
  599. --- Restore state.
  600. -- Restores a state of the graphics target from the stack.
  601. -- Useful to cancel any previous uses
  602. -- of @{addTransform}, @{setColour}, etc.
  603. -- @function restoreState
  604. restoreState = function (self)
  605. protolib.Graphics_restoreState(self)
  606. end;
  607. --- Begin transparency layer.
  608. -- Saves the current state and begins drawing on a temporary layer,
  609. -- to be applied with the specified final transparency.
  610. -- @function beginTransparencyLayer
  611. beginTransparencyLayer = function (self, layerOpacity)
  612. protolib.Graphics_beginTransparencyLayer(self, layerOpacity)
  613. end;
  614. --- End transparency layer.
  615. -- Applies the transparency layer that was started with @{beginTransparencyLayer}.
  616. -- @function endTransparencyLayer
  617. endTransparencyLayer = function (self)
  618. protolib.Graphics_endTransparencyLayer(self)
  619. end;
  620. --no
  621. -- Set origin. tparam juce.Point newOrigin function setOrigin
  622. --- Set origin.
  623. -- @param newOriginX
  624. -- @param newOriginY
  625. -- @function setOrigin
  626. setOrigin = function (self, ...)
  627. if select("#", ...) == 1 then
  628. protolib.Graphics_setOrigin(self, ...)
  629. else
  630. protolib.Graphics_setOrigin2(self, ...)
  631. end
  632. end;
  633. --- Add a transformation matrix.
  634. -- The matrix will be chained onto the current one, and affect all
  635. -- subsequent graphics operations. Use @{saveState} and @{restoreState}
  636. -- to apply a temporary transform.
  637. -- @tparam juce.AffineTransform transform
  638. -- @function addTransform
  639. addTransform = function (self, transform)
  640. protolib.Graphics_addTransform(self, transform)
  641. end;
  642. --- Reset to default state.
  643. -- @function resetToDefaultState
  644. resetToDefaultState = function (self)
  645. protolib.Graphics_resetToDefaultState(self)
  646. end;
  647. --- Is vector device.
  648. -- @treturn boolean whether the target is a vector device.
  649. -- @function isVectorDevice
  650. isVectorDevice = function (self)
  651. return protolib.Graphics_isVectorDevice(self)
  652. end;
  653. }
  654. }
  655. --- Resampling qualities.
  656. -- @table juce.Graphics.ResamplingQuality
  657. Graphics.ResamplingQuality =
  658. {
  659. low = 0;
  660. medium = 1;
  661. high = 2
  662. };
  663. ffi.metatype("pGraphics", Graphics_mt);
  664. return Graphics