MCPcopy
hub / github.com/processing/p5.js / image

Method image

src/core/p5.Renderer2D.js:365–418  ·  view source on GitHub ↗
(
    img,
    sx,
    sy,
    sWidth,
    sHeight,
    dx,
    dy,
    dWidth,
    dHeight
  )

Source from the content-addressed store, hash-verified

363 //////////////////////////////////////////////
364
365 image(
366 img,
367 sx,
368 sy,
369 sWidth,
370 sHeight,
371 dx,
372 dy,
373 dWidth,
374 dHeight
375 ) {
376 let cnv;
377 if (img.gifProperties) {
378 img._animateGif(this._pInst);
379 }
380
381 try {
382 if (img instanceof MediaElement) {
383 img._ensureCanvas();
384 }
385 if (this.states.tint && img.canvas) {
386 cnv = this._getTintedImageCanvas(img);
387 }
388 if (!cnv) {
389 cnv = img.canvas || img.elt;
390 }
391 let s = 1;
392 if (img.width && img.width > 0) {
393 s = cnv.width / img.width;
394 }
395 if (this._isErasing) {
396 this.blendMode(this._cachedBlendMode);
397 }
398
399 this.drawingContext.drawImage(
400 cnv,
401 s * sx,
402 s * sy,
403 s * sWidth,
404 s * sHeight,
405 dx,
406 dy,
407 dWidth,
408 dHeight
409 );
410 if (this._isErasing) {
411 this._pInst.erase();
412 }
413 } catch (e) {
414 if (e.name !== 'NS_ERROR_NOT_AVAILABLE') {
415 throw e;
416 }
417 }
418 }
419
420 _getTintedImageCanvas(img) {
421 if (!img.canvas) {

Callers 15

instance.tsFile · 0.80
sketch0Function · 0.80
sketchFunction · 0.80
drawFunction · 0.80
p5.MediaElement.jsFile · 0.80
testImageRenderFunction · 0.80
loading.jsFile · 0.80
filters.jsFile · 0.80
pixels.jsFile · 0.80
rendering.jsFile · 0.80
p5.Framebuffer.jsFile · 0.80
p5.RendererGL.jsFile · 0.80

Calls 5

_getTintedImageCanvasMethod · 0.95
blendModeMethod · 0.95
_animateGifMethod · 0.80
_ensureCanvasMethod · 0.80
eraseMethod · 0.45

Tested by

no test coverage detected