Date: 10/08/2022 14:27:29
From: Kingy
ID: 1919362
Subject: Programming languages

I have been trying to install a free programming language on Win7 so that I can keep my skills up, but it appears to be much harder to install one than to actually write programs.

Python is my first preference, but it doesn’t seem to play nicely with arrays on win7, and arrays are what I want to play with.

I tried C++ and created a few arrays and populated them with data, but I couldn’t get it to display the contents of the array as coloured pixels in a window.

Yesterday in desperation, I tried FreeBasic. Also way too hard to install and run a “Hello World” program.

Each one of these took at least a day wasted just trying to do a simple task.

Can anyone suggest a free package that allows me to write a program to create a (X * Y) array, randomise the contents, and display that array as coloured pixels in a separate window, with a menu bar at the top?

Reply Quote

Date: 10/08/2022 14:32:56
From: SCIENCE
ID: 1919366
Subject: re: Programming languages

do you mind if it runs in a browser

Reply Quote

Date: 10/08/2022 14:42:02
From: Kingy
ID: 1919370
Subject: re: Programming languages

SCIENCE said:


do you mind if it runs in a browser

Not really, as long as the code is portable.

Reply Quote

Date: 10/08/2022 14:46:22
From: dv
ID: 1919373
Subject: re: Programming languages

Kingy said:

Python is my first preference, but it doesn’t seem to play nicely with arrays on win7, and arrays are what I want to play with.

Well that’s weird but yeah the solution is to sort out your environment issues and still use Python…

Reply Quote

Date: 10/08/2022 14:53:27
From: The Rev Dodgson
ID: 1919381
Subject: re: Programming languages

Kingy said:


I have been trying to install a free programming language on Win7 so that I can keep my skills up, but it appears to be much harder to install one than to actually write programs.

Python is my first preference, but it doesn’t seem to play nicely with arrays on win7, and arrays are what I want to play with.

I tried C++ and created a few arrays and populated them with data, but I couldn’t get it to display the contents of the array as coloured pixels in a window.

Yesterday in desperation, I tried FreeBasic. Also way too hard to install and run a “Hello World” program.

Each one of these took at least a day wasted just trying to do a simple task.

Can anyone suggest a free package that allows me to write a program to create a (X * Y) array, randomise the contents, and display that array as coloured pixels in a separate window, with a menu bar at the top?

If you have Excel it comes with VBA so it’s free.

The free office programs also have built in programming languages; a different variety of Basic, or Javascript for the Google spreadsheet.

You can also do Javascript in Excel, but I wouldn’t recommend it.

Also installing Python shouldn’t be that hard.

You know if you want to work with arrays in Python you should install Numpy?

Reply Quote

Date: 10/08/2022 14:56:33
From: Kingy
ID: 1919382
Subject: re: Programming languages

dv said:


Kingy said:

Python is my first preference, but it doesn’t seem to play nicely with arrays on win7, and arrays are what I want to play with.

Well that’s weird but yeah the solution is to sort out your environment issues and still use Python…

I need “numpy” to use arrays, and I can’t import numpy until I install “Anaconda” which needs Win8 or above, or “Pip” and I wasted most of yesterday arvo trying to get that working.

Should I uninstall the lot and try installing Pip first?

Reply Quote

Date: 10/08/2022 14:59:47
From: Woodie
ID: 1919383
Subject: re: Programming languages

Kingy said:


I have been trying to install a free programming language on Win7 so that I can keep my skills up, but it appears to be much harder to install one than to actually write programs.

Python is my first preference, but it doesn’t seem to play nicely with arrays on win7, and arrays are what I want to play with.

I tried C++ and created a few arrays and populated them with data, but I couldn’t get it to display the contents of the array as coloured pixels in a window.

Yesterday in desperation, I tried FreeBasic. Also way too hard to install and run a “Hello World” program.

Each one of these took at least a day wasted just trying to do a simple task.

Can anyone suggest a free package that allows me to write a program to create a (X * Y) array, randomise the contents, and display that array as coloured pixels in a separate window, with a menu bar at the top?

Some people have just way too much time on their hands, hey what but.

How bout you try basket weaving instead. Much more productive.

Reply Quote

Date: 10/08/2022 14:59:54
From: sibeen
ID: 1919384
Subject: re: Programming languages

Kingy said:


dv said:

Kingy said:

Python is my first preference, but it doesn’t seem to play nicely with arrays on win7, and arrays are what I want to play with.

Well that’s weird but yeah the solution is to sort out your environment issues and still use Python…

I need “numpy” to use arrays, and I can’t import numpy until I install “Anaconda” which needs Win8 or above, or “Pip” and I wasted most of yesterday arvo trying to get that working.

Should I uninstall the lot and try installing Pip first?

Why wouldn’t you upgrade windows?

Reply Quote

Date: 10/08/2022 15:05:39
From: The Rev Dodgson
ID: 1919386
Subject: re: Programming languages

Kingy said:


dv said:

Kingy said:

Python is my first preference, but it doesn’t seem to play nicely with arrays on win7, and arrays are what I want to play with.

Well that’s weird but yeah the solution is to sort out your environment issues and still use Python…

I need “numpy” to use arrays, and I can’t import numpy until I install “Anaconda” which needs Win8 or above, or “Pip” and I wasted most of yesterday arvo trying to get that working.

Should I uninstall the lot and try installing Pip first?

I’ve found Anaconda a PitA. Yes, I’d suggest uninstalling then install Numpy with pip.

Reply Quote

