299,792,458 m/s
Join Date: Mar 2012
Location: Lebanon
Posts: 3,581
|
I've had some C# projects that are currently on sale. ( https://www.dropbox.com/s/x3qp141dzb...ania_Setup.msi)
Here's a pre-done Gs2 Graph:
PHP Code:
// Made by Johnaudi
//#CLIENTSIDE
function onPlayerEnters() {
maxlooplimit = 10000000;
onPlayerChats();
}
function onPlayerChats() {
temp.rvars1 = {};
for (temp.i = 0; temp.i <= 4 * pi; temp.i += 0.1) {
temp.rvars1.add(cos(temp.i));
}
//onDrawGraph(this.attr[3].tokenize("#"), false, false, false, 0, "");
onDrawGraph(temp.rvars1, true, false, false, 0.1, {});
//onDrawGraph({2, -4, 8, 4}, true, true, true, 0, {{1, 3, 7, -2}});
//onDrawGraph({1, 2, 1, 5, 2, 3, 7, 2, 1, 6, 2, 3.5}, true, true, true, 0.2, {{3, 1, 1, 6, 3, 2, 4, 4, 1, 2, 1, 4}, {4.4, 2, 8, 3, 4, 5, 1, 4, 3, 3, 5, 1.5}});
}
function onDrawGraph(_arr, _fill, s_lines, s_nums, _loop, m_arrs) {
cancelevents("onDrawGraph");
hideimgs(240, 17000);
temp.polyxy = {this.x, this.y};
temp.polywh = {18, 13};
temp.vars = _arr;
if (_loop > 0) {
temp.i = 0;
temp.vars = "";
for (temp.s : _arr) {
if (temp.i == _arr.size() - 1) {
temp.vars.add(temp.s);
temp.vars.add(_arr[0]);
break;
}
if (temp.i != 0) temp.vars.add(temp.s);
temp.i++;
}
_arr = temp.vars;
temp.m_vrs = "";
for (temp._sr : m_arrs) {
temp.m_vr = "";
temp.ri = 0;
for (temp.sr_s : temp._sr) {
if (temp.ri == temp._sr.size() - 1) {
temp.m_vr.add(temp.sr_s);
temp.m_vr.add(temp._sr[0]);
break;
}
if (temp.ri != 0) temp.m_vr.add(temp.sr_s);
temp.ri++;
}
temp.m_vrs.add(temp.m_vr);
}
m_arrs = temp.m_vrs;
scheduleevent(_loop, "onDrawGraph", _arr, _fill, s_lines, s_nums, _loop, m_arrs);
}
temp.h_var = 0;
temp.l_var = 0;
temp.all_vrs = _arr;
for (temp._sr : m_arrs) {
for (temp.sr_s : temp._sr) {
temp.all_vrs.add(temp.sr_s);
}
}
for (temp.h_vi : temp.all_vrs) {
temp.h_var = max(temp.h_var, abs(temp.h_vi));
temp.l_var = min(temp.l_var, temp.h_vi);
}
with(findimg(250)) { // x
polygon = {temp.polyxy[0], temp.polyxy[1],
temp.polyxy[0], temp.polyxy[1] + 0.2,
temp.polyxy[0] + temp.polywh[0], temp.polyxy[1] + 0.2,
temp.polyxy[0] + temp.polywh[0], temp.polyxy[1]};
}
temp.polyxy = {this.x, this.y - temp.polywh[1]};
with(findimg(251)) { // y
polygon = {temp.polyxy[0], temp.polyxy[1],
temp.polyxy[0] + 0.2, temp.polyxy[1],
temp.polyxy[0] + 0.2, temp.polyxy[1] + temp.polywh[1] * (temp.l_var < 0 ? 2 : 1),
temp.polyxy[0], temp.polyxy[1] + temp.polywh[1] * (temp.l_var < 0 ? 2 : 1)};
}
temp.mxy = {temp.polyxy[0] - 0.4, temp.polyxy[1] + temp.polywh[1] - 0.4};
temp.nx = temp.polywh[0] / (temp.vars.size() - 1);
temp.ny = temp.polywh[1] / temp.h_var;
temp._usedlines = {};
for (temp.i = 1; temp.i <= temp.vars.size(); temp.i++) {
if (temp.i != temp.vars.size())
with(findimg(300 + temp.i)) {
polygon = {(_fill ? 0.4 : 0) + temp.mxy[0] + (temp.i - 1) * temp.nx, (_fill ? 0.4 : 0) + temp.mxy[1] - temp.vars[temp.i - 1] * temp.ny,
(_fill ? 0.4 : 0) + temp.mxy[0] + (temp.i) * temp.nx, (_fill ? 0.4 : 0) + temp.mxy[1] - temp.vars[temp.i] * temp.ny};
if (_fill) {
polygon.add((_fill ? 0.4 : 0) + temp.mxy[0] + (temp.i) * temp.nx);
polygon.add((_fill ? 0.4 : 0) + temp.mxy[1]);
polygon.add((_fill ? 0.4 : 0) + temp.mxy[0] + (temp.i - 1) * temp.nx);
polygon.add((_fill ? 0.4 : 0) + temp.mxy[1]);
}
alpha = _fill ? 0.4 : 1;
}
if (!(temp.vars[temp.i - 1] in temp._usedlines) && (temp.vars.size() > 1000 ? (temp.i % 2 == 0 ? true : false) : true)) {
if (s_nums)
with(findimg(1000 + temp.i)) {
text = toDouble(temp.vars[temp.i - 1]);
x = temp.polyxy[0] - 2;
//x = temp.mxy[0] + (temp.i - 1) * temp.nx - 0.5;
y = temp.mxy[1] - temp.vars[temp.i - 1] * temp.ny - 0.5;
zoom = (temp.vars.size() > 30 ? 0.6 : 0.7);
alpha = 0.6;
}
if (s_lines)
with(findimg(2000 + temp.i)) {
polygon = {temp.polyxy[0] - 0.5, temp.mxy[1] - temp.vars[temp.i - 1] * temp.ny - 0.025, temp.polyxy[0] + temp.polywh[0] - 0.4, temp.mxy[1] - temp.vars[temp.i - 1] * temp.ny - 0.025};
alpha = 0.2;
}
temp._usedlines.add(temp.vars[temp.i - 1]);
}
}
temp.vars = "";
for (temp.vars : m_arrs)
for (temp.i = 1; temp.i <= temp.vars.size(); temp.i++) {
temp.nx = temp.polywh[0] / (temp.vars.size() - 1);
temp.ny = temp.polywh[1] / temp.h_var;
temp.r_i = m_arrs.index(temp.vars);
if (temp.i != temp.vars.size())
with(findimg(4000 + temp.i + 1000 * temp.r_i)) {
polygon = {(_fill ? 0.4 : 0) + temp.mxy[0] + (temp.i - 1) * temp.nx, (_fill ? 0.4 : 0) + temp.mxy[1] - temp.vars[temp.i - 1] * temp.ny,
(_fill ? 0.4 : 0) + temp.mxy[0] + (temp.i) * temp.nx, (_fill ? 0.4 : 0) + temp.mxy[1] - temp.vars[temp.i] * temp.ny};
if (_fill) {
polygon.add((_fill ? 0.4 : 0) + temp.mxy[0] + (temp.i) * temp.nx);
polygon.add((_fill ? 0.4 : 0) + temp.mxy[1]);
polygon.add((_fill ? 0.4 : 0) + temp.mxy[0] + (temp.i - 1) * temp.nx);
polygon.add((_fill ? 0.4 : 0) + temp.mxy[1]);
}
alpha = _fill ? 0.4 : 1;
}
if (!(temp.vars[temp.i - 1] in temp._usedlines) && (temp.vars.size() > 1000 ? (temp.i % 2 == 0 ? true : false) : true)) {
if (s_nums)
with(findimg(5000 + + temp.i + 1000 * temp.r_i)) {
text = toDouble(temp.vars[temp.i - 1]);
x = temp.polyxy[0] - 2;
y = temp.mxy[1] - temp.vars[temp.i - 1] * temp.ny - 0.5;
zoom = (temp.vars.size() > 30 ? 0.6 : 0.7);
alpha = 0.6;
}
if (s_lines)
with(findimg(5500 + temp.i + 1000 * temp.r_i)) {
polygon = {temp.polyxy[0] - 0.5, temp.mxy[1] - temp.vars[temp.i - 1] * temp.ny - 0.025, temp.polyxy[0] + temp.polywh[0] - 0.4, temp.mxy[1] - temp.vars[temp.i - 1] * temp.ny - 0.025};
alpha = 0.2;
}
temp._usedlines.add(temp.vars[temp.i - 1]);
}
}
}
function toDouble(nt) {
return int(nt * 100) / 100;
}
There is a better way to do this, but I didn't bother re-coding it by having a single polygon forming the array.
Here's the function:
onDrawGraph(_arr, _fill, s_lines, s_nums, _loop, m_arrs)
_arr is int[]/double[]/float[] of the main array you want. In this example I provided with cosine of 2pi
_fill is just a visual effect (boolean), filling out to the x origin
s_lines is visual (boolean), showing the lines to the borders
s_nums is visual as-well (boolean), shows how much the value is
_loop is a numbers, set to 0 for no looping, set to some number of seconds to re-trace the first value
m_arrs is int[][]/double[][]/float[][], add as many arrays as you want under this.
(to be used in a class or local NPC)
|