Browse Source

TextureData:paste;

bjorn 5 years ago
parent
commit
57da369c4b
2 changed files with 121 additions and 0 deletions
  1. 61 0
      api/init.lua
  2. 60 0
      api/lovr/data/TextureData/paste.lua

+ 61 - 0
api/init.lua

@@ -3744,6 +3744,67 @@ return {
                 }
               }
             },
+            {
+              name = "paste",
+              summary = "Copy pixels from another TextureData to this one.",
+              description = "Copies a rectangle of pixels from one TextureData to this one.",
+              key = "TextureData:paste",
+              module = "lovr.data",
+              related = {
+                "Texture:replacePixels",
+                "TextureData:getPixel",
+                "TextureData:setPixel"
+              },
+              variants = {
+                {
+                  arguments = {
+                    {
+                      name = "source",
+                      type = "TextureData",
+                      description = "The TextureData to copy pixels from."
+                    },
+                    {
+                      name = "x",
+                      type = "number",
+                      description = "The x coordinate to paste to (0-indexed).",
+                      default = "0"
+                    },
+                    {
+                      name = "y",
+                      type = "number",
+                      description = "The y coordinate to paste to (0-indexed).",
+                      default = "0"
+                    },
+                    {
+                      name = "fromX",
+                      type = "number",
+                      description = "The x coordinate in the source to paste from (0-indexed).",
+                      default = "0"
+                    },
+                    {
+                      name = "fromY",
+                      type = "number",
+                      description = "The y coordinate in the source to paste from (0-indexed).",
+                      default = "0"
+                    },
+                    {
+                      name = "width",
+                      type = "number",
+                      description = "The width of the region to copy.",
+                      default = "source:getWidth()"
+                    },
+                    {
+                      name = "height",
+                      type = "number",
+                      description = "The height of the region to copy.",
+                      default = "source:getHeight()"
+                    }
+                  },
+                  returns = {}
+                }
+              },
+              notes = "The two TextureData must have the same pixel format.\n\nCompressed TextureData cannot be copied.\n\nThe rectangle cannot go outside the dimensions of the source or destination textures."
+            },
             {
               name = "setPixel",
               summary = "Set the value of a pixel of the TextureData.",

+ 60 - 0
api/lovr/data/TextureData/paste.lua

@@ -0,0 +1,60 @@
+return {
+  summary = 'Copy pixels from another TextureData to this one.',
+  description = 'Copies a rectangle of pixels from one TextureData to this one.',
+  arguments = {
+    {
+      name = 'source',
+      type = 'TextureData',
+      description = 'The TextureData to copy pixels from.'
+    },
+    {
+      name = 'x',
+      type = 'number',
+      default = '0',
+      description = 'The x coordinate to paste to (0-indexed).',
+    },
+    {
+      name = 'y',
+      type = 'number',
+      default = '0',
+      description = 'The y coordinate to paste to (0-indexed).',
+    },
+    {
+      name = 'fromX',
+      type = 'number',
+      default = '0',
+      description = 'The x coordinate in the source to paste from (0-indexed).',
+    },
+    {
+      name = 'fromY',
+      type = 'number',
+      default = '0',
+      description = 'The y coordinate in the source to paste from (0-indexed).',
+    },
+    {
+      name = 'width',
+      type = 'number',
+      default = 'source:getWidth()',
+      description = 'The width of the region to copy.'
+    },
+    {
+      name = 'height',
+      type = 'number',
+      default = 'source:getHeight()',
+      description = 'The height of the region to copy.'
+    }
+  },
+  returns = {},
+  notes = [[
+    The two TextureData must have the same pixel format.
+
+    Compressed TextureData cannot be copied.
+
+    The rectangle cannot go outside the dimensions of the source or destination textures.
+  ]],
+  related = {
+    'Texture:replacePixels',
+    'TextureData:getPixel',
+    'TextureData:setPixel'
+  }
+}