MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / xs_poco_drawGray

Function xs_poco_drawGray

modules/commodetto/commodettoPocoCore.c:767–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

765}
766
767void xs_poco_drawGray(xsMachine *the)
768{
769 Poco poco = xsmcGetHostDataPoco(xsThis);
770 int argc = xsmcArgc;
771 PocoBitmapRecord bits;
772 PocoCoordinate x, y;
773 PocoDimension sx, sy, sw, sh;
774 PocoColor color = 0;
775 CommodettoBitmap cb;
776 uint8_t blend = kPocoOpaque;
777
778 cb = xsmcGetHostChunk(xsArg(0));
779 bits.width = cb->w;
780 bits.height = cb->h;
781 bits.format = cb->format;
782#if COMMODETTO_BITMAP_ID
783 bits.id = cb->id;
784 bits.byteLength = 0;
785#endif
786 bits.pixels = pocoGetBitmapPixels(the, poco, cb, 0);
787
788 color = (PocoColor)xsmcToInteger(xsArg(1));
789
790 x = (PocoCoordinate)xsmcToInteger(xsArg(2)) + poco->xOrigin;
791 y = (PocoCoordinate)xsmcToInteger(xsArg(3)) + poco->yOrigin;
792
793 if (argc <= 4) {
794 sx = 0, sy = 0;
795 #if (90 == kPocoRotation) || (270 == kPocoRotation)
796 sw = bits.height, sh = bits.width;
797 #else
798 sw = bits.width, sh = bits.height;
799 #endif
800 }
801 else {
802 sx = (PocoDimension)xsmcToInteger(xsArg(4));
803 sy = (PocoDimension)xsmcToInteger(xsArg(5));
804 sw = (PocoDimension)xsmcToInteger(xsArg(6));
805 sh = (PocoDimension)xsmcToInteger(xsArg(7));
806
807#if (0 == kPocoRotation) || (180 == kPocoRotation)
808 if ((sx >= bits.width) || (sy >= bits.height) || ((sx + sw) > bits.width) || ((sy + sh) > bits.height))
809#else
810 if ((sx >= bits.height) || (sy >= bits.width) || ((sx + sw) > bits.height) || ((sy + sh) > bits.width))
811#endif
812 xsRangeError("invalid src");
813
814 if (argc > 8)
815 blend = (uint8_t)xsmcToInteger(xsArg(8));
816 }
817
818 PocoGrayBitmapDraw(poco, &bits, color, blend, x, y, sx, sy, sw, sh);
819}
820
821void xs_poco_drawMasked(xsMachine *the)
822{

Callers

nothing calls this directly

Calls 2

pocoGetBitmapPixelsFunction · 0.85
PocoGrayBitmapDrawFunction · 0.85

Tested by

no test coverage detected