Date: 10/08/2022 15:07:21
From: Tamb
ID: 1919387
Subject: re: Programming languages

sibeen said:


Kingy said:

dv said:

Well that’s weird but yeah the solution is to sort out your environment issues and still use Python…

I need “numpy” to use arrays, and I can’t import numpy until I install “Anaconda” which needs Win8 or above, or “Pip” and I wasted most of yesterday arvo trying to get that working.

Should I uninstall the lot and try installing Pip first?

Why wouldn’t you upgrade windows?


While all you clever people are here I have two computer problems which I can’t seem to resolve.
1) How do I exclude a word in a Bing search.
2) My old Vista machine shows that the alternate drive contains about 8GB of data which I can’t access.
Any help would be appreciated.

Reply Quote

Date: 10/08/2022 15:08:15
From: The Rev Dodgson
ID: 1919388
Subject: re: Programming languages

The Rev Dodgson said:


Kingy said:

dv said:

Well that’s weird but yeah the solution is to sort out your environment issues and still use Python…

I need “numpy” to use arrays, and I can’t import numpy until I install “Anaconda” which needs Win8 or above, or “Pip” and I wasted most of yesterday arvo trying to get that working.

Should I uninstall the lot and try installing Pip first?

I’ve found Anaconda a PitA. Yes, I’d suggest uninstalling then install Numpy with pip.

Or save yourself the trouble and use VBA from Excel :)

Reply Quote

Date: 10/08/2022 15:08:24
From: dv
ID: 1919389
Subject: re: Programming languages

Is there a reason you’re wedded to win7?

Reply Quote

Date: 10/08/2022 15:10:15
From: dv
ID: 1919390
Subject: re: Programming languages

Tamb said:


sibeen said:

Kingy said:

I need “numpy” to use arrays, and I can’t import numpy until I install “Anaconda” which needs Win8 or above, or “Pip” and I wasted most of yesterday arvo trying to get that working.

Should I uninstall the lot and try installing Pip first?

Why wouldn’t you upgrade windows?


While all you clever people are here I have two computer problems which I can’t seem to resolve.
1) How do I exclude a word in a Bing search.
2) My old Vista machine shows that the alternate drive contains about 8GB of data which I can’t access.
Any help would be appreciated.

https://answers.microsoft.com/en-us/bing/forum/all/exclude-word-or-phrase-in-bing-search/4f74626b-3b1f-4a67-aea3-94267e27e3b8

Reply Quote

Date: 10/08/2022 15:15:54
From: Kingy
ID: 1919393
Subject: re: Programming languages

dv said:


Is there a reason you’re wedded to win7?

To upgrade costs time and money. I already have a nicely setup Win7 desktop system that has everything I need on it. I just want to do some programming, like I used to do 35 years ago on a 256kb 286.

I mistakenly assumed that it would be easier to achieve by now.

Reply Quote

Date: 10/08/2022 15:18:06
From: Tamb
ID: 1919394
Subject: re: Programming languages

dv said:


Tamb said:

sibeen said:

Why wouldn’t you upgrade windows?


While all you clever people are here I have two computer problems which I can’t seem to resolve.
1) How do I exclude a word in a Bing search.
2) My old Vista machine shows that the alternate drive contains about 8GB of data which I can’t access.
Any help would be appreciated.

https://answers.microsoft.com/en-us/bing/forum/all/exclude-word-or-phrase-in-bing-search/4f74626b-3b1f-4a67-aea3-94267e27e3b8


It worked. Thanks. I was unsuccessfully trying the – operator.

Reply Quote

Date: 10/08/2022 16:03:08
From: furious
ID: 1919404
Subject: re: Programming languages

Kingy said:


dv said:

Is there a reason you’re wedded to win7?

To upgrade costs time and money. I already have a nicely setup Win7 desktop system that has everything I need on it. I just want to do some programming, like I used to do 35 years ago on a 256kb 286.

I mistakenly assumed that it would be easier to achieve by now.

Get a raspberry pi…

Reply Quote

Date: 10/08/2022 16:04:28
From: Cymek
ID: 1919405
Subject: re: Programming languages

furious said:


Kingy said:

dv said:

Is there a reason you’re wedded to win7?

To upgrade costs time and money. I already have a nicely setup Win7 desktop system that has everything I need on it. I just want to do some programming, like I used to do 35 years ago on a 256kb 286.

I mistakenly assumed that it would be easier to achieve by now.

Get a raspberry pi…

Get SWMBO to make one

Reply Quote

Date: 10/08/2022 16:05:00
From: Spiny Norman
ID: 1919406
Subject: re: Programming languages

Can’t use Visual Studio Code or Atom or maybe Arduino IDE?

Reply Quote

Date: 10/08/2022 16:11:27
From: Spiny Norman
ID: 1919408
Subject: re: Programming languages

Spiny Norman said:


Can’t use Visual Studio Code or Atom or maybe Arduino IDE?

VSC & Atom have C++ & Python extensions, not sure about Arduino IDE.

Reply Quote

Date: 10/08/2022 16:13:15
From: Woodie
ID: 1919409
Subject: re: Programming languages

Spiny Norman said:


Can’t use Visual Studio Code or Atom or maybe Arduino IDE?

I’ve done heaps of stuff with Picaxe.

Operating signals with detectors on the train layout.

Working boom gates and flashing lights with ding ding ding ding ding as well. All fully automated.😁🚂🚂🚂

Reply Quote

Date: 10/08/2022 16:18:53
From: Spiny Norman
ID: 1919411
Subject: re: Programming languages

Woodie said:


Spiny Norman said:

