JimYuan's Blog

Sharing the things I learned

0%

HTML: Forms and Tables

Tables: TR, TD, and TH element

  • TR: The Table Row element
  • TD: The Table Data Cell element
  • TH: The Table Header element

TR: Table Row

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr

TD: Table Data

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td

TH: Table Header

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th

Tables: Thead, Tbody and Tfoot Elements

Tables: Colspan and Rowspan

1
2
3
4
5
6
7
8
<table>
<tr>
<th rowspan="2">Name</th>
<th rowspan="2">ID</th>
<th colspan="2">Membership Dates</th>
<th rowspan="2">Balance</th>
</tr>
</table>

Coding Excersice

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Heaviset Bird</h1>
<table>
<thead>
<tr>
<th>Subscription</th>
<th>Price</th>
<th>Support</th>
</tr>
</thead>
<tbody>
<tr>
<td>Free</td>
<td>Free</td>
<td>N/A</td>
</tr>
<tr>
<td>Personal</td>
<td>$9.99</td>
<td>Weekdays</td>
</tr>
<tr>
<td>Business</td>
<td>$49.99</td>
<td>24/7</td>
</tr>
</tbody>
</table>

table>tr>td*5
</body>
</html>

The Form Element

Creating Forms

  • The <form> element itself is a shell of container that doesn’t have any visual impact.
  • We then fill the form with a collection of inputs, checkboxes, buttons, etc.

<form>

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form

  • The form element represents a document section containing interactive contorls for submitting information.
  • The action attribute specifies WHERE the form data should be sent
  • The method attribute specifies which HTTP method should be used

<input> Common Input Types

  • The input element is used to create a variety of different form controls
  • We have 20+ possible types of inputs ranging from data pickers to checkboxes.
  • The type attribute is where the magic happens. Changing type dramatically alters the input’s behavior and appearance
1
2
3
4
5
6
7
<form action="/tacos">
<input type="text" name="" id="">
<input type="button" value="">
<input type="color" name="" id="">
<input type="image" src="" alt="">
<input type="text" placeholder="default">
</form>

The All-important Label label

https://developer.mozilla.org/en-US/search?q=label

The


1
2
3
4
5
6
7
8
9
<div class="preference">
<label for="cheese">Do you like cheese?</label>
<input type="checkbox" name="cheese" id="cheese">
</div>

<div class="preference">
<label for="peas">Do you like peas?</label>
<input type="checkbox" name="peas" id="peas">
</div>

HTML Buttons

The <button> HTML element represents a clickable button, used to submit forms or anywhere in a document for accessible, standard button functionality.

By default, button hold a type="submit" but if you want the button do not submit a form, you can do <button type="button">

1
2
3
4
<button class="favorite styled"
type="button">
Add to favorites
</button>

alternative

1
<input type="submit">

The name Attribute

We should put it on every single input that you use and it will be used when you send your data to a server eventually.

NameAttributes

Note that the webpage url changed after submitting the form.

1
2
3
4
5
6
7
8
9
10
11
12
<form action="https://www.reddit.com/search">
<input type="text" name="q">
<button>Search Reddit</button>
</form>
<form action="https://www.google.com/search">
<input type="text" name="q">
<button>Search google</button>
</form>
<form action="https://www.youtube.com/results">
<input type="text" name="search_query">
<button>Search youtube</button>
</form>

Radio Buttons, Checkboxes, & Selects

Checkboxes

1
2
3
4
5
<form action="/birds">
<input type="checkbox" name="agree_tos" id="agree" >
<label for="agree">I agree to everything</label>
<button>Submit</button>
</form>

Radio Buttons

1
2
3
4
5
6
7
8
<p>
<label for="s">S:</label>
<input type="radio" name="size" id="s" value="s">
<label for="m">M:</label>
<input type="radio" name="size" id="m" value="m">
<label for="l">L:</label>
<input type="radio" name="size" id="l" value="l">
</p>


1
2
3
4
5
6
7
8
<p>
<label for="meal">Please select an Entree</label>
<select name="meal" id="meal">
<option value="fish">Fish</option>
<option value="steak">Steak</option>
<option value="orange">Orange</option>
</select>
</p>

Range & Text Area

Range

1
2
3
4
<p> 
<label for="cheese">Amount of Cheese:</label>
<input type="range" id="cheese" min="1" max="100" name="cheese_level">
</p>

Text Area

1
2
3
4
<p>
<label for="req">Any Special Request?</label><br>
<textarea name="req" id="req" cols="100" rows="10"></textarea>
</p>


