Coder Social home page Coder Social logo

shalevy1 / optical_illusions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arthurfincham/optical_illusions

0.0 0.0 0.0 273 KB

A collection of classic optical illusions made with p5.js

Home Page: https://editor.p5js.org/arthurfincham/collections/u1Rp4mLSq

JavaScript 100.00%

optical_illusions's Introduction

A collection of classic optical illusions made with p5.js, a JavaSript library for creative coding.

To get started with p5.js, follow the instructions below.

For help in creating each illusion, navigate to the respective folder.

To see the collection in the p5 editor: https://editor.p5js.org/arthurfincham/collections/u1Rp4mLSq

Index of Illusions

Illusion Info Repo Preview
Hermann Grid hermann_grid preview
Cafe Wall cafe_wall preview
Munker-White munker_white preview

๐Ÿ”ง p5.js Setup (for inclusion in HTML)

1. To include the p5.js library in your script, go to the CDN page - here you will find the latest version.

Latest release as of July 2021: https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js

2. Then, we can include the link in a <script> tag in our HTML <head> .

Our HTML should now look as follows:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Hermann Grid</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"></script>
  </head>
  <body>

  </body>
</html>

3. Next, we need to create a script.js file.

Our file structure should look like:

> p5_folder
  * index.html
  * sketch.js

4. Finally, we include a <script> tag in the <body> of our HTML. Our code is...

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Hermann Grid</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"></script>
  </head>
  <body>
    <script src="sketch.js"></script>
  </body>
</html>

... and we are ready to code!

This may seem strange - there is no <canvas> tag in our HTML as one might expect. Our sketch.js file will create one!

optical_illusions's People

Contributors

arthurfincham avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.