Can’t use Visual Studio Code or Atom or maybe Arduino IDE?

I’ve done heaps of stuff with Picaxe.

Operating signals with detectors on the train layout.

Working boom gates and flashing lights with ding ding ding ding ding as well. All fully automated.😁🚂🚂🚂

Sweeeeet.
I’m making an ozone sniffer. Got it working last week, now I need to work out how to display the data on a small screen.

Reply Quote

Date: 10/08/2022 16:20:37
From: Kingy
ID: 1919413
Subject: re: Programming languages

Spiny Norman said:


Can’t use Visual Studio Code or Atom or maybe Arduino IDE?

I got VSC running Python, and did a few test programs. Then I tried arrays and found that I needed numpy, which is where the problems started. Apparently it’s easier if you have Win10, but with only Win7, the various installers won’t work.

Reply Quote

Date: 10/08/2022 16:23:02
From: Spiny Norman
ID: 1919415
Subject: re: Programming languages

Kingy said:


Spiny Norman said:

Can’t use Visual Studio Code or Atom or maybe Arduino IDE?

I got VSC running Python, and did a few test programs. Then I tried arrays and found that I needed numpy, which is where the problems started. Apparently it’s easier if you have Win10, but with only Win7, the various installers won’t work.

Weird.
I must say for an expert hacker you’re not going well with this mate.

Reply Quote

Date: 10/08/2022 16:23:49
From: sibeen
ID: 1919417
Subject: re: Programming languages

Spiny Norman said:


Kingy said:

Spiny Norman said:

Can’t use Visual Studio Code or Atom or maybe Arduino IDE?

I got VSC running Python, and did a few test programs. Then I tried arrays and found that I needed numpy, which is where the problems started. Apparently it’s easier if you have Win10, but with only Win7, the various installers won’t work.

Weird.
I must say for an expert hacker you’re not going well with this mate.

ROFL

Reply Quote

Date: 10/08/2022 16:25:19
From: dv
ID: 1919419
Subject: re: Programming languages

Reply Quote

Date: 10/08/2022 16:29:30
From: Spiny Norman
ID: 1919422
Subject: re: Programming languages

The World’s Greatest Hacker

Reply Quote

Date: 10/08/2022 16:31:47
From: The Rev Dodgson
ID: 1919425
Subject: re: Programming languages

Spiny Norman said:


Kingy said:

Spiny Norman said:

Can’t use Visual Studio Code or Atom or maybe Arduino IDE?

I got VSC running Python, and did a few test programs. Then I tried arrays and found that I needed numpy, which is where the problems started. Apparently it’s easier if you have Win10, but with only Win7, the various installers won’t work.

Weird.
I must say for an expert hacker you’re not going well with this mate.

No doubt it’s all part of his cunning plan.

Reply Quote

Date: 10/08/2022 17:30:26
From: mollwollfumble
ID: 1919440
Subject: re: Programming languages

Kingy said:


I have been trying to install a free programming language on Win7 so that I can keep my skills up, but it appears to be much harder to install one than to actually write programs.

Python is my first preference, but it doesn’t seem to play nicely with arrays on win7, and arrays are what I want to play with.

I tried C++ and created a few arrays and populated them with data, but I couldn’t get it to display the contents of the array as coloured pixels in a window.

Yesterday in desperation, I tried FreeBasic. Also way too hard to install and run a “Hello World” program.

Each one of these took at least a day wasted just trying to do a simple task.

Can anyone suggest a free package that allows me to write a program to create a (X * Y) array, randomise the contents, and display that array as coloured pixels in a separate window, with a menu bar at the top?

Sorry, Kingy. I’ve given up on programming in Win7.

Nowdays I do all my programming on Linux, where it is so much easier.

> Can anyone suggest a free package that allows me to write a program to create a (X * Y) array, randomise the contents, and display that array as coloured pixels in a separate window, with a menu bar at the top?

The last time I managed to that in Win7 was using Java 1.0. Java doesn’t like 2-D arrays, so I had to loop over 1-D arrays to do it.

Reply Quote

Date: 10/08/2022 22:30:18
From: SCIENCE
ID: 1919492
Subject: re: Programming languages

Kingy said:

SCIENCE said:

do you mind if it runs in a browser

Not really, as long as the code is portable.

how portable, like JavaScript is pretty much the same across all popular decent modern browsers

Reply Quote

Date: 11/08/2022 06:37:19
From: SCIENCE
ID: 1919535
Subject: re: Programming languages

Kingy said:

Can anyone suggest a free package that allows me to write a program to create a (X * Y) array, randomise the contents, and display that array as coloured pixels in a separate window, with a menu bar at the top?

We suggest a text editor such as NOTEPAD.EXE and a modern browser such as Mozilla Firefox or Google Chrome.

Shortly we will contribute a listing for a program that does some of the above requested, with the following interpretations:

Note that we did not include buffering in our code here, and pixel manipulation in HTML5Canvas was inefficient last time we checked some years ago.

Reply Quote

Date: 11/08/2022 06:42:50
From: SCIENCE
ID: 1919536
Subject: re: Programming languages

SCIENCE said:

We suggest a program that does some of the above requested, with the following interpretations:

  • the array will be a XY block rather than true multidimensional array of arrays
  • the pixels will be in a canvas on a page
  • the menu bar at the top will be that of the browser, but as you know, any other content may be included in the HTML at the discretion of the coder.

Note that we did not include buffering in our code here, and pixel manipulation in HTML5Canvas was inefficient last time we checked some years ago.

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<canvas id="c" width="10" height="10" style="width: 100px; image-rendering: pixelated;"></canvas>
<script type="application/javascript" ><!--
"use strict";