What Exactly Is Html5

Living Standard

The HTML standard is a document that describes how HTML should work

Role of Browsers

The standard describes the rules of HTML, but browsers actaully have to do the work and implement HTML according to those rules.

HTML5

HTML5 is the lastest evolution of the standard that defines HTML. It includes new elements & features for browsers to implement.

Block vs Inline Elements

  • INLINE elements
  • BLOCK elements

: The Content Division element

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span

1
2
<div></div>
<span></span>

Generic container
Div helps us the group the content together and style them all in once.

An Odd Assortment of Elements: HR, BR, Sup, Sub

1
2
3
4
- <hr> : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr
- <br> : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/br
- <sup></sup>: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
- <sub></sub>: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub

Entity Code

https://dev.w3.org/html5/html-author/charref
https://www.w3schools.com/html/html_entities.asp

Some characters are reserved in HTML. If you use the less than (<) or greater than (>) signs in your text, the browser might mix them with tags. Character entities are used to display reserved characters in HTML.

Intro to Semantic Markup - MEANINGFUL markup

Semantic - relating to meaning

what purpose of role does that HTML element have?

Semantic Markup can organize your html code well, and also google can crawl your page easily.

Playing with Semantic Elements

main

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main

The <main> HTML element represents the dominant content of the <body> of a document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nav

The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents.

section

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section

article

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article

The <article> HTML element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication).

aside

https://developer.mozilla.org/en-US/search?q=aside

The <aside> HTML element represents a portion of a document whose content is only indirectly related to the document’s main content.

VSCode Tip: Emmet

https://docs.emmet.io/

https://docs.emmet.io/abbreviations/syntax/

For example

1
nav>ul>li + Tab
1
2
3
4
5
<nav>
<ul>
<li></li>
</ul>
</nav>

Emmet

Introduction to HTML

HTML is a Markup language

HTML was created to help describe the structure of the acedemic research papars and share they across the very early internet.

The goal of HTML is to take the text content and somehow mark it up with some structures.

HTML Elements

To write HTML, we pick from a set of standard Elements that all browsers recognize

Common Elmements includes:

1
2
3
4
- <p> element: represent a paragraph of text
- <h1> element: represents the main header on the page
- <img> element: embeds an image
- <form> element: represents a form

Our Very First HTML Page

  1. Save your HTML file with the file extension [.html]
  2. After that you should be able view your web in local browser
1
2
DEVELOPING ON OMNIVERSE
NVIDIA Omniverse™ is a powerful multi-GPU real-time simulation and collaboration platform for 3D production pipelines based on Pixar's Universal Scene Description and NVIDIA RTX™technology.

1
2
DEVELOPING ON OMNIVERSE
NVIDIA <b>Omniverse™</b> is a powerful multi-GPU real-time simulation and collaboration platform for 3D production pipelines based on Pixar's Universal Scene Description and NVIDIA RTX™technology.

Developer Resources

https://developer.mozilla.org/en-US/

HTML Tags

Fast Way to Type HTML Tags

For example:

1
<b></b>

Press ‘b’ then ‘Tab’ to autocomplete

Paragraph Tag

1
<p>Something in between</p>
  • Take a block of space

Heading Elements

1
2
3
4
5
6
- <h1></h1>
- <h2></h2>
- <h3></h3>
- <h4></h4>
- <h5></h5>
- <h6></h6>

Chrome Inspector

Right click on the webpage select “Chrome Inspector” and then we can see the html instruction of the current showing web.

HTML Boilerplate

HTML SKELETON

We write our HTML in a standard “skeleton”

1
2
3
4
5
6
7
8
9
10
11
<!DOCTYPE html>
<html>
<head>
<title>
JimYuan
</title>
</head>
<body>
All the webpage contains
</body>
</html>
  • !DOCTYPE html is weird by not having the closing tab
  • Html element should have inside
    • head tag
    • body tag
  • Title is for the webpage name/ tab-name(Google use this tag element in the head to create the link in the search result)

Short cut for generate this skeleton

! + “Tab”

1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>

</body>
</html>

Reference Resources

VSCode Tip: Auto-format

Ctrl + Shift + P + (searching “format”)

List Element

1
2
3
- unordered list <ul></ul>
- ordered list <ol></ol>
- list item <li></li>

The Anchor Element

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a

The HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.

1
2
3
4
5
6
7
<p>You can reach Michael at:</p>

