File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -945,7 +945,7 @@ class RendererGL extends Renderer {
945945 pg . canvas = document . createElement ( "canvas" ) ;
946946 const node = pg . _pInst . _userNode || document . body ;
947947 node . appendChild ( pg . canvas ) ;
948- p5 . Element . call ( pg , pg . canvas , pg . _pInst ) ;
948+ Element . call ( pg , pg . canvas , pg . _pInst ) ;
949949 pg . width = w ;
950950 pg . height = h ;
951951 } else {
Original file line number Diff line number Diff line change 1+ import { describe , it , expect } from 'vitest' ;
2+
3+ // Importing p5
4+ import '../../../lib/p5.js' ;
5+
6+ describe ( 'noSmooth() should preserve canvas position in WEBGL' , ( ) => {
7+ it ( 'should maintain the canvas position after calling noSmooth()' , ( ) => {
8+
9+ let myP5 = new window . p5 ( ( p ) => {
10+ p . setup = function ( ) {
11+ let cnv = p . createCanvas ( 300 , 300 , p . WEBGL ) ;
12+ cnv . position ( 150 , 50 ) ;
13+
14+ const originalTop = cnv . elt . style . top ;
15+ const originalLeft = cnv . elt . style . left ;
16+
17+ // Call noSmooth()
18+ p . noSmooth ( ) ;
19+
20+ // Checking if position remains or not
21+ expect ( cnv . elt . style . top ) . toBe ( originalTop ) ;
22+ expect ( cnv . elt . style . left ) . toBe ( originalLeft ) ;
23+ } ;
24+ } ) ;
25+ } ) ;
26+ } ) ;
You can’t perform that action at this time.
0 commit comments