var attachInterface;

attachInterface = function (CanvasID) {
 var _;

 _ = {
  el: document.getElementById(CanvasID),
  c: null,
  getpixel: function (x, y) {
   return this.c.getImageData(x, y, 1, 1).data;
  },
  putpixel: function (x, y, r, g, b) {
   var id, d;
   d = (id = this.c.getImageData(x, y, 1, 1)).data;
   d[0] = r;
   d[1] = g;
   d[2] = b;
   d[3] = 255;
   this.c.putImageData(id, x, y);
  },
  rect: function (x1, y1, x2, y2, r, g, b) {
   var id, d;
   var n, N;
   var x, y;
   x = (x1 < x2? x1: x2);
   y = (y1 < y2? y1: y2);
   d = (id = this.c.getImageData(x, y, (x1 > x2? x1 - x: x2 - x) + 1, (y1 > y2? y1 - y: y2 - y) + 1)).data;
   N = d.length;
   for (n = 0; n < N; n += 4) {
    d[n] = r;
   }
   for (n = 1; n < N; n += 4) {
    d[n] = g;
   }
   for (n = 2; n < N; n += 4) {
    d[n] = b;
   }
   for (n = 3; n < N; n += 4) {
    d[n] = 255;
   }
   this.c.putImageData(id, x, y);
  },

  _: null
 };
 _.c = _.el.getContext("2d");

 return _;
};

var cp;
var x, y, a;
cp = attachInterface("c");
a = [];
for (y = 0; y < 10; y++) {
 for (x = 0; x < 10; x++) {
  a[x + 10 * y] = Math.random();
 }
}
cp.rect(0, 0, 10, 10, 0,0,0);
for (y = 0; y < 10; y++) {
 for (x = 0; x < 10; x++) {
  cp.putpixel(x, y, Math.floor(a[x + 10 * y] * 255), Math.floor(a[x + 10 * y] * 255), Math.floor(a[x + 10 * y] * 255));
 }
}

//--></script>
</body>
</html>
Reply Quote

Date: 11/08/2022 14:01:09
From: Kingy
ID: 1919661
Subject: re: Programming languages

Thank you kind sir, that is a great help and I shall start learning javascript and make the appropriate modifications in order to achieve what I wanted.

Reply Quote

Date: 11/08/2022 20:13:10
From: SCIENCE
ID: 1919781
Subject: re: Programming languages

must be the Alt-F4 of the times

Reply Quote

Date: 11/08/2022 21:37:25
From: Kingy
ID: 1919789
Subject: re: Programming languages

It took me several hours to get my head around javascript, but I have managed to modify the original program to create a box with a blue border, a sine wave of colours across it, and a modified randomiser effect.
Tomorrow I’ll try to increase the size and change the colour effects.

Reply Quote

Date: 11/08/2022 21:54:30
From: SCIENCE
ID: 1919793
Subject: re: Programming languages

Kingy said:

It took me several hours to get my head around javascript, but I have managed to modify the original program to create a box with a blue border, a sine wave of colours across it, and a modified randomiser effect.
Tomorrow I’ll try to increase the size and change the colour effects.

nice one, we’ll try to strip out the best of our double buffering code so it will actually run at a decent speed, you may find that necessary when you increase the size

Reply Quote

Date: 11/08/2022 21:59:48
From: The Rev Dodgson
ID: 1919794
Subject: re: Programming languages

SCIENCE said:

Kingy said:

It took me several hours to get my head around javascript, but I have managed to modify the original program to create a box with a blue border, a sine wave of colours across it, and a modified randomiser effect.
Tomorrow I’ll try to increase the size and change the colour effects.

nice one, we’ll try to strip out the best of our double buffering code so it will actually run at a decent speed, you may find that necessary when you increase the size

Not sure if this will be of interest if everybody is off doing Javascript, but here are some examples of graphics generated with Python code (connected to Excel, but you don’t have to do that if you dont want to):

Computing and plotting the Mandelbrot set in Excel

Plotting Mandelbrot in Excel with Matplotlib

Reply Quote

Date: 12/08/2022 21:24:56
From: Kingy
ID: 1920131
Subject: re: Programming languages

The Rev Dodgson said:


SCIENCE said:

Kingy said:

It took me several hours to get my head around javascript, but I have managed to modify the original program to create a box with a blue border, a sine wave of colours across it, and a modified randomiser effect.
Tomorrow I’ll try to increase the size and change the colour effects.

nice one, we’ll try to strip out the best of our double buffering code so it will actually run at a decent speed, you may find that necessary when you increase the size

Not sure if this will be of interest if everybody is off doing Javascript, but here are some examples of graphics generated with Python code (connected to Excel, but you don’t have to do that if you dont want to):

Computing and plotting the Mandelbrot set in Excel

Plotting Mandelbrot in Excel with Matplotlib

Interesting that you have mentioned the Mandelbrot set.

I got myself into a lot of shit in the 80’s at Uni when I wrote a program to calculate the Mandelbrot.

The university 80286 that I was using was way too slow, so I “borrowed” some processor time from every other computer on the network, and left it to calculate the numbers overnight.

When I arrived at Uni next day, I was called into the Sysadmins office. He was not amused. My program had accidentally taken over the 80286 that ran all of the admin and payroll. None of the staff got paid that day. :(

They did get paid the next day. :)

My Mandelbrot set did do a small zoom, but I wasn’t allowed to do another one.