<ul>
<li><a href="https://example.com">Website</a></li>
<li><a href="mailto:m.bluth@example.com">Email</a></li>
<li><a href="tel:+123456789">Phone</a></li>
</ul>

Image

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img

1
<img src="picture_location" alt="Some description about the pictue">
  • note that image tag don’t have closing tag

The alt attribute holds a text description of the image, which isn’t mandatory but is incredibly useful for accessibility.

Comment

1
<!-- comment -->

The Shortcut In VScode

Toggle line comment

This is the note from The Web Developer Bootcamp on Udemy created by Colt Steele. I’ve always want to know more about web, and I think it might be a good idea to just follow this bootcamp a bit.

Link: https://www.udemy.com/course/the-web-developer-bootcamp/

The Internet In 5 Minutes

  • Routing: phyiscal machine to help you connet your computer to someone else.
  • My computer doesn’t need to know your computer at all
  • Internet -> Network of networks

HTTP requests

  • Foundation of communication on the World Wide Web
  • Hyper Text Transfer Protocol
  • Request -> I would like this information please
  • Responese -> Ok, here you go!

The Request/Response Cycle

A server somewhere(Here are the instructions) -INSTRUCTION-> your browser (Look what I made!)

You can right click on any webpage [View_Page_Source] to see the content of the Instrucstion from that server.

Front End/ Back End

  • Front End: Dining Place
  • Back End: Kitchen

What do HTML/CSS/JS do?

The

  • Purple [CSS_adj]
  • Dinosaur [HTML_noun]
  • Danced [JS_verbs]

https://codepen.io/

Physical Sitmalation

One big idea behind the physical simualtion is all the things inside computer is discrete. We should tranfer the smooth/ continuous real world into digit/ discrete/ finite computer language. Instead of having infinite elements(or atoms) in one rope, we are have finite amount of element.

rope

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
private void RunScript(bool reset, Point3d anchor0, Point3d anchor1, int nodeCount, double mass, Vector3d gravity, double stiffness, double friction, ref object P, ref object V, ref object C)
{
if(reset){
nodes.Clear();
vels.Clear();

Line line = new Line(anchor0, anchor1);
NurbsCurve lineCurve = line.ToNurbsCurve();

Point3d[] pts;
lineCurve.DivideByCount(nodeCount - 1, true, out pts);

nodes.AddRange(pts);

for (int i = 0; i < nodeCount; i++)
{
vels.Add(new Vector3d(0, 0, 0));
}
}

// Update the location of the anchors
nodes[0] = anchor0;
nodes[nodes.Count - 1] = anchor1;



// Simulation forces for each node
for (int i = 1; i < nodes.Count - 1; i++)
{
Point3d n = nodes[i];
Vector3d v = vels[i];

// Calculating all the forces
Vector3d gravityForce = mass * gravity;
Vector3d prevSpring = -stiffness * (n - nodes[i - 1]);
Vector3d nextSpring = -stiffness * (n - nodes[i + 1]);

// Aggregate all the forces
Vector3d totalForce = gravityForce + prevSpring + nextSpring;

// Update velocity
v += totalForce;

// Add friction
v *= friction;

// Update location of the node
n += v;

// Update values on the original lists
nodes[i] = n;
vels[i] = v;

}

P = nodes;
V = vels;
C = new Polyline(nodes);
}

// <Custom additional code>
List<Point3d> nodes = new List<Point3d>();
List<Vector3d> vels = new List<Vector3d>();
// </Custom additional code>

Intro

In grasshopper field, there’re some useful and famous plug-ins for phyiscal simulation. Just to mention a few, Kangaroo, Flexhopper,… and etc.
I always think it’s more fun to play around the modelling which mimic the realistic phyiscal behaviours. This post is for noting down some developers’ thoughts while developing the phyiscal simulation tools.

And again this amazing tutorial is from Professor. Jose.
Here’s the link:

https://www.youtube.com/watch?v=kG-AxzMPjxk&t=5311s

Also, one important concept before doing simulations would be iteration.

Iteration

Usually, the physic behaviors are related to time, meaning it’s a function of time.
In code, we need to make sure the result of previous round can be brought to the next round.
Might be seen something like this.

1
NextRound += PreviousRound;

Iteration In C# script Component

https://www.youtube.com/watch?v=ek2iL88WqGQ&t=497s
Professor Jose well explained the scope of the variables in C# script component, which is one of the vital ingredient before you do any simualtion related to time.

Code

