Jump to content
EN
Play

Forum

Creativity: Computer Graphics


 Share

Recommended Posts

i am in this clan

-________________________________________-

 

1. This is not a clan

2. You didn't send an application

3. No one has accepted you

Edited by omrot

Share this post


Link to post
Share on other sites

i used Notepad to make my graphics because Notepad is AWESOME

JavaScript:

 

 

// @author Penguin-Pal http://tankionline.wikia.com/wiki/User:Penguin-Pal
// latest version 2016-07-23 http://tankionline.wikia.com/wiki/MediaWiki:Common.js?oldid=24673
/* ================================ *\
	# protection module generator
\* ================================ */
window.tow = window.tow || {};
tow.protectionModules = {
	data: {},
	fn: {}
}

/* data */
// file url paths
tow.protectionModules.data.moduleUrlPaths = {
	icons: {
		Firebird: "4/41",
		Freeze: "b/b7",
		Isida: "6/6c",
		Hammer: "e/ee",
		Twins: "1/1d",
		Ricochet: "c/ce",
		Smoky: "1/14",
		Vulcan: "1/12",
		Thunder: "8/8a",
		Railgun: "a/ab",
		Shaft: "a/ae",
		Mine: "7/7d",
		general: "b/bb"
	},
	modules: {
		M0: "8/81",
		M1: "0/0a",
		M2: "d/d0",
		M3: "6/61",
		special: "9/90"
	}
}
// green icon background
tow.protectionModules.data.iconbg = "http\x3a//images.wikia.com/tankionline/images/2/25/Garage_icons_protection_module_background.png";

/* functions */
// get icon image url
tow.protectionModules.fn.getIconUrl = function(name) {
	var validIcons = ["Firebird", "Freeze", "Isida", "Hammer", "Twins", "Ricochet", "Smoky", "Vulcan", "Thunder", "Railgun", "Shaft", "Mine", "general"];
	if (validIcons.indexOf(name) > -1) {
		name = name;
	} else {
		name = "general";
	}
	return "http\x3a//images.wikia.com/tankionline/images/" + tow.protectionModules.data.moduleUrlPaths.icons[name] + "/Garage_icons_protection_modules_" + name + ".png";
}
// get module image url
tow.protectionModules.fn.getModuleUrl = function(name) {
	var validModules = ["M0", "M1", "M2", "M3", "special"];
	if (validModules.indexOf(name) > -1) {
		name = name;
	} else {
		name = "M0";
	}
	return "http\x3a//images.wikia.com/tankionline/images/" + tow.protectionModules.data.moduleUrlPaths.modules[name] + "/Protection_Module_icon_" + name + ".png";
}
// create new module image
tow.protectionModules.fn.createModule = function(moduleData, cb) { // cb's 'ths' is bounded to the generated canvas
	// moduleData = {type: /M[0-3]|special/, prot: []}
	var canvas = document.createElement("canvas"),
		ctx = canvas.getContext("2d"),
		content = [];
	cb = cb.bind(canvas);
	canvas.width = 166;
	canvas.height = 106;
	content.push({
		url: tow.protectionModules.fn.getModuleUrl(moduleData.type),
		x: 0,
		y: 0
	});
	moduleData.prot = Array.isArray(moduleData.prot) ? moduleData.prot : [];
	moduleData.prot.reverse(/* reverse because icons are drawn from right to left */).forEach(function(prot, i) {
		console.log(prot);
		// 'x' and 'y' are just for testing - put the logic for calculation position later, based on 'i' and 'moduleData.prot.length'
		var listWidth = 32 * moduleData.prot.length - 2,
			x = (166 - listWidth) / 2 + i * (32),
			y = 36;
		x = 166 - x - 30; // mirror the drawing position of x - icons are drawn from right to left
		content.push({
			url: tow.protectionModules.data.iconbg,
			x: x - 1,
			y: y - 1
		});
		content.push({
			url: tow.protectionModules.fn.getIconUrl(prot),
			x: x + 1,
			y: y + 1
		});
	});
	console.warn(content.concat());
	tow.protectionModules.fn.fillModule(ctx, content, cb);
}
// draw images on module
tow.protectionModules.fn.fillModule = function(ctx, arrayOfImages, cb) {
	if (arrayOfImages.length === 0) {
		cb();
	} else {
		var curr = arrayOfImages.shift(),
			img = document.createElement("img");
		img.onload = function() {
			ctx.drawImage(this, curr.x || 0, curr.y || 0);
			tow.protectionModules.fn.fillModule(ctx, arrayOfImages, cb);
		}
		img.src = curr.url;
	}
}

/* implement */
$(".protection-module").each(function() {
	var placeholder = this,
		data = {type: null, prot: []},
		protAttr = $(this).attr("data-protection-module-prot");
	data.type = $(this).attr("data-protection-module-type");
	if (typeof protAttr === "string") {
		// value not empty or set to 'NONE'
		if (protAttr != "NONE" && protAttr.trim().length > 0) {
			data.prot = protAttr.split("##");
		}
	}
	tow.protectionModules.fn.createModule(data, function() {
		$(placeholder).replaceWith(this);
	});
});

 

HTML + wiki code:

<span class="protection-module" data-protection-module-type="{{{type|{{{1|M0}}}}}}" data-protection-module-prot="{{{protection|{{{2|NONE}}}}}}">placeholder text</span>
Syntax:

{{Protection Module|M<number>|Protection 1##Protection 2##Protection 3##etc.}}
 

I used it for auto-generation for images in an unofficial, fan Tanki wiki: http://tankionline.wikia.com/wiki/Protection_Modules#List_of_Modules (will not work on mobile)

 

Here's what i did with this syntax:

{{Protection Module|special|Railgun##Shaft##Thunder##Vulcan}}
Ladies and Gentlemen, i present you, the Penguin Q-A!

 

Protection_Module_fanart_Penguin_Q-A_-_R

 

(for those of you with tendencies to faint, don't worry, i used Notepad++. I mean, who even uses MS Notepad... ew?!)

Edited by AN_602
  • Like 2

Share this post


Link to post
Share on other sites

i am in this clan

 

-________________________________________-

 

1. This is not a clan

2. You didn't send an application

3. No one has accepted you

ROFLMAO xD

Share this post


Link to post
Share on other sites

 

 

 

 

 

How to be chat Moderators ?

For photoshop

Watch:

2Cn7qRQ.jpg

Or become like katekizem

ForumEnglishModerators

0ldpCOA.jpg :D :wub: :wub: :wub:

 

I've got a cool trick to edit it without Photoshop, I'll show you in a bit

 

Edit: here you go

 

Just right click the text (or image) you want to change on Google Chrome and click Inspect Element. Then rewrite whatever you want :D

Quite fun actually, but this is quite an old trick :)

 

90c37eee80464aba9f2116d1a2551dc2.png

 

BTW, The changes made are only done on your pc and will go back to its normal version when you refresh the page

Edited by MusicJam19
  • Like 2

Share this post


Link to post
Share on other sites

I've got a cool trick to edit it without Photoshop, I'll show you in a bit

 

Edit: here you go

 

Just right click the text (or image) you want to change on Google Chrome and click Inspect Element. Then rewrite whatever you want :D

Quite fun actually, but this is quite an old trick :)

 

 

90c37eee80464aba9f2116d1a2551dc2.png

 

 

BTW, The changes made are only done on your pc and will go back to its normal version when you refresh the page

I changed my K/D, awesome hack.

Share this post


Link to post
Share on other sites

This topic is now closed to further replies.
 Share

×
×
  • Create New...