Reply Quote

Date: 12/08/2022 21:34:14
From: The Rev Dodgson
ID: 1920136
Subject: re: Programming languages

Kingy said:


The Rev Dodgson said:

SCIENCE said:

nice one, we’ll try to strip out the best of our double buffering code so it will actually run at a decent speed, you may find that necessary when you increase the size

Not sure if this will be of interest if everybody is off doing Javascript, but here are some examples of graphics generated with Python code (connected to Excel, but you don’t have to do that if you dont want to):

Computing and plotting the Mandelbrot set in Excel

Plotting Mandelbrot in Excel with Matplotlib

Interesting that you have mentioned the Mandelbrot set.

I got myself into a lot of shit in the 80’s at Uni when I wrote a program to calculate the Mandelbrot.

The university 80286 that I was using was way too slow, so I “borrowed” some processor time from every other computer on the network, and left it to calculate the numbers overnight.

When I arrived at Uni next day, I was called into the Sysadmins office. He was not amused. My program had accidentally taken over the 80286 that ran all of the admin and payroll. None of the staff got paid that day. :(

They did get paid the next day. :)

My Mandelbrot set did do a small zoom, but I wasn’t allowed to do another one.

I had no idea you were such a computer nerd. :)

But the increase in computing power available to everyone with a few hundred dollars to spare is indeed amazing.

Reply Quote

Date: 12/08/2022 21:54:47
From: Kingy
ID: 1920155
Subject: re: Programming languages

This is as far as I have got this morning.

I can’t work out why the event.Listener wont stop and accept the result before it continues.




<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Island Maker</title>
<style><br /> html { font-family: sans-serif;}<br /> body { width:50%; max-width: 800px; min-width: 480px; margin: 0 auto; } .form input{ width: 200px; } .lastResult { color: white; padding: 3px; }</p> <p></style>

Island Maker(The basics)


<script type="application/javascript"><!&#8212;<br /> &#8220;use strict&#8221;;</p> <p>var height = document.querySelector(&#8220;.height&#8221;);<br /> var optionSubmit = document.querySelector(&#8220;.optionSubmit&#8221;);</p> <p>function checkOption(){<br /> var height = Number(optionField.value);</p> <p>optionSubmit.addEventListener(&#8216;click&#8217;, checkOption);</p> <p>//alert(height);<br /> }</p> <p>checkOption();</p> <p>// Draws squares?</p> <p>var attachInterface;</p> <p>attachInterface = function (CanvasID) { var _;</p> _ = { el: document.getElementById(CanvasID), c: null, getpixel: function (x, y) { return this.c.getImageData(x, y, 1, 1).data; }, putpixel: function (x, y, r, g, b) { var id, d; d = (id = this.c.getImageData(x, y, 1, 1)).data; d = r; d = g; d = b; d = 255; this.c.putImageData(id, x, y); }, rect: function (x1, y1, x2, y2, r, g, b) { var id, d; var n, N; var x, y; x = (x1 < x2? x1: x2); y = (y1 < y2? y1: y2); d = (id = this.c.getImageData(x, y, (x1 > x2? x1 &#8211; x: x2 &#8211; x) + 1, (y1 > y2? y1 &#8211; y: y2 &#8211; y) + 1)).data; N = d.length; for (n = 0; n < N; n += 4) { d = r; } for (n = 1; n < N; n += 4) { d = g; } for (n = 2; n < N; n += 4) { d = b; } for (n = 3; n < N; n += 4) { d = 255; } this.c.putImageData(id, x, y); }, _: null }; _.c = _.el.getContext(&#8220;2d&#8221;); return _; }; <p>/* Populates 3 &#8220;size&#8221; by &#8220;size&#8221; arrays with R G B values */</p> <p>var cp;<br /> var x, y, a, aa, aaa, pie, size, rads;<br /> cp = attachInterface(&#8220;c&#8221;);<br /> a = <br /> aa = <br /> aaa = <br /> pie = 3.14159268<br /> size = 40<br /> rads = 40<br /> height = 1.8;<br /> for (y = 0; y < size; y++) { for (x = 0; x < size; x++) {</p> <p>// Starting <span class="caps">RGB</span> values of each pixel a = (((Math.sin(pie*(x/rads)))+(Math.sin(pie*(y/rads))))/height)-0.5 aa = (((Math.sin(pie*(x/rads)))+(Math.sin(pie*(y/rads))))/height)-0.5 aaa = (((Math.sin(pie*(x/rads)))+(Math.sin(pie*(y/rads))))/height)-0.5</p> <p>// Creates blue border if (((x < 1) || (x > (size-2))) || ((y < 1)) || (y > (size-2))) { a = 0 aa = 0.2 aaa = 0.8 }; }<br /> }</p> <p>//Test Text<br /> // <button>Hello</button><br /> // Const btn = document.querySelector(&#8216;button&#8217;);<br /> // btn.addEventListener(&#8216;click&#8217;, () => {<br /> // Do This;<br /> // });</p> <p>//While hasn&#8217;t clicked exit</p> <p>//Await button click</p> <p>/* Draws &#8220;size&#8221; by &#8220;size&#8221; square with colours from above code */</p> <p>cp.rect(0, 0, size, size, 0,0,0);<br /> for (y = 0; y < size; y++) { for (x = 0; x < size; x++) { cp.putpixel(x, y, Math.floor(a * 255), Math.floor(aa * 255), Math.floor(aaa * 255)); }<br /> }</p> <p>//&#8212;></script>


Reply Quote

