Day 13th -2015-4-9-processing Tutorial-api-Second lecture on-lerpcolor (), NFP (),

Source: Internet
Author: User

So it's been updated for 10 days. And then today's update is the processing API, in fact, this is my study processing on the way a byproduct; anyway offerings,

I'll take it out today and see. Actually just API document words, and there is no need for anything. But if it's just the need to talk about existence, my blog is not

The necessity of existence. There are no more advanced or particularly useful things to record. The purpose of my previous blog is simply to write, and because to write, it will naturally lead to

Interruption, after all, people are fickle animals.

So, the next thing I'm going to do is change.

I'm going to write some really useful articles.

The next entry into the processing combat, the goal is to create our own processing framework--pepper. The details will be written in the following tutorial.

Next, if you want to continue reading the API, go ahead.


006
-------------------------------------------------------------------------------------------------------------
Lerpcolor ()
-------------------------------------------------------------------------------------------------------------

Case

Stroke (255);
Background (51);
Color from = Color (204, 102, 0);
Color to = Color (0, 102, 153);
Color Intera = Lerpcolor (from, to,. 33);
Color Interb = Lerpcolor (from, to,. 66);
Fill (from);
Rect (10, 20, 20, 60);
Fill (Intera);
Rect (30, 20, 20, 60);
Fill (Interb);
Rect (50, 20, 20, 60);
Fill (to);
Rect (70, 20, 20, 60);

-------------------------------------------------------------------------------------------------------------

Describe

This function is similar to the LERP () function, which is also a function of entering two ranges, a ratio, and thus getting a value between two.
The difference is that the Lerpcolor () function calculates the color. The concrete usage is exactly the same as the Lerp (), no longer repeat.

The only difference is that the Lerpcolor () function truncates the offside value--that is, for example, the original is 20-230, and you
The ratio is set to 1.1 then it will be 230, even if it is 1.1 times times less than 255. In Lerp (), the cross-border is fully permissible.
The reason for this setting is to prevent the appearance of a color that cannot be displayed. (Of course if you start with the colors and the range
or the Hopeless)

-------------------------------------------------------------------------------------------------------------

Grammar

Lerpcolor (c1, C2, AMT)

-------------------------------------------------------------------------------------------------------------

Parameters

C1int: Starting color value
C2int: Key color values
Ratio of amtfloat:0.0 to 1.0

-------------------------------------------------------------------------------------------------------------

return value

Int
There's a lot to say about this int here--because the color type in processing is actually int!!
Yes, you're not mistaken, color is int. Sure you'll find it strange-otherwise you don't have to read my tutorial ...
So, why the int type can concurrently color.

First, the int type occupies 4 bytes, regardless of the platform.
The color type, in fact, is 4 sets of numbers, RGB three primary colors and alpha transparent channel.
Generally used colors are 0-255 of the range, that is, a byte of storage size is required. 4 sets of numbers are exactly the space of an int.

The bottom of the thing is not much to say-but the feeling of using int to represent the color is really a Java feature--c++ can not do.

-------------------------------------------------------------------------------------------------------------

Related

Color ()
Lerp ()

-------------------------------------------------------------------------------------------------------------

007
-------------------------------------------------------------------------------------------------------------
NFP ()
-------------------------------------------------------------------------------------------------------------

Case


int a=200, b=-40, c=90;
String sa = NFP (A, 10);
println (SA); Prints "+0000000200"
String sb = NFP (b, 5);
println (SB); Prints "-00040"
String sc = NFP (c, 3);
println (SC); Prints "+090"

Float d = -200.94, E = 40.2, F =-9.012;
String SD = NFP (d, 10, 4);
println (SD); Prints "-0000000200.9400"
String SE = NFP (E, 5, 3);
println (SE); Prints "+00040.200"
String SF = NFP (f, 3, 5);
println (SF); Prints "-009.01200"

-------------------------------------------------------------------------------------------------------------

Describe

Used to format numbers as strings. Same as NF function, but "+" appears in front of a positive number and "-" appears before negative numbers. It has two formats, one of which is

Determine the number of digits after the decimal point, and the other is to determine the integer and decimal digits. And these values should be positive integers.

-------------------------------------------------------------------------------------------------------------

