Final Fantasy is wierd in that it constantly turns on the backlight, despite it alrea...
[SquirrelJME.git] / modules / midp-lcdui / src / main / java / cc / squirreljme / runtime / lcdui / mle / PencilGraphics.java
blobba996695bd14d1ff7b0766ef44ded1aa205fd3a3
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc.squirreljme.runtime.lcdui.mle;
12 import cc.squirreljme.jvm.mle.PencilShelf;
13 import cc.squirreljme.jvm.mle.brackets.PencilBracket;
14 import cc.squirreljme.jvm.mle.constants.UIPixelFormat;
15 import cc.squirreljme.jvm.mle.exceptions.MLECallError;
16 import cc.squirreljme.jvm.mle.scritchui.brackets.ScritchPencilBracket;
17 import cc.squirreljme.runtime.cldc.annotation.SquirrelJMEVendorApi;
18 import cc.squirreljme.runtime.cldc.debug.Debugging;
19 import cc.squirreljme.runtime.lcdui.scritchui.DisplayManager;
20 import javax.microedition.lcdui.Font;
21 import javax.microedition.lcdui.Graphics;
22 import javax.microedition.lcdui.Image;
23 import javax.microedition.lcdui.Text;
24 import javax.microedition.lcdui.game.Sprite;
26 /**
27 * This delegates drawing operations to the hardware graphics layer.
29 * This utilizes both {@link PencilShelf} and {@link PencilBracket} for native
30 * graphics.
32 * @since 2020/09/25
34 @SquirrelJMEVendorApi
35 public final class PencilGraphics
36 extends Graphics
38 /** The hardware bracket reference. */
39 @SquirrelJMEVendorApi
40 protected final PencilBracket hardware;
42 /** Surface width. */
43 @SquirrelJMEVendorApi
44 protected final int surfaceW;
46 /** Surface height. */
47 @SquirrelJMEVendorApi
48 protected final int surfaceH;
50 /** Is there an alpha channel? */
51 @SquirrelJMEVendorApi
52 protected final boolean hasAlpha;
54 /** Single character. */
55 @SquirrelJMEVendorApi
56 private final char[] _singleChar =
57 new char[1];
59 /** The current alpha color. */
60 @SquirrelJMEVendorApi
61 private int _argbColor;
63 /** The current blending mode. */
64 @SquirrelJMEVendorApi
65 private int _blendingMode;
67 /** The clip height. */
68 @SquirrelJMEVendorApi
69 private int _clipHeight;
71 /** The clip width. */
72 @SquirrelJMEVendorApi
73 private int _clipWidth;
75 /** The clip X position. */
76 @SquirrelJMEVendorApi
77 private int _clipX;
79 /** The clip Y position. */
80 @SquirrelJMEVendorApi
81 private int _clipY;
83 /** The current font used. */
84 @SquirrelJMEVendorApi
85 private Font _font;
87 /** The current stroke style. */
88 @SquirrelJMEVendorApi
89 private int _strokeStyle;
91 /**
92 * Initializes the pencil graphics system.
94 * @param __sw The surface width.
95 * @param __sh The surface height.
96 * @param __hardware The hardware bracket reference for drawing.
97 * @throws IllegalArgumentException If hardware graphics are not capable
98 * enough to be used at all.
99 * @throws NullPointerException On null arguments.
100 * @since 2020/09/25
102 @SquirrelJMEVendorApi
103 private PencilGraphics(int __sw, int __sh, PencilBracket __hardware)
104 throws IllegalArgumentException, NullPointerException
106 if (__hardware == null)
107 throw new NullPointerException("NARG");
109 this.hardware = __hardware;
111 // These are used to manage the clip
112 this.surfaceW = __sw;
113 this.surfaceH = __sh;
115 // Determines which blending modes are valid
116 this.hasAlpha = PencilShelf.hardwareHasAlpha(__hardware);
118 // Set initial parameters for the graphics and make sure they are
119 // properly forwarded as well
120 this.setAlphaColor(0xFF000000);
121 this.setBlendingMode(Graphics.SRC_OVER);
122 this.setStrokeStyle(Graphics.SOLID);
123 this.setFont(null);
127 * {@inheritDoc}
128 * @since 2020/09/25
130 @Override
131 @SquirrelJMEVendorApi
132 public void clipRect(int __x, int __y, int __w, int __h)
134 throw Debugging.todo();
138 * {@inheritDoc}
139 * @since 2020/09/25
141 @Override
142 @SquirrelJMEVendorApi
143 public void copyArea(int __sx, int __sy, int __w, int __h, int __dx,
144 int __dy, int __anchor)
145 throws IllegalArgumentException, IllegalStateException
147 // Forward to native call
150 PencilShelf.hardwareCopyArea(this.hardware,
151 __sx, __sy, __w, __h, __dx, __dy, __anchor);
154 // Unwrap any potential errors.
155 catch (MLECallError e)
157 throw e.throwDistinct();
162 * {@inheritDoc}
163 * @since 2020/09/25
165 @Override
166 @SquirrelJMEVendorApi
167 public void drawArc(int __x, int __y, int __w, int __h, int __startAngle,
168 int __arcAngle)
170 throw Debugging.todo();
174 * {@inheritDoc}
175 * @since 2020/09/25
177 @Override
178 @SquirrelJMEVendorApi
179 public void drawARGB16(short[] __data, int __off, int __scanlen,
180 int __x, int __y, int __w, int __h)
181 throws NullPointerException
183 throw Debugging.todo();
187 * {@inheritDoc}
188 * @since 2020/09/25
190 @Override
191 @SquirrelJMEVendorApi
192 public void drawChar(char __s, int __x, int __y, int __anchor)
194 // Fill single character first
195 char[] singleChar = this._singleChar;
196 singleChar[0] = __s;
198 // Forward
201 PencilShelf.hardwareDrawChars(this.hardware,
202 singleChar, 0, 1, __x, __y, __anchor);
204 catch (MLECallError e)
206 throw e.throwDistinct();
211 * {@inheritDoc}
212 * @since 2020/09/25
214 @Override
215 @SquirrelJMEVendorApi
216 public void drawChars(char[] __s, int __o, int __l, int __x, int __y,
217 int __anchor)
218 throws IllegalArgumentException, IndexOutOfBoundsException,
219 NullPointerException
221 // Check
222 if (__s == null)
223 throw new NullPointerException("NARG");
224 if (__o < 0 || __l < 0 || (__o + __l) > __s.length)
225 throw new IndexOutOfBoundsException("IOOB");
227 // Forward
230 PencilShelf.hardwareDrawChars(this.hardware,
231 __s, __o, __l, __x, __y, __anchor);
233 catch (MLECallError e)
235 throw e.throwDistinct();
240 * {@inheritDoc}
241 * @since 2020/09/25
243 @Override
244 @SquirrelJMEVendorApi
245 public void drawImage(Image __i, int __x, int __y, int __anchor)
246 throws IllegalArgumentException, NullPointerException
248 // This is a duplicate function, so it gets forwarded
249 this.drawRegion(__i, 0, 0,
250 __i.getWidth(), __i.getHeight(), 0,
251 __x, __y, __anchor);
255 * {@inheritDoc}
256 * @since 2020/09/25
258 @Override
259 @SquirrelJMEVendorApi
260 public void drawLine(int __x1, int __y1, int __x2, int __y2)
262 PencilShelf.hardwareDrawLine(this.hardware, __x1, __y1, __x2, __y2);
266 * {@inheritDoc}
267 * @since 2020/09/25
269 @Override
270 @SquirrelJMEVendorApi
271 public void drawRGB(int[] __data, int __off, int __scanlen, int __x,
272 int __y, int __w, int __h, boolean __alpha)
273 throws NullPointerException
275 // Forward Call
276 this.__drawRegion(__data, __off, __scanlen, __alpha,
277 0, 0, __w, __h, Sprite.TRANS_NONE,
278 __x, __y, Graphics.TOP | Graphics.LEFT, __w, __h,
279 __scanlen, (__data.length - __off) / __scanlen);
283 * {@inheritDoc}
284 * @since 2020/09/25
286 @Override
287 @SquirrelJMEVendorApi
288 public void drawRGB16(short[] __data, int __off, int __scanlen,
289 int __x, int __y, int __w, int __h)
290 throws NullPointerException
292 throw Debugging.todo();
296 * {@inheritDoc}
297 * @since 2020/09/25
299 @Override
300 @SquirrelJMEVendorApi
301 public void drawRect(int __x, int __y, int __w, int __h)
303 // Forward to hardware
304 PencilShelf.hardwareDrawRect(this.hardware, __x, __y, __w, __h);
308 * {@inheritDoc}
309 * @since 2020/09/25
311 @Override
312 @SquirrelJMEVendorApi
313 public void drawRegion(Image __src, int __xsrc, int __ysrc,
314 int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
315 int __anch)
316 throws IllegalArgumentException, NullPointerException
318 // Forward call
319 this.drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc,
320 __trans, __xdest, __ydest, __anch, __wsrc, __hsrc);
324 * {@inheritDoc}
325 * @since 2020/09/25
327 @Override
328 @SquirrelJMEVendorApi
329 public void drawRegion(Image __src, int __xsrc, int __ysrc,
330 int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
331 int __anch, int __wdest, int __hdest)
332 throws IllegalArgumentException, NullPointerException
334 if (__src == null)
335 throw new NullPointerException("NARG");
337 // If the image is direct, use the buffer that is inside rather than
338 // a copy, so we do not waste time copying from it!
339 int[] buf;
340 int offset;
341 int scanLen;
342 if (__src.squirreljmeIsDirect())
344 buf = __src.squirreljmeDirectRGBInt();
345 offset = __src.squirreljmeDirectOffset();
346 scanLen = __src.squirreljmeDirectScanLen();
349 // Image is not directly accessible, so get a copy of it
350 else
352 // Obtain image properties
353 int iW = __src.getWidth();
354 int iH = __src.getHeight();
355 int totalPixels = iW * iH;
357 // Read RGB data
358 buf = new int[totalPixels];
359 offset = 0;
360 scanLen = iW;
361 __src.getRGB(buf, offset, scanLen, 0, 0, iW, iH);
364 // Perform the internal draw
365 this.__drawRegion(buf, offset, scanLen, __src.hasAlpha(),
366 __xsrc, __ysrc, __wsrc, __hsrc, __trans,
367 __xdest, __ydest, __anch,
368 __wdest, __hdest, __src.getWidth(), __src.getHeight());
372 * {@inheritDoc}
373 * @since 2020/09/25
375 @Override
376 @SquirrelJMEVendorApi
377 public void drawRoundRect(int __x, int __y, int __w, int __h,
378 int __arcWidth, int __arcHeight)
380 throw Debugging.todo();
384 * {@inheritDoc}
385 * @since 2020/09/25
387 @Override
388 @SquirrelJMEVendorApi
389 public void drawString(String __s, int __x, int __y, int __anchor)
390 throws NullPointerException
392 if (__s == null)
393 throw new NullPointerException("NARG");
395 // Forward
398 PencilShelf.hardwareDrawSubstring(this.hardware,
399 __s, 0, __s.length(), __x, __y, __anchor);
401 catch (MLECallError e)
403 throw e.throwDistinct();
408 * {@inheritDoc}
409 * @since 2020/09/25
411 @Override
412 @SquirrelJMEVendorApi
413 public void drawSubstring(String __s, int __o, int __l,
414 int __x, int __y, int __anchor)
415 throws NullPointerException, StringIndexOutOfBoundsException
417 if (__s == null)
418 throw new NullPointerException("NARG");
419 if (__o < 0 || __l < 0 || (__o + __l) > __s.length())
420 throw new StringIndexOutOfBoundsException("IOOB");
422 // Forward
425 PencilShelf.hardwareDrawSubstring(this.hardware,
426 __s, __o, __l, __x, __y, __anchor);
428 catch (MLECallError e)
430 throw e.throwDistinct();
435 * {@inheritDoc}
436 * @since 2020/09/25
438 @Override
439 @SquirrelJMEVendorApi
440 public void drawText(Text __t, int __x, int __y)
442 throw Debugging.todo();
446 * {@inheritDoc}
447 * @since 2020/09/25
449 @Override
450 @SquirrelJMEVendorApi
451 public void fillArc(int __x, int __y, int __w, int __h, int __startAngle,
452 int __arcAngle)
454 throw Debugging.todo();
458 * {@inheritDoc}
459 * @since 2020/09/25
461 @Override
462 @SquirrelJMEVendorApi
463 public void fillRect(int __x, int __y, int __w, int __h)
465 // Forward to hardware
466 PencilShelf.hardwareFillRect(this.hardware, __x, __y, __w, __h);
470 * {@inheritDoc}
471 * @since 2020/09/25
473 @Override
474 @SquirrelJMEVendorApi
475 public void fillRoundRect(int __x, int __y, int __w, int __h,
476 int __arcWidth, int __arcHeight)
478 throw Debugging.todo();
482 * {@inheritDoc}
483 * @since 2020/09/25
485 @Override
486 @SquirrelJMEVendorApi
487 public void fillTriangle(int __x1, int __y1, int __x2, int __y2,
488 int __x3, int __y3)
490 // Forward to hardware
491 PencilShelf.hardwareFillTriangle(this.hardware, __x1, __y1, __x2, __y2,
492 __x3, __y3);
496 * {@inheritDoc}
497 * @since 2020/09/25
499 @Override
500 @SquirrelJMEVendorApi
501 public int getAlpha()
503 return (this._argbColor >> 24) & 0xFF;
507 * {@inheritDoc}
508 * @since 2020/09/25
510 @Override
511 @SquirrelJMEVendorApi
512 public int getAlphaColor()
514 return this._argbColor;
518 * {@inheritDoc}
519 * @since 2020/09/25
521 @Override
522 @SquirrelJMEVendorApi
523 public int getBlendingMode()
525 return this._blendingMode;
529 * {@inheritDoc}
530 * @since 2020/09/25
532 @Override
533 @SquirrelJMEVendorApi
534 public int getBlueComponent()
536 return (this._argbColor) & 0xFF;
540 * {@inheritDoc}
541 * @since 2020/09/25
543 @Override
544 @SquirrelJMEVendorApi
545 public int getClipHeight()
547 return this._clipHeight;
551 * {@inheritDoc}
552 * @since 2020/09/25
554 @Override
555 @SquirrelJMEVendorApi
556 public int getClipWidth()
558 return this._clipWidth;
562 * {@inheritDoc}
563 * @since 2020/09/25
565 @Override
566 @SquirrelJMEVendorApi
567 public int getClipX()
569 return this._clipX - this.getTranslateX();
573 * {@inheritDoc}
574 * @since 2020/09/25
576 @Override
577 @SquirrelJMEVendorApi
578 public int getClipY()
580 return this._clipY - this.getTranslateY();
584 * {@inheritDoc}
585 * @since 2020/09/25
587 @Override
588 @SquirrelJMEVendorApi
589 public int getColor()
591 return this._argbColor & 0xFFFFFF;
595 * {@inheritDoc}
596 * @since 2020/09/25
598 @Override
599 @SquirrelJMEVendorApi
600 public int getDisplayColor(int __rgb)
602 throw Debugging.todo();
603 /*// We can just ask the software graphics for the color we are using
604 // since it should hopefully match the hardware one.
605 return this.software.getDisplayColor(__rgb);*/
609 * {@inheritDoc}
610 * @since 2020/09/25
612 @Override
613 @SquirrelJMEVendorApi
614 public Font getFont()
616 return this._font;
620 * {@inheritDoc}
621 * @since 2020/09/25
623 @Override
624 @SquirrelJMEVendorApi
625 public int getGrayScale()
627 return (((this._argbColor >> 16) & 0xFF) +
628 ((this._argbColor >> 8) & 0xFF) +
629 ((this._argbColor) & 0xFF)) / 3;
633 * {@inheritDoc}
634 * @since 2020/09/25
636 @Override
637 @SquirrelJMEVendorApi
638 public int getGreenComponent()
640 return (this._argbColor >> 8) & 0xFF;
644 * {@inheritDoc}
645 * @since 2020/09/25
647 @Override
648 @SquirrelJMEVendorApi
649 public int getRedComponent()
651 return (this._argbColor >> 16) & 0xFF;
655 * {@inheritDoc}
656 * @since 2020/09/25
658 @Override
659 @SquirrelJMEVendorApi
660 public int getStrokeStyle()
662 return this._strokeStyle;
666 * {@inheritDoc}
667 * @since 2020/09/25
669 @Override
670 @SquirrelJMEVendorApi
671 public int getTranslateX()
673 return PencilShelf.hardwareTranslateXY(this.hardware, false);
677 * {@inheritDoc}
678 * @since 2020/09/25
680 @Override
681 @SquirrelJMEVendorApi
682 public int getTranslateY()
684 return PencilShelf.hardwareTranslateXY(this.hardware, true);
688 * {@inheritDoc}
689 * @since 2020/09/25
691 @Override
692 @SquirrelJMEVendorApi
693 public void setAlpha(int __a)
694 throws IllegalArgumentException
696 this.setAlphaColor(__a,
697 this.getRedComponent(),
698 this.getGreenComponent(),
699 this.getBlueComponent());
703 * {@inheritDoc}
704 * @since 2020/09/25
706 @Override
707 @SquirrelJMEVendorApi
708 public void setAlphaColor(int __argb)
710 // Mirror locally
711 this._argbColor = __argb;
713 // Set on the hardware side
714 PencilShelf.hardwareSetAlphaColor(this.hardware, __argb);
718 * {@inheritDoc}
719 * @since 2020/09/25
721 @Override
722 @SquirrelJMEVendorApi
723 public void setAlphaColor(int __a, int __r, int __g, int __b)
724 throws IllegalArgumentException
726 /* {@squirreljme.error EB3t Color out of range. (Alpha; Red; Green;
727 Blue)} */
728 if (__a < 0 || __a > 255 || __r < 0 || __r > 255 ||
729 __g < 0 || __g > 255 || __b < 0 || __b > 255)
730 throw new IllegalArgumentException(String.format(
731 "EB3t %d %d %d %d", __a, __r, __g, __b));
733 // Set
734 this.setAlphaColor((__a << 24) | (__r << 16) | (__g << 8) | __b);
738 * {@inheritDoc}
739 * @since 2020/09/25
741 @Override
742 @SquirrelJMEVendorApi
743 public void setBlendingMode(int __m)
744 throws IllegalArgumentException
746 /* {@squirreljme.error EB3u Invalid blending mode. (The mode)} */
747 if ((__m != Graphics.SRC && __m != Graphics.SRC_OVER) ||
748 (__m == Graphics.SRC && !this.hasAlpha))
749 throw new IllegalArgumentException("EB3u " + __m);
751 // Cache locally
752 this._blendingMode = __m;
754 // Forward to both software and hardware graphics
755 PencilShelf.hardwareSetBlendingMode(this.hardware, __m);
759 * {@inheritDoc}
760 * @since 2020/09/25
762 @Override
763 @SquirrelJMEVendorApi
764 public void setClip(int __x, int __y, int __w, int __h)
766 // Calculate the base clip coordinates
767 int startX = __x + this.getTranslateX();
768 int startY = __y + this.getTranslateY();
769 int endX = startX + __w;
770 int endY = startY + __h;
772 // Normalize X
773 if (endX < startX)
775 int temp = endX;
776 endX = startX;
777 startX = temp;
780 // Normalize Y
781 if (endY < startY)
783 int temp = endY;
784 endY = startY;
785 startY = temp;
788 // Determine the bounds of all of these
789 int clipX = Math.min(this.surfaceW, Math.max(0, startX));
790 int clipY = Math.min(this.surfaceH, Math.max(0, startY));
791 int clipEndX = Math.min(this.surfaceW, Math.max(0, endX));
792 int clipEndY = Math.min(this.surfaceH, Math.max(0, endY));
794 // Record internally
795 this._clipX = clipX;
796 this._clipY = clipY;
797 this._clipWidth = clipEndX - clipX;
798 this._clipHeight = clipEndY - clipY;
800 // Forward to both software and hardware graphics
801 PencilShelf.hardwareSetClip(this.hardware, __x, __y, __w, __h);
805 * {@inheritDoc}
806 * @since 2020/09/25
808 @SuppressWarnings("MagicNumber")
809 @Override
810 @SquirrelJMEVendorApi
811 public void setColor(int __rgb)
813 this.setAlphaColor((this.getAlphaColor() & 0xFF_000000) |
814 (__rgb & 0x00_FFFFFF));
818 * {@inheritDoc}
819 * @since 2020/09/25
821 @Override
822 @SquirrelJMEVendorApi
823 public void setColor(int __r, int __g, int __b)
824 throws IllegalArgumentException
826 this.setAlphaColor(this.getAlpha(), __r, __g, __b);
830 * {@inheritDoc}
831 * @since 2020/09/25
833 @Override
834 @SquirrelJMEVendorApi
835 public void setFont(Font __font)
837 // Clearing the font?
838 if (__font == null)
839 __font = Font.getDefaultFont();
841 // Cache locally
842 this._font = __font;
844 // Set font natively from the font details
845 PencilShelf.hardwareSetFont(this.hardware,
846 ((PencilFontProvider)__font).__squirreljmePencilFont());
850 * {@inheritDoc}
851 * @since 2020/09/25
853 @Override
854 @SquirrelJMEVendorApi
855 public void setGrayScale(int __v)
857 this.setAlphaColor(this.getAlpha(), __v, __v, __v);
861 * {@inheritDoc}
862 * @since 2020/09/25
864 @Override
865 @SquirrelJMEVendorApi
866 public void setStrokeStyle(int __style)
867 throws IllegalArgumentException
869 /* {@squirreljme.error EB3v Illegal stroke style.} */
870 if (__style != Graphics.SOLID && __style != Graphics.DOTTED)
871 throw new IllegalArgumentException("EB3v");
873 // Set
874 this._strokeStyle = __style;
876 // Forward to both software and hardware graphics
877 PencilShelf.hardwareSetStrokeStyle(this.hardware, __style);
881 * {@inheritDoc}
882 * @since 2020/09/25
884 @Override
885 @SquirrelJMEVendorApi
886 public void translate(int __x, int __y)
888 PencilShelf.hardwareTranslate(this.hardware, __x, __y);
892 * Draws a direct RGB region of an image.
894 * @param __data The source buffer.
895 * @param __off The offset into the buffer.
896 * @param __scanlen The scanline length.
897 * @param __alpha Drawing with the alpha channel?
898 * @param __xsrc The source X position.
899 * @param __ysrc The source Y position.
900 * @param __wsrc The width of the source region.
901 * @param __hsrc The height of the source region.
902 * @param __trans Sprite translation and/or rotation, see {@link Sprite}.
903 * @param __xdest The destination X position, is translated.
904 * @param __ydest The destination Y position, is translated.
905 * @param __anch The anchor point.
906 * @param __wdest The destination width.
907 * @param __hdest The destination height.
908 * @param __origImgWidth Original image width.
909 * @param __origImgHeight Original image height.
910 * @throws NullPointerException On null arguments.
911 * @since 2022/01/26
913 @SquirrelJMEVendorApi
914 private void __drawRegion(int[] __data, int __off, int __scanlen,
915 boolean __alpha, int __xsrc, int __ysrc, int __wsrc, int __hsrc,
916 int __trans, int __xdest, int __ydest, int __anch, int __wdest,
917 int __hdest, int __origImgWidth, int __origImgHeight)
918 throws NullPointerException
920 if (__data == null)
921 throw new NullPointerException("NARG");
923 // Forward to the native region drawing method
924 PencilShelf.hardwareDrawXRGB32Region(this.hardware,
925 __data, __off, __scanlen,
926 __alpha, __xsrc, __ysrc, __wsrc, __hsrc,
927 __trans, __xdest, __ydest, __anch,
928 __wdest, __hdest, __origImgWidth, __origImgHeight);
932 * Creates a graphics that is capable of drawing on hardware if it is
933 * supported, but falling back to software level graphics.
935 * @param __pf The {@link UIPixelFormat} used for the draw.
936 * @param __bw The buffer width, this is the scanline width of the buffer.
937 * @param __bh The buffer height.
938 * @param __buf The target buffer to draw to, this is cast to the correct
939 * buffer format.
940 * @param __pal The color palette, may be {@code null}.
941 * @param __sx Starting surface X coordinate.
942 * @param __sy Starting surface Y coordinate.
943 * @param __sw Surface width.
944 * @param __sh Surface height.
945 * @throws NullPointerException On null arguments.
946 * @since 2020/09/25
948 @SquirrelJMEVendorApi
949 public static Graphics hardwareGraphics(int __pf, int __bw,
950 int __bh, Object __buf, int[] __pal, int __sx, int __sy,
951 int __sw, int __sh)
952 throws NullPointerException
954 return new PencilGraphics(__sw, __sh,
955 DisplayManager.instance().scritch().hardwareGraphics(
956 __pf, __bw, __bh, __buf, __pal, __sx, __sy, __sw, __sh));
960 * Initializes a new graphics interface.
962 * @param __hw The hardware graphics to use.
963 * @param __sw The surface width.
964 * @param __sh The surface height.
965 * @return The wrapped graphics.
966 * @throws NullPointerException On null arguments.
967 * @since 2024/05/12
969 @SquirrelJMEVendorApi
970 public static Graphics of(ScritchPencilBracket __hw, int __sw, int __sh)
971 throws NullPointerException
973 if (__hw == null)
974 throw new NullPointerException("NARG");
976 return new PencilGraphics(__sw, __sh, __hw);