Date: 12/08/2022 21:57:40
From: Kingy
ID: 1920158
Subject: re: Programming languages

That wasn’t what I was expecting to happen.

Reply Quote

Date: 12/08/2022 22:05:06
From: The Rev Dodgson
ID: 1920161
Subject: re: Programming languages

Kingy said:


That wasn’t what I was expecting to happen.

Nobody expects the Spanish incodelisting.

Reply Quote

Date: 12/08/2022 22:17:19
From: SCIENCE
ID: 1920165
Subject: re: Programming languages

Kingy said:


This is as far as I have got this morning.

I can’t work out why the event.Listener wont stop and accept the result before it continues.


<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Island Maker</title>
<style>
html { font-family: sans-serif;}
body {
  width:50%;
  max-width: 800px;
  min-width: 480px;
  margin: 0 auto;
 }
   .form input[type="number"]{
   width: 200px;
 }
   .lastResult {
   color: white;
   padding: 3px;
 }

</style>
</head>
<body>

<h1>Island Maker(The basics)</h1>

<div class="form">
<label for="optionField">Select a height: </label>
<input type="number" min="1" max="10" required id="optionField" class="optionField">
<input type="submit" value="Submit Height" class="optionSubmit">
</div>

<div class="resultParas">
 <p class="height"></p>
 </div>


<canvas id="c" width="40" height="40" style="width: 400px; image-rendering: pixelated;"></canvas>
<script type="application/javascript" ><!--
"use strict";

var height = document.querySelector(".height");
var optionSubmit = document.querySelector(".optionSubmit");

function checkOption(){
var height = Number(optionField.value);

optionSubmit.addEventListener('click', checkOption);

//alert(height);
}

checkOption();

// Draws squares?

var attachInterface;

attachInterface = function (CanvasID) {
 var _;

 _ = {
  el: document.getElementById(CanvasID),
  c: null,
  getpixel: function (x, y) {
   return this.c.getImageData(x, y, 1, 1).data;
  },

  putpixel: function (x, y, r, g, b) {
   var id, d;
   d = (id = this.c.getImageData(x, y, 1, 1)).data;
   d[0] = r;
   d[1] = g;
   d[2] = b;
   d[3] = 255;
   this.c.putImageData(id, x, y);
  },
  rect: function (x1, y1, x2, y2, r, g, b) {
   var id, d;
   var n, N;
   var x, y;
   x = (x1 < x2? x1: x2);
   y = (y1 < y2? y1: y2);
   d = (id = this.c.getImageData(x, y, (x1 > x2? x1 - x: x2 - x) + 1, (y1 > y2? y1 - y: y2 - y) + 1)).data;
   N = d.length;
   for (n = 0; n < N; n += 4) {
    d[n] = r;
   }
   for (n = 1; n < N; n += 4) {
    d[n] = g;
   }
   for (n = 2; n < N; n += 4) {
    d[n] = b;
   }
   for (n = 3; n < N; n += 4) {
    d[n] = 255;
   }
   this.c.putImageData(id, x, y);
  },

  _: null
 };
 _.c = _.el.getContext("2d");

 return _;
};

/* Populates 3 "size" by "size" arrays with R G B values */


var cp;
var x, y, a, aa, aaa, pie, size, rads;
cp = attachInterface("c");
a = []
aa = []
aaa = []
pie = 3.14159268
size = 40
rads = 40
height = 1.8;
for (y = 0; y < size; y++) {
 for (x = 0; x < size; x++) {

// Starting RGB values of each pixel
  a[x + size * y] = (((Math.sin(pie*(x/rads)))+(Math.sin(pie*(y/rads))))/height)-0.5
  aa[x + size * y] = (((Math.sin(pie*(x/rads)))+(Math.sin(pie*(y/rads))))/height)-0.5
  aaa[x + size * y] = (((Math.sin(pie*(x/rads)))+(Math.sin(pie*(y/rads))))/height)-0.5
 
// Creates blue border
  if (((x < 1) || (x > (size-2))) || ((y < 1)) || (y > (size-2))) {
         a[x + size * y] = 0
         aa[x + size * y] = 0.2 
         aaa[x + size * y] = 0.8
  };
 }
}

//Test Text
// <button>Hello</button>
// Const btn = document.querySelector('button');
// btn.addEventListener('click', () => {
// Do This;
// });

//While hasn't clicked exit

//Await button click

/* Draws "size" by "size" square with colours from above code */

cp.rect(0, 0, size, size, 0,0,0);
for (y = 0; y < size; y++) {
 for (x = 0; x < size; x++) {
  cp.putpixel(x, y, Math.floor(a[x + size * y] * 255), Math.floor(aa[x + size * y] * 255), Math.floor(aaa[x + size * y] * 255));
 }
}


//--></script>

</body>
</html> 

oh yeah that happens if you paste HTML directly into the box, it says HTML markup allowed so we had to write another bit of code to convert it all to entities

we’ll have a look in a bit

Reply Quote

Date: 12/08/2022 22:23:27
From: SCIENCE
ID: 1920167
Subject: re: Programming languages

SCIENCE said:

it says HTML markup allowed so we had to write another bit of code to convert it all to entities

here’s what we wrote to help, you can save it to HTML file to acquire the functionality yourself


