Jump to content

User:Vanisaac/scripts/TartanBuilder.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Vanisaac (talk | contribs) at 20:20, 25 June 2020 (Starting to build the logic). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* The TartanBuilder userscript is used in conjunction with template:Tartan to build an SVG
   image of a tartan pattern from its sett description and upload the file to Wikipedia for
   use as a default image for template:Tartan to use */

/*
var settinput = prompt("Sett pattern")	// input of a tartan sett pattern, to be replaced
										// by data from HTML scrape.
var sett = settinput.toLowerCase()
var colorarray = []						// Array containing color codes for thread count.
var lenarray = []						// Array of color code locations in sett string.
var threadarray = []					// Array containing thread count for each color.
var dasharray = []						// String for insertion in SVG stroke-dasharrays.

if (sett != null){
	for (i=0; i<sett.length; i++){		// Goes through each character of sett to extract
										// color codes and their location in the string.
		if (sett.substr(i,1) >= "a" && sett.substr(i,1) <= "z" ){
			colorarray.push (sett.substr(i,1));
			lenarray.push (i)
		}
	}
	for (i=0; i<colorarray.length; i++){	// Extracts thread counts from sett string
		threadarray.push (sett.substring(lenarray[i];lenarray[i+1]-1))
	}
	for (i="a"; i<="z"; i++){			//Generates dasharray for each color
		if colorarray
	}







}
*/