Here I would like to share one of the example in this tutorial.
idea

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
private void RunScript(bool reset, Point3d anchorPoint, Point3d startPoint, double radius, Vector3d gravity, double stiffness, double friction, ref object L, ref object S, ref object P, ref object V)
{
//Algorithm
if(reset)
{
currentLocation = startPoint;
currentVelocity = Vector3d.Zero;
}

// Calculate all forces acting on the particle
Vector3d gravityForce = gravity;
Vector3d springForce = -stiffness * (currentLocation - anchorPoint);

Vector3d totalForces = gravityForce + springForce;

// Update the currentVelocity with all the acting forces
currentVelocity += totalForces;

// Damp down velocity a little assuming friction on the system
currentVelocity *= friction;

// Update the location based on the velocity
currentLocation += currentVelocity;

// Output
L = new Line(anchorPoint, currentLocation);
S = new Sphere(currentLocation, radius);
P = currentLocation;
V = currentVelocity;
}

// <Custom additional code>
Point3d currentLocation = Point3d.Unset;
Vector3d currentVelocity = Vector3d.Unset;

I just finished this quick introduction of JSON video, and it was so helpful.
Here is the link:
https://www.youtube.com/watch?v=iiADhChRriM&t=553s

Several things I would like to take away from this lesson:

The most important thing might be this one:

Everything in JSON is VALID in JavaScript


JaveScript Object Notation

  • Data Representation Format
  • Commonly Used for APIs and Configs
  • Lightweight and Easy to Read/Write
  • Integrate Easily With Most Language

JSON Types

  • Strings
  • Number
  • Booleans
  • null
  • Array
  • Object

Example

user.json
{
“name”: “Kyle”,
“favoriteNumber”: 3,
“isProgrammer”: true,
“hobbies”: [“Weight Lifting”, “Bowling”],
“friends”: [{
“name”: “Joey”,
“favoriteNumber”: 100,
“isProgrammer”: false,
“friends”: […]
}]
}

How to Parse from string to JSON

JSON.Parse(string)

Recently, I tried RhinoInsideRevit a bit. I found that RIR has this Direct Shape to help deliver geometry from Rhino/Grasshopper to Revit.
I would like to note down some thought I currently have while I developing alongside.

According to the RevitAPI doc page about DirectShape:
https://www.revitapidocs.com/2022/bfbd137b-c2c2-71bb-6f4a-992d0dcf6ea8.htm

This class is used to store externally created geometric shapes. Primary intended use is for importing shapes from other data formats such as IFC or STEP. A DirectShape object may be assigned a category. That will affect how that object is displayed in Revit.

So, which may mean that although RhinoInsideRevit might be a get-around solution without producing/ exporting a IFC file by building the Rhino on Revit (In runtime, Revit occupied some memories, and inside those memeories Rhino takes some part to be built), internally, both (IFC-way and RIR) use this DirectShape to help external geometry to be put inside Reivt.

About what RhinoInsideRevit, we can refer this QA interview video from the official developers group.
https://www.youtube.com/watch?v=kckMA-GdsLc&t=6451s

Recently, I wanna catch up the videos from Jose Lois. Hope this way I can rememeber the thing I’ve learned a bit longer.
Here’s the video:
https://www.youtube.com/watch?v=sJT_m4AxR0o

Things I’ve learned from the video is:

  • Sanity, can help construct the upper bound/ lower bound
  • List_Item“ component has wrap boolean toggle to help avoiding the boundary issue
  • Whenever error happened, we could try use
1
Component.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Index out of bounds");

This line make the script component yellow, and print the warning message.

Along my way of developing with RhinoCommon, I noticed that I have some certain patterns which I feel them handy and keep using from time to time.
This note is for the skill/ function I recently learned and implemented.


Readers may refer to this QA
https://discourse.mcneel.com/t/moveface-in-rhinocommon/129818

So basically, in RhinoCommon, we have this Brep.TransformComponent function, this can allow developer to change(apply xform) on a certain component(vertice/ edge/ face) and the other components will changed accordingly as well.

You could see the example code I provide here and also in the QA section page

1
2
3
4
5
List<ComponentIndex> ci = new List<ComponentIndex>();
ci.Add(x.Faces[0].ComponentIndex());
Transform moveDown = Transform.Rotation(y, Vector3d.YAxis, x.Faces[0].GetBoundingBox(true).Center);
x.TransformComponent(ci, moveDown, 0.0001, 0.1, true);
A = x;

And the result:
screenShot