<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title></title></head><body>
<h1>Prepare code for <a href="https://tokyo3.org/forums/holiday/">https://tokyo3.org/forums/holiday/</a> display.</h1>
<div>
<textarea id="i" cols="80" rows="25">Put code to entitise here.</textarea>
<textarea id="o" cols="80" rows="25"></textarea>
</div>
<div>
</div>
<div id="f">
</div>
<script type="text/javascript"><!--
"use strict";
(function () {
 document.getElementById("i").focus();
 document.getElementById("o").addEventListener("focus", function () {
  var i, n, o = "";
  i = document.getElementById("i").value;
  for (n = 0; n < i.length; n++) {
   switch (i[n]) {
    case " ": case "\xA0": {
     o += "&nbsp;";
    } break;
    case "\r": case "\n": {
     o += "<br>\n";
    } break;
    default: {
     o += "&#x" + i.charCodeAt(n).toString(16) + ";";
    }
   }
  }
  document.getElementById("o").value = "<div style=\"font-family: Consolas, Lucida Console, Courier New, monospace;\">\n" + o + "\n</div>\n";
  document.getElementById("f").innerHTML = "<div style=\"font-family: Consolas, Lucida Console, Courier New, monospace;\">\n" + o + "\n</div>\n";
  document.getElementById("o").select();
 }, false);
})();
//--></script>
</body></html>


originally we were going to post it to https://tokyo3.org/forums/holiday/topics/14973/ and say

we’ve made ourselves a code packaging application to let us smuggle code into display for your viewing pleasure (curing the whitespace problem) so in future we’ll be able to respond to any other computational exercises in a more aesthetically appealing fashion

but the thread got left behind

Reply Quote

Date: 12/08/2022 23:24:16
From: SCIENCE
ID: 1920197
Subject: re: Programming languages

SCIENCE said:

Kingy said:

This is as far as I have got this morning.

I can’t work out why the event.Listener wont stop and accept the result before it continues.


<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Island Maker</title>
<style>
html { font-family: sans-serif;}
body {
  width:50%;
  max-width: 800px;
  min-width: 480px;
  margin: 0 auto;
 }
   .form input[type="number"]{
   width: 200px;
 }
   .lastResult {
   color: white;
   padding: 3px;
 }

</style>
</head>
<body>

<h1>Island Maker(The basics)</h1>

<div class="form">
<label for="optionField">Select a height: </label>
<input type="number" min="1" max="10" required id="optionField" class="optionField">
<input type="submit" value="Submit Height" class="optionSubmit">
</div>

<div class="resultParas">
 <p class="height"></p>
 </div>


<canvas id="c" width="40" height="40" style="width: 400px; image-rendering: pixelated;"></canvas>
<script type="application/javascript" ><!--
"use strict";

var height = document.querySelector(".height");
var optionSubmit = document.querySelector(".optionSubmit");

function checkOption(){
var height = Number(optionField.value);

optionSubmit.addEventListener('click', checkOption);

//alert(height);
}

checkOption();

// Draws squares?

var attachInterface;

attachInterface = function (CanvasID) {
 var _;

 _ = {
  el: document.getElementById(CanvasID),
  c: null,
  getpixel: function (x, y) {
   return this.c.getImageData(x, y, 1, 1).data;
  },

  putpixel: function (x, y, r, g, b) {
   var id, d;
   d = (id = this.c.getImageData(x, y, 1, 1)).data;
   d[0] = r;
   d[1] = g;
   d[2] = b;
   d[3] = 255;
   this.c.putImageData(id, x, y);
  },
  rect: function (x1, y1, x2, y2, r, g, b) {
   var id, d;
   var n, N;
   var x, y;
   x = (x1 < x2? x1: x2);
   y = (y1 < y2? y1: y2);
   d = (id = this.c.getImageData(x, y, (x1 > x2? x1 - x: x2 - x) + 1, (y1 > y2? y1 - y: y2 - y) + 1)).data;
   N = d.length;
   for (n = 0; n < N; n += 4) {
    d[n] = r;
   }
   for (n = 1; n < N; n += 4) {
    d[n] = g;
   }
   for (n = 2; n < N; n += 4) {
    d[n] = b;
   }
   for (n = 3; n < N; n += 4) {
    d[n] = 255;
   }
   this.c.putImageData(id, x, y);
  },

  _: null
 };
 _.c = _.el.getContext("2d");

 return _;
};

/* Populates 3 "size" by "size" arrays with R G B values */


var cp;
var x, y, a, aa, aaa, pie, size, rads;
cp = attachInterface("c");
a = []
aa = []
aaa = []
pie = 3.14159268
size = 40
rads = 40
height = 1.8;
for (y = 0; y < size; y++) {
 for (x = 0; x < size; x++) {

// Starting RGB values of each pixel
  a[x + size * y] = (((Math.sin(pie*(x/rads)))+(Math.sin(pie*(y/rads))))/height)-0.5
  aa[x + size * y] = (((Math.sin(pie*(x/rads)))+(Math.sin(pie*(y/rads))))/height)-0.5
  aaa[x + size * y] = (((Math.sin(pie*(x/rads)))+(Math.sin(pie*(y/rads))))/height)-0.5
 
// Creates blue border
  if (((x < 1) || (x > (size-2))) || ((y < 1)) || (y > (size-2))) {
         a[x + size * y] = 0
         aa[x + size * y] = 0.2 
         aaa[x + size * y] = 0.8
  };
 }
}

//Test Text
// <button>Hello</button>
// Const btn = document.querySelector('button');
// btn.addEventListener('click', () => {
// Do This;
// });

//While hasn't clicked exit

//Await button click

/* Draws "size" by "size" square with colours from above code */

cp.rect(0, 0, size, size, 0,0,0);
for (y = 0; y < size; y++) {
 for (x = 0; x < size; x++) {
  cp.putpixel(x, y, Math.floor(a[x + size * y] * 255), Math.floor(aa[x + size * y] * 255), Math.floor(aaa[x + size * y] * 255));
 }
}


