Skip to content

Commit

Permalink
homepage updates
Browse files Browse the repository at this point in the history
  • Loading branch information
williamngan committed Jun 19, 2018
1 parent 490c2ff commit a4c4aa4
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 59 deletions.
89 changes: 53 additions & 36 deletions assets/cover.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,68 @@
// Source code licensed under Apache License 2.0.
// Copyright © 2017 William Ngan. (https://github.com/williamngan/pts)

window.demoDescription = "In a field of points that revolves around a center, draw a perpendicular line from each point to a path.";

(function() {

Pts.namespace( this );
var space = new CanvasSpace("#pt").setup({bgcolor: "#fff", resize: true, retina: true});
var space = new CanvasSpace("#pt").setup({bgcolor: "#123", resize: true, retina: true});
var form = space.getForm();


//// Demo code ---

var delay = 0;
var angle = 0;

space.add( {

var pts = new Group();
var timeOutId = -1;
var header = null;


space.add({

// creatr 200 random points
start:( bound ) => {
pts = Create.distributeRandom( space.innerBound, 200 );
header = document.getElementById("header");
},

animate: (time, ftime) => {
// make a line and turn it into an "op" (see the guide on Op for more)
let perpend = new Group( space.center.$subtract(0.1), space.pointer ).op( Line.perpendicularFromPt );
pts.rotate2D( 0.0005, space.center );

delay++;
angle += Const.one_degree/2;

// get a line from pointer to center, and use it for direction and magnitude calculations
let center = space.center.clone().toAngle( angle, 0.1, space.center );
let ln = space.pointer.$subtract( center );
let dir = ln.$unit();
let mag = ln.magnitude();
let mag2 = space.size.magnitude();
let sc = (space.size.x > space.size.y) ? space.size.y/12 : space.size.x/12;

// create a grid of lines
let lines = Create.gridPts( space.innerBound, Math.floor( space.size.x/sc ), Math.floor( space.size.y/sc ) ).map( (p) => {
let dist = p.$subtract( space.center ).magnitude() / mag2;
return new Group(p, p.$add( dir.$multiply( dist*(20 + mag/5) ) ))
pts.forEach( (p, i) => {
// for each point, find the perpendicular to the line
let lp = perpend( p );
var ratio = Math.min( 1, 1 - lp.$subtract(p).magnitude()/(space.size.x/2) );
form.stroke(`rgba(255,255,255,${ratio}`, ratio*2).line( [ p, lp ] );
form.fillOnly( ["#f03", "#09f", "#0c6"][i%3] ).point( p, 1 );
});

// let color = Color.lab( Color.maxValues("lab") );
// color.multiply( 0.5, (space.pointer.x-space.center.x)/space.center.x, (space.pointer.y-space.center.y)/space.center.y, 1 );
// form.fillOnly( Color.LABtoRGB( color ).hex ).rect( space.innerBound );

form.strokeOnly("#f03", 2).line( [space.center, space.pointer] );
form.strokeOnly("#123", 1).lines( lines );

// header position
if (header) {
let top = window.pageYOffset || document.documentElement.scrollTop;
let dp = top - space.size.y + 150;
if (dp > 0) {
header.style.top = `${dp * -1}px`;
} else {
header.style.top = "0px";
}
}

},

action: (type, x, y) => {
delay = 0;

resize: () => {
clearTimeout( timeOutId );
setTimeout( () => {
pts = Create.distributeRandom( space.innerBound, 200 );
}, 500 );
}

});

//// ----


space.bindMouse().bindTouch().play();

})();
137 changes: 119 additions & 18 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,33 @@ html * {
#header {
font-size: 1.4em;
position: relative;
border-bottom: 1px solid #f03;
/* border-bottom: 1px solid #f03; */
line-height: 70px;

position: fixed;
top: 0; left: 0; right: 0;
z-index: 2;
}

#footer {
font-size: 1.1em;
text-align: center;
color: #aeb7c1;
width: 50%;
margin-left: 40%;
padding: 30px 0;
padding: 100px 0 30px;
}

#footer a, #footer a:hover {
color: #aeb7c1; text-decoration: underline;
}

#header a {
color: #123;
color: #fff;
text-decoration: none;
padding-left: 10px;
padding-right: 10px;
}
#header a:hover {
color: #f03;
color: #75f;
border-bottom: none;
}

Expand All @@ -56,10 +63,16 @@ html * {
padding-right: 0;
font-weight: normal;
}
#pts a {

#header_title {
color: #fff;
display: inline-block;
font-weight: bold;
padding-right: 0px;
font-size: 4em;
font-weight: 400;
margin-top: 40px;
margin-left: 20px;
user-select: none;
}
#pts a > span {
color: #f03;
Expand All @@ -69,7 +82,7 @@ html * {

#topmenu {
position: absolute;
top: 0; right: 30px;
top: 20px; right: 40px;
height: 100%;
vertical-align: middle;
}
Expand All @@ -82,12 +95,68 @@ html * {
}


#block_1 {
padding: 40px;
font-size: 2em;

.block h1, .block h3 {
margin: 60px 0 20px;
font-weight: 400;
}

