Skip to content

Commit

Permalink
Harbour Colours
Browse files Browse the repository at this point in the history
  • Loading branch information
willxyu committed Nov 11, 2017
1 parent 8bc8718 commit 9c38071
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
20 changes: 10 additions & 10 deletions core/asm.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ asm.data.poi = {
['Aalen'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
coordinates: [ 53, 84], type: 'harbour',
},
['Ageiro'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
['Ageiro'] : { paletteR: 200, paletteG: 185, paletteB: 245, paletteA: 1,
coordinates: [-187, 191], type: 'harbour',
trades: {
gems : [
Expand All @@ -71,7 +71,7 @@ asm.data.poi = {
['Ashtan'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
coordinates: [ 32, 338], type: 'harbour',
},
['Colchis'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
['Colchis'] : { paletteR: 235, paletteG: 65, paletteB: 180, paletteA: 1,
coordinates: [ 354, 470], type: 'harbour',
trades: {
glass : [
Expand All @@ -94,7 +94,7 @@ asm.data.poi = {
['Mhaldor'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
coordinates: [-123, 288], type: 'harbour',
},
['Minos'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
['Minos'] : { paletteR: 110, paletteG: 215, paletteB: 215, paletteA: 1,
coordinates: [ 270, 558], type: 'harbour',
trades: {
honey : [
Expand All @@ -104,7 +104,7 @@ asm.data.poi = {
{ cost: 'tea', lose: 3, receive: 2, }, ],
},
},
['Mysia'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
['Mysia'] : { paletteR: 66, paletteG: 245, paletteB: 155, paletteA: 1,
coordinates: [ 461, 112], type: 'harbour',
trades: {
ceramics : [
Expand Down Expand Up @@ -137,7 +137,7 @@ asm.data.poi = {
{ cost: 'glass', lose: 3, receive: 2, }, ],
},
},
['Shastaan'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
['Shastaan'] : { paletteR: 175, paletteG: 65, paletteB: 235, paletteA: 1,
coordinates: [ 364, 139], type: 'harbour',
trades: {
cotton : [
Expand All @@ -152,7 +152,7 @@ asm.data.poi = {
{ cost: 'perfume', lose: 3, receive: 2, }, ],
},
},
['Suliel'] : { paletteR: 190, paletteG: 100, paletteB: 55, paletteA: 1,
['Suliel'] : { paletteR: 190, paletteG: 245, paletteB: 195, paletteA: 1,
coordinates: [ 34, 809], type: 'harbour',
trades: {
fur: [
Expand All @@ -164,7 +164,7 @@ asm.data.poi = {
['Targossas'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
coordinates: [ 376, 234], type: 'harbour',
},
["Tasur'ke"] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
["Tasur'ke"] : { paletteR: 245, paletteG: 105, paletteB: 85, paletteA: 1,
coordinates: [ 344, 356], type: 'harbour',
trades: {
granite : [
Expand All @@ -178,7 +178,7 @@ asm.data.poi = {
['Tenwat'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
coordinates: [ 215, 579], type: 'harbour',
},
['Thraasi'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
['Thraasi'] : { paletteR: 75, paletteG: 250, paletteB: 195, paletteA: 1,
coordinates: [ -15, 204], type: 'harbour',
trades: {
armaments : [
Expand All @@ -197,7 +197,7 @@ asm.data.poi = {
['Ulangi'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
coordinates: [ 402, 163], type: 'harbour',
},
['Umbrin'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
['Umbrin'] : { paletteR: 245, paletteG: 220, paletteB: 135, paletteA: 1,
coordinates: [ 365, 494], type: 'harbour',
trades: {
armaments : [
Expand All @@ -211,7 +211,7 @@ asm.data.poi = {
['Valho'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
coordinates: [ 299, 645], type: 'harbour',
},
['Zanzibaar'] : { paletteR: 145, paletteG: 60, paletteB: 55, paletteA: 1,
['Zanzibaar'] : { paletteR: 225, paletteG: 190, paletteB: 55, paletteA: 1,
coordinates: [ 479, 49], type: 'harbour',
trades: {
fruits : [
Expand Down
28 changes: 24 additions & 4 deletions core/asm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ asm = typeof asm !== 'undefined' ? asm : {}

asm.hover = asm.hover || false
asm.hovrp = asm.hovrp || false
asm.hovrc = asm.hovrc || ''
asm.hovrn = asm.hovrn || ''

asm.copy = function(obj) { var c; if (null == obj || 'object' != typeof obj) return obj; if (obj instanceof Date) { c = new Date(); c.setTime(obj.getTime()); return c }; if (obj instanceof Array) { c = []; for (var i=0;i<obj.length;i++) { c[i] = asm.copy(obj[i]) }; return c }; if (obj instanceof Object) { c = {}; for (var attr in obj) { if (obj.hasOwnProperty(attr)) { c[attr] = asm.copy(obj[attr]) } }; return c }; throw new Error('Unable to copy obj! Type not supported.'); }

Expand Down Expand Up @@ -47,7 +49,12 @@ asm.draw = function(context, transform, data) {
for (var k in t) {
var c = t[k].coordinates
c[1] *= -1
if (t[k].type == 'harbour') { asm.drawpoint(context, r, c) }
if (t[k].type == 'harbour') {
var R = t[k].paletteR || 190
var G = t[k].paletteG || 100
var B = t[k].paletteB || 55
var fs = 'rgba( '+R+', '+G+', '+B+', 1)'
asm.drawpoint(context, r, c, fs) }
}
}

Expand Down Expand Up @@ -114,7 +121,7 @@ asm.mousehover = function(transform,event,canvasdimension) {
for (var k in t) {
if (t[k].type == 'harbour') { points.push({ coordinates: t[k].coordinates, id: k}) }
}
var tc = copy(asm.data.tradeColours)
var tc = asm.copy(asm.data.tradeColours)

var b = false
for (var i=0;i<points.length;i++) {
Expand Down Expand Up @@ -186,16 +193,29 @@ asm.mousehover = function(transform,event,canvasdimension) {
var cd = points[i].coordinates
cd[1] *= -1
asm.hovrp = asm.copy(cd)
asm.drawpoint(c, r, cd, 'rgba(255,255,255,1)', rd - 1)
asm.hovrn = points[i].id
// asm.hovrc = 'rgba( 190, 100, 55, 1)'
asm.drawpoint(c, r, cd, 'rgba(210,210,210,0.37)', rd - 1)
break }
}
if (!b) {
asm.hover = false
// un-highlight
var c = d3.select('canvas').node().getContext('2d')
var cd = asm.hovrp
asm.drawpoint(c, r, cd, 'rgba( 190, 100, 55, 1)')
var fs = 'rgba( 190, 100, 55, 1)'
if (asm.data.poi[asm.hovrn]) {
var x = asm.data.poi[asm.hovrn]
var R = x.paletteR || 190
var G = x.paletteG || 100
var B = x.paletteB || 55
fs = 'rgba( '+R+', '+G+', '+B+', 1)'
}

asm.drawpoint(c, r, cd, fs)
asm.hovrp = false
asm.hovrc = ''
asm.hovrn = ''
$('canvas').css('cursor','default') }

}
Expand Down

0 comments on commit 9c38071

Please sign in to comment.