//--></script>

</body>
</html> 

oh yeah that happens if you paste HTML directly into the box, it says HTML markup allowed so we had to write another bit of code to convert it all to entities

we’ll have a look in a bit

This bit

function checkOption(){
var height = Number(optionField.value);

optionSubmit.addEventListener('click', checkOption);

//alert(height);
}

checkOption();

doesn’t look quite right, suggest

function checkOption(){
 var height = Number(optionField.value);
 alert(height);
}
optionSubmit.addEventListener('click', checkOption);

instead.

Reply Quote

Date: 13/08/2022 01:55:15
From: SCIENCE
ID: 1920229
Subject: re: Programming languages

SCIENCE said:

Kingy said:

It took me several hours to get my head around javascript, but I have managed to modify the original program to create a box with a blue border, a sine wave of colours across it, and a modified randomiser effect.
Tomorrow I’ll try to increase the size and change the colour effects.

nice one, we’ll try to strip out the best of our double buffering code so it will actually run at a decent speed, you may find that necessary when you increase the size

here you go we copied the double buffering code out from some of our existing libraries and it is delivered below

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=0.5, maximum-scale=2, user-scalable=no" />
<title></title>
</head>
<body>
<canvas id="c" width="100" height="100" style="width: 100px; image-rendering: pixelated;"></canvas>
<script type="application/javascript" ><!--
"use strict";

var attachInterface;

attachInterface = function (CanvasID) {
 var _;

 _ = {
  el: document.getElementById(CanvasID),
  c: null,
  b: null,
  d: null,
  width: 0,
  height: 0,
  getpixel: function (x, y) {
   var o;
   o = 4 * (this.width * y + x);
   return [this.d[o + 0], this.d[o + 1], this.d[o + 2], this.d[o + 3]];
  },
  putpixel: function (x, y, r, g, b) {
   var o;
   o = 4 * (this.width * y + x);
   this.d[o + 0] = r;
   this.d[o + 1] = g;
   this.d[o + 2] = b;
   this.d[o + 3] = 255;
  },
  rect: function (x1, y1, x2, y2, r, g, b) {
   var n;
   var x, y;
   (x2 < x1) && ([x1, x2] = [x2, x1]);
   (y2 < y1) && ([y1, y2] = [y2, y1]);
   for (y = y1; y <= y2; y++) {
    n = 4 * (this.width * y + x1);
    for (x = x1; x <= x2; x++) {
     this.d[n + 0] = r;
     this.d[n + 1] = g;
     this.d[n + 2] = b;
     this.d[n + 3] = 255;
     n += 4;
    }
   }
  },
  draw: function () {
   this.c.putImageData(this.b, 0, 0);
  },
  _: null
 };
 _.c = _.el.getContext("2d");
 _.b = _.c.getImageData(0, 0, _.el.width, _.el.height);
 _.d = _.b.data;
 [_.width, _.height] = [_.el.width, _.el.height];
 return _;
};



var cp;
var x, y, a;
cp = attachInterface("c");
a = [];
for (y = 0; y < 100; y++) {
 for (x = 0; x < 100; x++) {
  a[x + 100 * y] = Math.random();
 }
}
cp.rect(0, 0, 100, 100, 0,0,255);
for (y = 0; y < 100; y++) {
 for (x = 0; x < 100; x++) {
  cp.putpixel(x, y, Math.floor(a[x + 100 * y] * 255), Math.floor(a[x + 100 * y] * 255), Math.floor(a[x + 100 * y] * 255));
 }
}
cp.draw();

//--></script>
</body>
</html>

note the main difference is that you will need to use the draw() function to update the display

Reply Quote

Date: 23/03/2023 10:08:47
From: SCIENCE
ID: 2011337
Subject: re: Programming languages

in the interest of completeness

a HTML contained JS powered utility for posting code in a readable format

simply paste our code into a file and open it as HTML in your JS enabled browser (easiest if you give it a HTML type extension when saved), and you too will have the power

<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>code for https://tokyo3.org/forums/holiday/</title></head><body>
<h1>code for <a href="https://tokyo3.org/forums/holiday/">https://tokyo3.org/forums/holiday/</a></h1>
<div>
<textarea id="i" cols="80" rows="25">paste code here to cure the whitespace problem, then select the output from the other box to copy and paste it to forum</textarea>
<textarea id="o" cols="80" rows="25"></textarea>
</div>
<div id="f">
</div>
<script type="text/javascript"><!--
"use strict";
(function () {
 document.getElementById("i").focus();
 document.getElementById("o").addEventListener("focus", function () {
  var i, n, o = "";
  i = document.getElementById("i").value;
  for (n = 0; n < i.length; n++) {
   switch (i[n]) {
    case " ": case "\xA0": {
     o += "&nbsp;";
    } break;
    case "\r": case "\n": {
     o += "<br>\n";
    } break;
    default: {
     o += "&#x" + i.charCodeAt(n).toString(16) + ";";
    }
   }
  }
  o = o.replace(/(\r|\n)/g, "");
  document.getElementById("f").innerHTML = document.getElementById("o").value = "<div style=\"font-family: Consolas, Lucida Console, Courier New, monospace;\">\n" + o + "\n</div>\n";
  document.getElementById("o").select();
 }, false);
})();
//--></script>
</body></html>

also available at

http://void.byethost10.com/sssf/ForUmCodeEnt.html

Reply Quote