Surface.clone

From Spheriki

Jump to: navigation, search

Makes a new, separate copy of the surface.


Usage

Surface surface.clone();
  • surface Sphere Surface object. The surface to clone.
  • Surface is returned, which is the new surface. It is identical to the old one, except actions performed on this surface will not be reflected in the original, and vice versa.


Examples

This example features a red rectangle in both surfaces, but a green triangle in only a clone of the original surface.

var black = CreateColor(0, 0, 0);
var red = CreateColor(255, 0, 0);
var green = CreateColor(0, 255, 0);

var s1 = CreateSurface(100, 100, black);
s1.rectangle(10, 10, 60, 90, red);

var s2 = s1.Surface.clone();
s2.triangle(50, 20, 5, 60, 95, 60, red);

s1.blit(0, 0);
s2.blit(210, 0);
FlipScreen();
GetKey();


See also