.block {
width: 100vw;
max-width: 1350px;
margin: 0 auto;
text-align: center;

}

.block .subcol {
text-align: left;
vertical-align: top;
min-width: 540px;
max-width: 640px;
padding: 0 40px 0 80px;
box-sizing: border-box;
display: inline-block;
}

.block h3 {
font-size: 2.1em;
color: #345;
font-weight: 500;
}


.block p {
color: #345;
font-size: 1.3em;
}

.cta {
display: inline-block;
margin: 20px 0;
padding: 15px 20px;
font-size: 1.4em;
font-weight: 600;
border: 2px solid #42e;
color: #42e;
cursor: pointer;
}

.cta:hover {
background: #42e;
color: #fff
}

code {
display: inline-block;
background-color: #f3f7f9;
color: #678;
font-family: Menlo, sans-serif;
padding: 15px;
font-size: 0.8em;
margin: 10px 0;
}

/* ---------- */

#start {
Expand All @@ -114,7 +183,7 @@ html * {
#board {
cursor: pointer;
width: 100%;
height: 60vh;
height: 80vh;
}

#pt {
Expand Down Expand Up @@ -191,14 +260,13 @@ p {


a {
color: #f03;
font-weight: 500;
color: #42f;
text-decoration: none;
display: inline-block;
}

a:hover {
border-bottom: 1px solid #f03;
text-decoration: underline;
}

.demo, .section {
Expand Down Expand Up @@ -236,10 +304,20 @@ a:hover {
padding-left: 30px;
padding-right: 30px;
}

#header_title {
margin-top: 20px;
margin-left: 10px;
}

#topmenu {
display: none;
}

#footer {
line-height: 1.4;
padding: 100px 0 30px;
padding: 100px 40px 40px;
text-align: left;
}


Expand All @@ -252,6 +330,29 @@ a:hover {
}


.block h1, .block h3 {
/* margin: 60px 0 20px; */
font-weight: 400;
}

.block {
max-width: 100vw;
margin: auto;
text-align: left;

}

.block .subcol {
min-width: 50vw;
max-width: 100vw;
text-align: left;

padding: 0 40px;
box-sizing: border-box;
display: block;
}



#pts { padding-left: 0; line-height: 1.4; vertical-align: middle; }
#pts a { padding: 0; }
Expand All @@ -273,7 +374,7 @@ a:hover {
}

#board {
height: calc( 100vh - 100px );
height: 75vh;
}

#hint {
Expand Down
2 changes: 1 addition & 1 deletion dist/pts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 27 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<body>

<div id="header">
<div id="pts"><a href="./">Pts</a>
<div id="pts"><span id="header_title">Pts.</span>
<div id="topmenu">
<a href="../demo/index.html"/>demos</a>
<a href="../guide/index.html"/>guides</a>
Expand All @@ -38,10 +38,33 @@
<div id="pt"></div>
</div>

<div id="block_1">Hello</div>

<!-- <a id="start" href="./guide/Introduction-0000.html">Get started</a> -->
<div class="block">
<div class="subcol">
<h3>Connecting the dots</h3>
<!-- <p>A point represents the basic building block, the smallest idea, within a vast conceptual space. </p> -->
<!-- <p>Can you find the Big Dipper in a sky full of stars? Can you discover, through your mind's eyes, invisible points in conceptual spaces too?</p> -->
<!-- <p>Pts helps you connect and express those invisible points — as ideas, shapes, colors, motions, sounds, and more. </p> -->
<p>Pts is about connecting the dots, like seeing the Big Dipper in a sky full of stars, like watching dust afloat in the air illuminated by sunlight, like discovering sparks of insights in your mind.</p>
<p>Pts enables you to compose and visualize these invisible points, and to express what you see in your mind's eyes — points as ideas, shapes, colors, motions, interactions, sounds, and more.</p>
<div class="cta">Get Started</div>
</div>
<div class="subcol">
<h3>A modern javascript library</h3>
<p>Written in typescript and compiled to javascript ES6, Pts is lightweight and modular. It also comes with many useful algorithms for data visualization and creative coding.</p>
<p>You can <a href="#">link it</a> directly like this: <br />
<code>&lt;script src="https://unpkg.com/pts/dist/pts.min.js"&gt;&lt;script&gt;</code></p>
<p>Or use it via <a href="https://www.npmjs.com/package/pts" target="_blank">npm</a> like this: <br />
<code>npm install pts</code>
</p>
<p>Draw a dot that follows the pointer in just <a href="#">1 line of code</a>: <br />
<code>Pts.quickStart("#divId")( t => form.point( space.pointer ) )</code>
</p>
<p>You can use Pts by itself, or in conjunction with other libraries. Here is an example of using Pts with Tensorflow to <a href="#">visualize human pose</a>.</p>
<div class="cta">View Demos</div>
</div>
</div>

<div id="footer">Copyright &copy; 2017-current by <a href="https://twitter.com/williamngan">William Ngan</a> and contributors. Pts is an <a href="https://github.com/williamngan/pts">open source project</a> under Apache License 2.0.</div>

<script type="text/javascript" src="./assets/cover.js"></script>

Expand Down

0 comments on commit a4c4aa4

Please sign in to comment.