MCPcopy
hub / github.com/phaserjs/phaser / create

Function create

src/display/canvas/CanvasPool.js:43–89  ·  view source on GitHub ↗
(parent, width, height, canvasType, selfParent)

Source from the content-addressed store, hash-verified

41 * @return {HTMLCanvasElement} The canvas element that was created or pulled from the pool.
42 */
43 var create = function (parent, width, height, canvasType, selfParent)
44 {
45 if (width === undefined) { width = 1; }
46 if (height === undefined) { height = 1; }
47 if (canvasType === undefined) { canvasType = CONST.CANVAS; }
48 if (selfParent === undefined) { selfParent = false; }
49
50 var canvas;
51 var container = first(canvasType);
52
53 if (container === null)
54 {
55 container = {
56 parent: parent,
57 canvas: document.createElement('canvas'),
58 type: canvasType
59 };
60
61 if (canvasType === CONST.CANVAS)
62 {
63 pool.push(container);
64 }
65
66 canvas = container.canvas;
67 }
68 else
69 {
70 container.parent = parent;
71
72 canvas = container.canvas;
73 }
74
75 if (selfParent)
76 {
77 container.parent = canvas;
78 }
79
80 canvas.width = width;
81 canvas.height = height;
82
83 if (_disableContextSmoothing && canvasType === CONST.CANVAS)
84 {
85 Smoothing.disable(canvas.getContext('2d', { willReadFrequently: false }));
86 }
87
88 return canvas;
89 };
90
91 /**
92 * Creates a new 2D Canvas DOM element, or pulls one from the pool if free.

Callers 2

create2DFunction · 0.85
createWebGLFunction · 0.85

Calls 1

firstFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…