Grammar

NFP (num, digits)
NFP (num, left, right)

-------------------------------------------------------------------------------------------------------------

Parameters

Numfloat[], int[], or int: The number to be formatted
Digitsint: Digits after decimal point
Leftint: Digits before decimal point
Rightint: Digits after decimal point


-------------------------------------------------------------------------------------------------------------

return value

String or string[]

-------------------------------------------------------------------------------------------------------------

Related

NF ()
NFS ()
NFC ()
-------------------------------------------------------------------------------------------------------------

008
-------------------------------------------------------------------------------------------------------------
Box ()
-------------------------------------------------------------------------------------------------------------

Case

Size (+, p3d);
Translate (58, 48, 0);
Rotatey (0.5);
NoFill ();
Box (40);

-------------

Size (+, p3d);
Translate (58, 48, 0);
Rotatey (0.5);
NoFill ();
Box (40, 20, 50);


-------------------------------------------------------------------------------------------------------------

Describe

Box is a kind of geometry produced by rectangle extrusion. (Just a box)
If the length of each of its sides is equal, it is a cube

-------------------------------------------------------------------------------------------------------------

Grammar

Box (size)
Box (W, H, D)

-------------------------------------------------------------------------------------------------------------

Parameters

Sizefloat: Length of each edge (cube)
Wfloat:x Axis Direction length
Hfloat:y Axis Direction length
Dfloat:z Axis Direction length

-------------------------------------------------------------------------------------------------------------

return value

void

-------------------------------------------------------------------------------------------------------------

Related

Sphere ()

-------------------------------------------------------------------------------------------------------------

009
-------------------------------------------------------------------------------------------------------------
Sphere ()
-------------------------------------------------------------------------------------------------------------

Case

Size (100,100,P3D);
Nostroke ();
Lights ();
Translate (58, 48, 0);
Sphere (28);

-------------------------------------------------------------------------------------------------------------

Describe

Sphere is a hollow sphere that is spliced with triangular faces.

-------------------------------------------------------------------------------------------------------------

Grammar

Sphere (R)

-------------------------------------------------------------------------------------------------------------

Parameters

Rfloat: Sphere radius

-------------------------------------------------------------------------------------------------------------

return value

void

-------------------------------------------------------------------------------------------------------------

Related
Spheredetail ()

-------------------------------------------------------------------------------------------------------------


010
-------------------------------------------------------------------------------------------------------------
Spheredetail ()
-------------------------------------------------------------------------------------------------------------

Case

void Setup () {
Size (+, p3d);
}

void Draw () {
Background (200);
Stroke (255, 50);
Translate (50, 50, 0);
Rotatex (Mousey * 0.05);
Rotatey (MouseX * 0.05);
Fill (MouseX * 2, 0, 160);
Spheredetail (MOUSEX/4);
Sphere (40);
}

-------------------------------------------------------------------------------------------------------------

Describe

Controls how fine the sphere is by controlling the number of vertices that make up the sphere mesh. The default precision is 30.
With a precision of 30, every 360 degrees corresponds to 30.3 yuan faces, that is 360/30 equals 12 degrees,
It's still a bit smoother. If you want to render a lot of spheres at every frame,
It is better to reduce the precision of the fractal properly.

Only if you call Spheredetail () and give a new precision will the settings really change, so don't each
Spheres are called once--unless you want their accuracy to be different--to lower the precision of a small object, far from the lens,
This can improve efficiency.

If you want to change the accuracy of the horizontal and vertical directions, call the version of the two parameter

-------------------------------------------------------------------------------------------------------------

Grammar

Spheredetail (RES)
Spheredetail (Ures, Vres)

-------------------------------------------------------------------------------------------------------------

Parameters

Resint: Fractal accuracy () minimum is 3
Uresint: Horizontal Directional fractal accuracy
Vresint: Vertical-oriented fractal accuracy

-------------------------------------------------------------------------------------------------------------

return value

void

-------------------------------------------------------------------------------------------------------------

Related
Sphere ()

-------------------------------------------------------------------------------------------------------------

Day 13th -2015-4-9-processing Tutorial-api-Second lecture on-lerpcolor (), NFP (),

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.