p5.js | show() Function
Last Updated :
20 Aug, 2019
The show() function is an inbuilt function which is used to display the current element. Use setting display: block for style purpose.
This function requires p5.dom library. So add the following line in the head section of the index.html file.
<script language= "javascript"
type= "text/javascript" src= "path/to/p5.dom.js" >
</script>
|
Syntax:
show()
Parameters: This function does not accepts any parameters.
Below example illustrates the show() function in p5.js:
Example:
function setup() {
var cvs = createCanvas(600, 250);
}
function draw() {
background( 'green' );
var myDiv1 = createDiv( 'GeeksforGeeks' );
myDiv1.position(170, 30);
myDiv1.size(200, 100);
myDiv1.style( 'font-size' , '36px' );
var myDiv = createDiv( 'A computer science portal for geeks' );
myDiv.position(180, 80);
myDiv.size(200, 100);
myDiv.style( 'font-size' , '24px' );
myDiv.style( 'border' , '1px solid black' );
myDiv.style( 'text-align' , 'center' );
myDiv.style( 'color' , 'white' );
myDiv.hide();
myDiv.show();
}
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...