How to use getContext method in differencify

Best JavaScript code snippet using differencify

cartoRendererTest.js

Source:cartoRendererTest.js Github

copy

Full Screen

1module("cartoRenderer");2test("TestCartoRenderer_Constructor", function() {3 expect(8);4 var canvas = document.createElement("canvas"),5 context = canvas.getContext("2d"),6 hitCanvas = document.createElement("canvas"),7 hitContext = canvas.getContext("2d"),8 options = {};9 var carto = new SuperMap.CartoRenderer(context, hitContext, options);10 equal(carto.CLASS_NAME, "SuperMap.CartoRenderer", "CartoRenderer_Constructor");11 ok(carto.context != null, "CartoRenderer_Constructor");12 ok(carto.hitContext != null, "CartoRenderer_Constructor");13 equal(carto.symbolizer, null, "CartoRenderer_Constructor");14 equal(carto.layer, null, "CartoRenderer_Constructor");15 equal( typeof carto.pointImagesInfo, "object", "CartoRenderer_Constructor");16 equal(carto.imagesBackup.length, 0, "CartoRenderer_Constructor");17 equal(carto.tempImage, null, "CartoRenderer_Constructor");18});19test("TestCartoRenderer_Destroy", function() {20 expect(4);21 var canvas = document.createElement("canvas"),22 context = canvas.getContext("2d"),23 hitCanvas = document.createElement("canvas"),24 hitContext = canvas.getContext("2d"),25 options = {};26 var carto = new SuperMap.CartoRenderer(context, hitContext, options);27 carto.destroy();28 equal(carto.context, null, "CartoRenderer_Destroy");29 equal(carto.symbolizer, null, "CartoRenderer_Destroy");30 equal(carto.pointImagesInfo, null, "CartoRenderer_Destroy");31 equal(carto.imagesBackup, null, "CartoRenderer_Destroy");32});33test("TestCartoRenderer_Support", function() {34 expect(1);35 var canvas = document.createElement("canvas"),36 context = canvas.getContext("2d"),37 hitCanvas = document.createElement("canvas"),38 hitContext = canvas.getContext("2d"),39 options = {};40 var carto = new SuperMap.CartoRenderer(context, hitContext, options);41 var isSupport = carto.supported();42 equal(isSupport, !!canvas.getContext, "CartoRenderer_Support");43});44test("TestCartoRenderer_ApplyStyle", function() {45 expect(2);46 var canvas = document.createElement("canvas"),47 context = canvas.getContext("2d"),48 hitCanvas = document.createElement("canvas"),49 hitContext = canvas.getContext("2d"),50 options = {};51 var carto = new SuperMap.CartoRenderer(context, hitContext, options);52 var can = document.createElement("canvas"), 53 ctx = canvas.getContext("2d"),54 style = {55 fillStyle: "#ababab",56 lineWidth: 557 };58 carto.applyStyle(ctx, style);59 for(var st in style){60 equal(ctx[st], style[st], "CartoRenderer_ApplyStyle");61 }62});63test("TestCartoRenderer_DrawFeature", function() {64 expect(1);65 var canvas = document.createElement("canvas"),66 context = canvas.getContext("2d"),67 hitCanvas = document.createElement("canvas"),68 hitContext = canvas.getContext("2d"),69 options = {};70 var carto = new SuperMap.CartoRenderer(context, hitContext, options);71 var geo = new SuperMap.Geometry.Point(50, 50),72 feature = new SuperMap.Feature.Vector(geo),73 style = new SuperMap.Style(),74 layerType = "POINT";75 feature.layerIndex = 10;76 geo.type = "POINT";77 geo.points = [50, 50];78 var rendered = carto.drawFeature(feature, style, layerType);79 equal(rendered, true, "CartoRenderer_DrawFeature");80});81test("TestCartoRenderer_DrawGeometry", function() {82 expect(1);83 var canvas = document.createElement("canvas"),84 context = canvas.getContext("2d"),85 hitCanvas = document.createElement("canvas"),86 hitContext = canvas.getContext("2d"),87 options = {};88 var carto = new SuperMap.CartoRenderer(context, hitContext, options);89 var can = document.createElement("canvas"), 90 ctx = canvas.getContext("2d"),91 hitCan = document.createElement("canvas"), 92 hitCtx = canvas.getContext("2d"),93 geometry = new SuperMap.Geometry.Point(50, 50),94 style = new SuperMap.Style(),95 hitColor = carto.featureIdToHex("SuperMap.Feature.Vector_14", 10),96 attributs = {},97 layerType = "THEME";98 geometry.type = "TEXT";99 var drawed = carto.drawGeometry(ctx, hitCtx, geometry, style, hitColor, attributs, layerType);100 var geometry0 = new SuperMap.Geometry.MultiPoint([101 new SuperMap.Geometry.Point(50, 50),102 new SuperMap.Geometry.Point(100, 50),103 new SuperMap.Geometry.Point(10, 100)104 ]);105 geometry0.type = "POINT";106 geometry0.parts = [];107 var drawed = carto.drawGeometry(ctx, hitCtx, geometry0, style, hitColor, attributs, layerType);108 layerType = "";109 var geometry1 = new SuperMap.Geometry.LineString([110 new SuperMap.Geometry.Point(50, 50),111 new SuperMap.Geometry.Point(100, 50)112 ]);113 geometry1.type = "LINE";114 geometry1.parts = geometry1.components;115 geometry1.points = geometry1.components;116 var drawed = carto.drawGeometry(ctx, hitCtx, geometry1, style, hitColor, attributs, layerType);117 118 var geometry2 = new SuperMap.Geometry.Polygon([119 new SuperMap.Geometry.LinearRing([120 new SuperMap.Geometry.Point(50, 50),121 new SuperMap.Geometry.Point(100, 50),122 new SuperMap.Geometry.Point(10, 100)123 ])124 ]);125 geometry2.type = "REGION";126 geometry2.parts = geometry2.components;127 geometry2.points = geometry2.components; 128 var drawed = carto.drawGeometry(ctx, hitCtx, geometry2, style, hitColor, attributs, layerType); 129 equal(drawed, true, "CartoRenderer_DrawGeometry");130});131test("TestCartoRenderer_DrawText", function() {132 expect(4);133 var canvas = document.createElement("canvas"),134 context = canvas.getContext("2d"),135 hitCanvas = document.createElement("canvas"),136 hitContext = canvas.getContext("2d"),137 options = {};138 var carto = new SuperMap.CartoRenderer(context, hitContext, options);139 var can = document.createElement("canvas"), 140 ctx = canvas.getContext("2d"),141 hitCan = document.createElement("canvas"), 142 hitCtx = canvas.getContext("2d"),143 geometry = new SuperMap.Geometry.Point(50, 50),144 style = new SuperMap.Style(),145 attributes = {};146 geometry.texts = ["DDDDD", "EEEEEE"];147 geometry.parts = [1];148 geometry.points = [149 new SuperMap.Geometry.Point(50, 50),150 new SuperMap.Geometry.Point(100, 50),151 new SuperMap.Geometry.Point(10, 100),152 new SuperMap.Geometry.Point(100, 100)153 ]; 154 style.textName = "AAAAA";155 style.bold = true;156 style.rotation = 30;157 style.haloRadius = 5;158 style.backColor = "#ABABAB";159 style.foreColor = "#FFFFFF";160 style.textHeight = 10;161 style.fontWeight = 700;162 var drawed = carto.drawText(ctx, hitCtx, geometry, style, attributes);163 equal(drawed, true, "CartoRenderer_DrawText");164 equal(style.fontWeight, 700, "CartoRenderer_DrawText");165 equal(ctx.strokeStyle, "#000000", "CartoRenderer_DrawText");166 equal(ctx.fillStyle, "#000000", "CartoRenderer_DrawText");167});168test("TestCartoRenderer_DrawPoint", function() {169 var canvas = document.createElement("canvas"),170 context = canvas.getContext("2d"),171 hitCanvas = document.createElement("canvas"),172 hitContext = canvas.getContext("2d"),173 options = {};174 var carto = new SuperMap.CartoRenderer(context, hitContext, options);175 var can = document.createElement("canvas"), 176 ctx = canvas.getContext("2d"),177 hitCan = document.createElement("canvas"), 178 hitCtx = canvas.getContext("2d"),179 geometry = {180 points: [181 new SuperMap.Geometry.Point(50, 50),182 new SuperMap.Geometry.Point(50, 50)183 ]184 },185 style = new SuperMap.Style();186 var drawed = carto.drawPoint(ctx, hitCtx, geometry, style);187 equal(drawed, true, "CartoRenderer_DrawText");188 equal(ctx.lineWidth, 1, "CartoRenderer_DrawText");189 equal(ctx.strokeStyle, "#cc3333", "CartoRenderer_DrawText");190 equal(ctx.fillStyle, "#ffcc00", "CartoRenderer_DrawText");191});192test("TestCartoRenderer_DrawImagePoint", function() {193 expect(5);194 var canvas = document.createElement("canvas"),195 context = canvas.getContext("2d"),196 hitCanvas = document.createElement("canvas"),197 hitContext = canvas.getContext("2d"),198 options = {};199 var carto = new SuperMap.CartoRenderer(context, hitContext, options);200 var can = document.createElement("canvas"), 201 ctx = canvas.getContext("2d"),202 hitCan = document.createElement("canvas"), 203 hitCtx = canvas.getContext("2d"),204 style = new SuperMap.Style(),205 x = 50, y = 50;206 207 style.pointFile = "Images/Day.jpg";208 style.imageSmoothingEnabled = null;209 carto.layer = {210 map: {211 getZoom: function() {212 return 5;213 }214 }215 };216 carto.drawImagePoint(ctx, hitCtx, style, x, y);217 equal(ctx.globalAlpha, 1, "CartoRenderer_DrawImagePoint");218 equal(ctx.globalCompositeOperation, "source-over", "CartoRenderer_DrawImagePoint");219 style.pointFile = "Images/Day.png";220 carto.drawImagePoint(ctx, hitCtx, style, x, y);221 equal(ctx.lineWidth, 1, "CartoRenderer_DrawImagePoint");222 equal(ctx.strokeStyle, "#000000", "CartoRenderer_DrawImagePoint");223 equal(ctx.fillStyle, "#000000", "CartoRenderer_DrawImagePoint");224});225test("TestCartoRenderer_DrawVectorPoint", function() {226 expect(0);227 var canvas = document.createElement("canvas"),228 context = canvas.getContext("2d"),229 hitCanvas = document.createElement("canvas"),230 hitContext = canvas.getContext("2d"),231 options = {};232 var carto = new SuperMap.CartoRenderer(context, hitContext, options);233 var can = document.createElement("canvas"), 234 ctx = canvas.getContext("2d"),235 W = 100, H = 50, x = 50, y = 50;236 carto.drawVectorPoint(ctx, W, H, x, y);237});238test("TestCartoRenderer_DrawLine", function() {239 expect(12);240 var canvas = document.createElement("canvas"),241 context = canvas.getContext("2d"),242 hitCanvas = document.createElement("canvas"),243 hitContext = canvas.getContext("2d"),244 options = {};245 var carto = new SuperMap.CartoRenderer(context, hitContext, options);246 var can = document.createElement("canvas"), 247 ctx = canvas.getContext("2d"),248 hitCan = document.createElement("canvas"), 249 hitCtx = canvas.getContext("2d"),250 geometry = new SuperMap.Geometry.LineString([251 new SuperMap.Geometry.Point(50, 50),252 new SuperMap.Geometry.Point(100, 50)253 ]),254 style = new SuperMap.Style(),255 isRegion = true;256 style.offset = {257 x: 0,258 y: 0259 };260 style.lineDashOffset = 0;261 geometry.points = geometry.components;262 geometry.parts = [2, 2]; 263 var drawed = carto.drawLine(ctx, hitCtx, geometry, style, isRegion);264 equal(style.offset.x, 0, "CartoRenderer_DrawLine");265 equal(style.offset.y, 0, "CartoRenderer_DrawLine");266 equal(hitCtx.globalCompositeOperation, "source-over", "CartoRenderer_DrawLine");267 equal(ctx.globalCompositeOperation, "source-over", "CartoRenderer_DrawLine");268 equal(drawed, true, "CartoRenderer_DrawLine");269 style.lineDasharray = [1, 2, 1];270 style.strokeOpacity = 0.5;271 style.fillOpacity = 0.8;272 style.lineOpacity = 0.2;273 var drawed1 = carto.drawLine(ctx, hitCtx, geometry, style, isRegion);274 //equal(ctx.lineDashOffset, 0, "CartoRenderer_DrawLine");275 equal(drawed1, true, "CartoRenderer_DrawLine");276 ctx.setLineDash = false;277 isRegion = false;278 var drawed2 = carto.drawLine(ctx, hitCtx, geometry, style, isRegion);279 equal(style.offset.x, 0, "CartoRenderer_DrawLine");280 equal(style.offset.y, 0, "CartoRenderer_DrawLine");281 equal(hitCtx.globalCompositeOperation, "source-over", "CartoRenderer_DrawLine");282 equal(ctx.globalCompositeOperation, "source-over", "CartoRenderer_DrawLine");283 equal(ctx.globalAlpha, 0.5, "CartoRenderer_DrawLine");284 equal(drawed2, true, "CartoRenderer_DrawLine");285});286test("TestCartoRenderer_DrawDotedLine", function() {287 expect(1);288 var canvas = document.createElement("canvas"),289 context = canvas.getContext("2d"),290 hitCanvas = document.createElement("canvas"),291 hitContext = canvas.getContext("2d"),292 options = {};293 var carto = new SuperMap.CartoRenderer(context, hitContext, options);294 var can = document.createElement("canvas"), 295 ctx = canvas.getContext("2d"),296 hitCan = document.createElement("canvas"), 297 hitCtx = canvas.getContext("2d"),298 points = [299 new SuperMap.Geometry.Point(50, 50),300 new SuperMap.Geometry.Point(100, 50),301 new SuperMap.Geometry.Point(100, 100)302 ],303 startIndex = 0,304 length = 2,305 style = new SuperMap.Style(),306 isRegion = true,307 noLine = false;308 style.fillOpacity = 0.5;309 style.strokeOpacity = 0.8;310 style.offset = {};311 carto.drawDotedLine(ctx, hitCtx, points, startIndex, length, style, isRegion, noLine);...

Full Screen

Full Screen

RCSDK.js

Source:RCSDK.js Github

copy

Full Screen

...30 * This is for internal use only31 * @protected32 * @returns {Request}33 */34 RCSDK.prototype.getRequest = function() { return require('./core/http/Request').$get(this.getContext()); };35 /**36 * This is for internal use only37 * @protected38 * @returns {Response}39 */40 RCSDK.prototype.getResponse = function(status, statusText, body, headers) {41 return require('./core/http/Response').$get(this.getContext(), status, statusText, body, headers);42 };43 /**44 * @returns {AjaxObserver}45 */46 RCSDK.prototype.getAjaxObserver = function() { return require('./core/AjaxObserver').$get(this.getContext()); };47 /**48 * This is for internal use only49 * @protected50 * @returns {XhrResponse}51 */52 RCSDK.prototype.getXhrResponse = function() { return require('./core/xhr/XhrResponse').$get(this.getContext()); };53 /**54 * @returns {Platform}55 */56 RCSDK.prototype.getPlatform = function() { return require('./core/Platform').$get(this.getContext()); };57 /**58 * @returns {Cache}59 */60 RCSDK.prototype.getCache = function() { return require('./core/Cache').$get(this.getContext()); };61 /**62 * @returns {Subscription}63 */64 RCSDK.prototype.getSubscription = function() { return require('./core/Subscription').$get(this.getContext()); };65 /**66 * @returns {PageVisibility}67 */68 RCSDK.prototype.getPageVisibility = function() { return require('./core/PageVisibility').$get(this.getContext()); };69 /**70 * @returns {Helper}71 */72 RCSDK.prototype.getHelper = function() { return require('./core/Helper').$get(this.getContext()); };73 /**74 * @returns {Observable}75 */76 RCSDK.prototype.getObservable = function() { return require('./core/Observable').$get(this.getContext()); };77 /**78 * @returns {Validator}79 */80 RCSDK.prototype.getValidator = function() { return require('./core/Validator').$get(this.getContext()); };81 /**82 * @returns {Log}83 */84 RCSDK.prototype.getLog = function() { return require('./core/Log').$get(this.getContext()); };85 /**86 * @returns {Utils}87 */88 RCSDK.prototype.getUtils = function() { return require('./core/Utils').$get(this.getContext()); };89 /**90 * @returns {List}91 */92 RCSDK.prototype.getList = function() { return require('./core/List').$get(this.getContext()); };93 // Helpers94 /**95 * @returns {CountryHelper}96 */97 RCSDK.prototype.getCountryHelper = function() { return require('./helpers/Country').$get(this.getContext()); };98 /**99 * @returns {DeviceModelHelper}100 */101 RCSDK.prototype.getDeviceModelHelper = function() { return require('./helpers/DeviceModel').$get(this.getContext()); };102 /**103 * @returns {LanguageHelper}104 */105 RCSDK.prototype.getLanguageHelper = function() { return require('./helpers/Language').$get(this.getContext()); };106 /**107 * @returns {LocationHelper}108 */109 RCSDK.prototype.getLocationHelper = function() { return require('./helpers/Location').$get(this.getContext()); };110 /**111 * @returns {ShippingMethodHelper}112 */113 RCSDK.prototype.getShippingMethodHelper = function() { return require('./helpers/ShippingMethod').$get(this.getContext()); };114 /**115 * @returns {StateHelper}116 */117 RCSDK.prototype.getStateHelper = function() { return require('./helpers/State').$get(this.getContext()); };118 /**119 * @returns {TimezoneHelper}120 */121 RCSDK.prototype.getTimezoneHelper = function() { return require('./helpers/Timezone').$get(this.getContext()); };122 /**123 * @returns {AccountHelper}124 */125 RCSDK.prototype.getAccountHelper = function() { return require('./helpers/Account').$get(this.getContext()); };126 /**127 * @returns {BlockedNumberHelper}128 */129 RCSDK.prototype.getBlockedNumberHelper = function() { return require('./helpers/BlockedNumber').$get(this.getContext()); };130 /**131 * @returns {CallHelper}132 */133 RCSDK.prototype.getCallHelper = function() { return require('./helpers/Call').$get(this.getContext()); };134 /**135 * @returns {ConferencingHelper}136 */137 RCSDK.prototype.getConferencingHelper = function() { return require('./helpers/Conferencing').$get(this.getContext()); };138 /**139 * @returns {ContactHelper}140 */141 RCSDK.prototype.getContactHelper = function() { return require('./helpers/Contact').$get(this.getContext()); };142 /**143 * @returns {ContactGroupHelper}144 */145 RCSDK.prototype.getContactGroupHelper = function() { return require('./helpers/ContactGroup').$get(this.getContext()); };146 /**147 * @returns {DeviceHelper}148 */149 RCSDK.prototype.getDeviceHelper = function() { return require('./helpers/Device').$get(this.getContext()); };150 /**151 * @returns {ExtensionHelper}152 */153 RCSDK.prototype.getExtensionHelper = function() { return require('./helpers/Extension').$get(this.getContext()); };154 /**155 * @returns {ForwardingNumberHelper}156 */157 RCSDK.prototype.getForwardingNumberHelper = function() { return require('./helpers/ForwardingNumber').$get(this.getContext()); };158 /**159 * @returns {MessageHelper}160 */161 RCSDK.prototype.getMessageHelper = function() { return require('./helpers/Message').$get(this.getContext()); };162 /**163 * @returns {PhoneNumberHelper}164 */165 RCSDK.prototype.getPhoneNumberHelper = function() { return require('./helpers/PhoneNumber').$get(this.getContext()); };166 /**167 * @returns {PresenceHelper}168 */169 RCSDK.prototype.getPresenceHelper = function() { return require('./helpers/Presence').$get(this.getContext()); };170 /**171 * @returns {RingoutHelper}172 */173 RCSDK.prototype.getRingoutHelper = function() { return require('./helpers/Ringout').$get(this.getContext()); };174 /**175 * @returns {ServiceHelper}176 */177 RCSDK.prototype.getServiceHelper = function() { return require('./helpers/Service').$get(this.getContext()); };178 if (!injections179 || !('CryptoJS' in injections)180 || !('localStorage' in injections)181 || !('Promise' in injections)182 || !('PUBNUB' in injections)183 || !('XHR' in injections)) throw new Error('Injections object is not complete');184 injections.XHR = (injections.XHR || function() {185 try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e1) {}186 try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e2) {}187 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e3) {}188 throw new Error("This browser does not support XMLHttpRequest.");189 });190 return RCSDK;191 };...

Full Screen

Full Screen

sushigameIngredients.js

Source:sushigameIngredients.js Github

copy

Full Screen

...38 "Rice",39 100,40 "A",41 function (xPos, yPos) {42 CanvasManager.getContext().fillStyle = "white"43 CanvasManager.getContext().beginPath()44 CanvasManager.getContext().arc(xPos, yPos, 15, 0, Math.PI*2)45 CanvasManager.getContext().fill()46 CanvasManager.getContext().arc(xPos, yPos, 15, 0, Math.PI*2)47 CanvasManager.getContext().stroke()48 CanvasManager.getContext().closePath()49 },50 function (xPos, yPos) {51 // CanvasManager.getContext().drawImage(Ingredient.riceStockSprite, xPos, yPos)52 CanvasManager.getContext().fillStyle = "white"53 CanvasManager.getContext().beginPath()54 CanvasManager.getContext().arc(xPos, yPos, 15, 0, Math.PI*2)55 CanvasManager.getContext().fill()56 CanvasManager.getContext().arc(xPos, yPos, 15, 0, Math.PI*2)57 CanvasManager.getContext().stroke()58 CanvasManager.getContext().closePath()59 }60)61Ingredient.roe = new Ingredient(62 "Salmon Roe",63 200,64 "Z",65 function (xPos, yPos) {66 // CanvasManager.getContext().drawImage(Ingredient.roeSprite, xPos, yPos)67 let displayRoe = function (xPos, yPos) {68 CanvasManager.getContext().fillStyle = "orangered"69 CanvasManager.getContext().beginPath()70 CanvasManager.getContext().arc(xPos, yPos, 8, 0, Math.PI*2)71 CanvasManager.getContext().fill()72 CanvasManager.getContext().closePath()73 CanvasManager.getContext().fillStyle = "darkorange"74 CanvasManager.getContext().beginPath()75 CanvasManager.getContext().arc(xPos, yPos, 6, 0, Math.PI*2)76 CanvasManager.getContext().fill()77 CanvasManager.getContext().closePath()78 CanvasManager.getContext().fillStyle = "firebrick"79 CanvasManager.getContext().beginPath()80 CanvasManager.getContext().arc(xPos, yPos, 2, 0, Math.PI*2)81 CanvasManager.getContext().fill()82 CanvasManager.getContext().closePath()83 CanvasManager.getContext().fillStyle = "darkorange"84 CanvasManager.getContext().beginPath()85 CanvasManager.getContext().arc(xPos - 1, yPos - 5, 3, 0, Math.PI*2)86 CanvasManager.getContext().fill()87 CanvasManager.getContext().closePath()88 CanvasManager.getContext().fillStyle = "white"89 CanvasManager.getContext().beginPath()90 CanvasManager.getContext().arc(xPos - 1, yPos - 6, 1, 0, Math.PI*2)91 CanvasManager.getContext().fill()92 CanvasManager.getContext().closePath()93 }94 displayRoe(xPos, yPos - 8)95 displayRoe(xPos - 8, yPos + 5)96 displayRoe(xPos + 8, yPos + 5)97 },98 function (xPos, yPos) {99 // CanvasManager.getContext().drawImage(Ingredient.roeStockSprite, xPos, yPos)100 let displayRoe = function (xPos, yPos) {101 CanvasManager.getContext().fillStyle = "orangered"102 CanvasManager.getContext().beginPath()103 CanvasManager.getContext().arc(xPos, yPos, 8, 0, Math.PI*2)104 CanvasManager.getContext().fill()105 CanvasManager.getContext().closePath()106 CanvasManager.getContext().fillStyle = "darkorange"107 CanvasManager.getContext().beginPath()108 CanvasManager.getContext().arc(xPos, yPos, 6, 0, Math.PI*2)109 CanvasManager.getContext().fill()110 CanvasManager.getContext().closePath()111 CanvasManager.getContext().fillStyle = "firebrick"112 CanvasManager.getContext().beginPath()113 CanvasManager.getContext().arc(xPos, yPos, 2, 0, Math.PI*2)114 CanvasManager.getContext().fill()115 CanvasManager.getContext().closePath()116 CanvasManager.getContext().fillStyle = "darkorange"117 CanvasManager.getContext().beginPath()118 CanvasManager.getContext().arc(xPos - 1, yPos - 5, 3, 0, Math.PI*2)119 CanvasManager.getContext().fill()120 CanvasManager.getContext().closePath()121 CanvasManager.getContext().fillStyle = "white"122 CanvasManager.getContext().beginPath()123 CanvasManager.getContext().arc(xPos - 1, yPos - 6, 1, 0, Math.PI*2)124 CanvasManager.getContext().fill()125 CanvasManager.getContext().closePath()126 }127 displayRoe(xPos, yPos - 8)128 displayRoe(xPos - 8, yPos + 5)129 displayRoe(xPos + 8, yPos + 5)130 }131)132Ingredient.nori = new Ingredient(133 "Nori",134 100,135 "E",136 function (xPos, yPos) {137 xPos -= 8138 yPos -= 8139 CanvasManager.getContext().fillStyle = "black"140 CanvasManager.getContext().fillRect(xPos, yPos, 15, 25)141 CanvasManager.getContext().fillStyle = "darkgreen"142 CanvasManager.getContext().fillRect(xPos + 1, yPos, 3, 8)143 CanvasManager.getContext().fillRect(xPos + 1, yPos + 9, 3, 10)144 CanvasManager.getContext().fillRect(xPos + 1, yPos + 20, 3, 5)145 CanvasManager.getContext().fillRect(xPos + 6, yPos, 3, 10)146 CanvasManager.getContext().fillRect(xPos + 6, yPos + 11, 3, 5)147 CanvasManager.getContext().fillRect(xPos + 6, yPos + 16, 3, 8)148 CanvasManager.getContext().fillRect(xPos + 11, yPos, 3, 5)149 CanvasManager.getContext().fillRect(xPos + 11, yPos + 6, 3, 8)150 CanvasManager.getContext().fillRect(xPos + 11, yPos + 15, 3, 10)151 },152 function (xPos, yPos) {153 // CanvasManager.getContext().drawImage(Ingredient.noriStockSprite, xPos, yPos)154 xPos -= 8155 yPos -= 8156 CanvasManager.getContext().fillStyle = "black"157 CanvasManager.getContext().fillRect(xPos, yPos, 15, 25)158 CanvasManager.getContext().fillStyle = "darkgreen"159 CanvasManager.getContext().fillRect(xPos + 1, yPos, 3, 8)160 CanvasManager.getContext().fillRect(xPos + 1, yPos + 9, 3, 10)161 CanvasManager.getContext().fillRect(xPos + 1, yPos + 20, 3, 5)162 CanvasManager.getContext().fillRect(xPos + 6, yPos, 3, 10)163 CanvasManager.getContext().fillRect(xPos + 6, yPos + 11, 3, 5)164 CanvasManager.getContext().fillRect(xPos + 6, yPos + 16, 3, 8)165 CanvasManager.getContext().fillRect(xPos + 11, yPos, 3, 5)166 CanvasManager.getContext().fillRect(xPos + 11, yPos + 6, 3, 8)167 CanvasManager.getContext().fillRect(xPos + 11, yPos + 15, 3, 10)168 }169)170Ingredient.avocado = new Ingredient(171 "Avocado",172 400,173 "R",174 function(xPos, yPos) {175 CanvasManager.getContext().drawImage(Ingredient.avocadoSprite, xPos, yPos)176 },177 function (xPos, yPos) {178 CanvasManager.getContext().drawImage(Ingredient.avocadoStockSprite, xPos, yPos)179 }180)181Ingredient.salmon = new Ingredient(182 "Salmon",183 600,184 "Q",185 function(xPos, yPos) {186 },187 function (xPos, yPos) {188 189 }190)191Ingredient.tuna = new Ingredient(192 "Tuna",...

Full Screen

Full Screen

sushigameClock.js

Source:sushigameClock.js Github

copy

Full Screen

1class Clock {2 constructor() {3 }4 displayDot(xPos, yPos) {5 CanvasManager.getContext().beginPath()6 CanvasManager.getContext().arc(xPos, yPos, 1, 0, Math.PI*2)7 CanvasManager.getContext().closePath()8 CanvasManager.getContext().stroke()9 }10 displayClock(xPos, yPos) {11 CanvasManager.getContext().fillStyle = "white"12 CanvasManager.getContext().beginPath()13 CanvasManager.getContext().arc(xPos, yPos, 20, 0, Math.PI*2)14 CanvasManager.getContext().closePath()15 CanvasManager.getContext().fill()16 CanvasManager.getContext().stroke()17 this.displayDot(xPos, yPos)18 this.displayDot(xPos, yPos - 15)19 this.displayDot(xPos + 8, yPos - 13)20 this.displayDot(xPos + 14, yPos - 7)21 this.displayDot(xPos + 15, yPos)22 this.displayDot(xPos + 14, yPos + 7)23 this.displayDot(xPos + 8, yPos + 13)24 this.displayDot(xPos, yPos + 15)25 this.displayDot(xPos - 8, yPos + 13)26 this.displayDot(xPos - 13, yPos + 7)27 this.displayDot(xPos - 15, yPos)28 this.displayDot(xPos - 13, yPos - 7)29 this.displayDot(yPos - 8, yPos - 13)30 }31 displayMinutes(iterator, xPos, yPos) {32 let minutes = iterator%6033 minutes = Math.floor(minutes/5) * 534 CanvasManager.getContext().beginPath()35 CanvasManager.getContext().moveTo(xPos, yPos)36 switch (minutes) {37 case 0:38 CanvasManager.getContext().lineTo(xPos, yPos - 15)39 break40 case 5:41 CanvasManager.getContext().lineTo(xPos + 8, yPos - 13)42 break43 case 10:44 CanvasManager.getContext().lineTo(xPos + 14, yPos - 7)45 break46 case 15:47 CanvasManager.getContext().lineTo(xPos + 15, yPos)48 break49 case 20:50 CanvasManager.getContext().lineTo(xPos + 14, yPos + 7)51 break52 case 25:53 CanvasManager.getContext().lineTo(xPos + 8, yPos + 13)54 break55 case 30:56 CanvasManager.getContext().lineTo(xPos, yPos + 15)57 break58 case 35:59 CanvasManager.getContext().lineTo(xPos - 8, yPos + 13)60 break61 case 40:62 CanvasManager.getContext().lineTo(xPos - 13, yPos + 7)63 break64 case 45:65 CanvasManager.getContext().lineTo(xPos - 15, yPos)66 break67 case 50:68 CanvasManager.getContext().lineTo(xPos - 13, yPos - 7)69 break70 case 55:71 CanvasManager.getContext().lineTo(xPos - 8, yPos - 13)72 break73 } 74 CanvasManager.getContext().stroke()75 }76 displayHours(iterator, xPos, yPos) {77 let hours = Math.floor((iterator%720)/60)78 CanvasManager.getContext().beginPath()79 CanvasManager.getContext().moveTo(xPos, yPos)80 switch (hours) {81 case 0:82 CanvasManager.getContext().lineTo(xPos, yPos - 10)83 break84 case 1:85 CanvasManager.getContext().lineTo(xPos + 4, yPos - 7)86 break87 case 2:88 CanvasManager.getContext().lineTo(xPos + 8, yPos - 5)89 break90 case 3:91 CanvasManager.getContext().lineTo(xPos + 10, yPos)92 break93 case 4:94 CanvasManager.getContext().lineTo(xPos + 8, yPos + 5)95 break96 case 5:97 CanvasManager.getContext().lineTo(xPos + 4, yPos + 7)98 break99 case 6:100 CanvasManager.getContext().lineTo(xPos, yPos + 10)101 break102 case 7:103 CanvasManager.getContext().lineTo(xPos - 5, yPos + 8)104 break105 case 8:106 CanvasManager.getContext().lineTo(xPos - 8, yPos + 5)107 break108 case 9:109 CanvasManager.getContext().lineTo(xPos - 10, yPos)110 break111 case 10:112 CanvasManager.getContext().lineTo(xPos - 8, yPos - 5)113 break114 case 11:115 CanvasManager.getContext().lineTo(xPos - 5, yPos - 8)116 break117 }118 CanvasManager.getContext().stroke()119 }120 displayTime(iterator, xPos, yPos) {121 this.displayClock(xPos, yPos)122 this.displayMinutes(iterator, xPos, yPos)123 this.displayHours(iterator, xPos, yPos)124 }...

Full Screen

Full Screen

drawing_shapes.js

Source:drawing_shapes.js Github

copy

Full Screen

1function draw() {2 var canvas_rect = document.getElementById('canvas_rect');3 if(canvas_rect.getContext){4 var ctx = canvas_rect.getContext('2d');5 6 //(x, y, width, height)7 ctx.fillRect(25, 25, 100, 100);8 ctx.clearRect(45, 45, 60, 60);9 ctx.strokeRect(50, 50, 50, 50);10 }11 var canvas_line = document.getElementById('canvas_line');12 if(canvas_line.getContext){13 var ctx = canvas_line.getContext('2d');14 15 ctx.beginPath();16 //x, y17 ctx.beginPath();18 ctx.moveTo(75, 50);19 ctx.lineTo(100, 75);20 ctx.lineTo(100, 25);21 ctx.fill();22 }23 var canvas_arc = document.getElementById('canvas_arc');24 if(canvas_arc.getContext){25 var ctx = canvas_arc.getContext('2d');26 27 ctx.beginPath();28 //(x, y, radius, startAngle, endAngle, anticlockwise)29 ctx.arc(75, 75, 50, 0, Math.PI *2, true); //outer circle30 ctx.moveTo(110, 75);31 ctx.arc(75, 75, 35, 0, Math.PI, false); //Mouth (clockwise)32 ctx.moveTo(65, 65);33 ctx.arc(60, 65, 5, 0, Math.PI * 2, true); //left eye34 ctx.moveTo(95, 65);35 ctx.arc(90, 65, 5, 0, Math.PI * 2, true); //right eye36 ctx.stroke();37 }38 var canvas_arcs = document.getElementById('canvas_arcs');39 if(canvas_arcs.getContext) {40 var ctx = canvas_arcs.getContext('2d');41 42 for (var i=0; i < 3; i++) {43 for (var j=0; j<3; j++) {44 ctx.beginPath();45 var x = 25 + j * 50; // x coordinate46 var y = 25 + i * 50; // y coordinate47 var radius = 20; // Arc radius48 var startAngle = 0; // Starting point on circle49 var endAngle = Math.PI + (Math.PI * j) / 2; // End point on circle50 var anticlockwise = i % 2 !== 0; // clockwise or anticlockwise51 ctx.arc(x, y, radius, startAngle, endAngle, anticlockwise);52 if(i>1) {53 ctx.fill();54 }55 else {56 ctx.stroke();57 }58 }59 }60 }61 var quadratic_curve = document.getElementById('quadratic_curve');62 if(quadratic_curve.getContext) {63 var ctx = quadratic_curve.getContext('2d');64 ctx.beginPath();65 ctx.moveTo(30, 0);66 //px1, py1, x2, y267 ctx.quadraticCurveTo(5, 50, 20, 150);68 ctx.moveTo(90, 0);69 //px1, py1, px2, py2, x2, y270 ctx.bezierCurveTo(30, 40, 140, 100, 100, 150);71 ctx.stroke();72 }73 var rect = document.getElementById('rect');74 if(rect.getContext){75 var ctx = rect.getContext('2d');76 ctx.moveTo(20, 20);77 //x1, y1, x2, y2, radius78 ctx.arcTo(80, 80, 50, 150, 50);79 ctx.stroke();80 }81 var path2d = document.getElementById('path2d');82 if(path2d.getContext) {83 var ctx = path2d.getContext('2d');84 var rectangle = new Path2D();85 rectangle.rect(10, 10, 50, 50);86 var circle = new Path2D();87 circle.moveTo(125, 35);88 circle.arc(100, 35, 25, 0, 2*Math.PI);89 ctx.stroke(rectangle);90 ctx.fill(circle);91 }...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...5}6function drawBlindfold(){7 var canvas = document.getElementById('blindfold-canvas');8 if (canvas.getContext){9 var context = canvas.getContext('2d');10 }11 context.fillStyle = '#333333';12 context.fillRect(0,0,800,200);13 context.stroke();14}15function drawVerticalLine(x, lineWidth){16 var canvas = document.getElementById('amidakuji-canvas');17 if (canvas.getContext){18 var context = canvas.getContext('2d');19 }20 context.strokeStyle = '#1253A4';21 context.lineWidth = lineWidth;22 context.beginPath();23 context.moveTo(x, 0);24 context.lineTo(x, $('#amidakuji-canvas').height());25 context.stroke();26}27function drawHorizontalLine(startX, endX, y, lineWidth){28 var canvas = document.getElementById('amidakuji-canvas');29 if (canvas.getContext){30 var context = canvas.getContext('2d');31 }32 context.strokeStyle = '#1253A4';33 context.lineWidth = lineWidth;34 context.beginPath();35 context.moveTo(startX, y);36 context.lineTo(endX, y);37 context.stroke();38}39function drawVerticalLines(n, lineWidth){40 var canvas = document.getElementById('amidakuji-canvas');41 if (canvas.getContext){42 var context = canvas.getContext('2d');43 }44 var diff = Math.floor( $('#amidakuji-canvas').width() /(n-1));45 for(var i = 0; i < n; i++){46 drawVerticalLine(Math.floor(lineWidth / 2) + diff * i, lineWidth);47 addLotButton($('#amidakuji-canvas').offset().left + Math.floor(lineWidth / 2) + diff * i, $('#amidakuji-canvas').offset().top);48 }49}50function drawHorizontalLines(columnN, rowN, lineWidth){51 var canvas = document.getElementById('amidakuji-canvas');52 if (canvas.getContext){53 var context = canvas.getContext('2d');54 }55 var offSet = 30;56 var columnDiff = Math.floor($('#amidakuji-canvas').width()/(columnN - 1));57 var rowDiff = Math.floor(($('#amidakuji-canvas').height() - lineWidth - offSet * 2)/(rowN - 1));58 for(var i = 0; i < columnN - 1; i++){59 for(var j = 0; j < rowN; j++){60 drawHorizontalLine(Math.floor(lineWidth / 2) + columnDiff * i, 61 Math.floor(lineWidth / 2) + columnDiff * (i + 1), 62 Math.floor(lineWidth / 2) + rowDiff * j + offSet, 63 lineWidth);64 }65 }66}67function addLotButton(width, height) {68 var amidakuji = document.getElementById('button-area');69 var id = 'rotButton' + (amidakuji.getElementsByTagName('input').length).toString();70 $('#button-area').append(71 $('<input></input>')72 .attr('id', id)73 .attr('type', 'button')74 );75 var button = document.getElementById('amidakuji-canvas');76 $('#'+id).click(function(){77 var canvas = document.getElementById('blindfold-canvas');78 if (canvas.getContext){79 var context = canvas.getContext('2d');80 }81 context.clearRect(0,0,800,200);82 context.stroke();83 84 })85 return;...

Full Screen

Full Screen

2d.getcontext.extraargs.worker.js

Source:2d.getcontext.extraargs.worker.js Github

copy

Full Screen

...10 throw reason;11});12t.step(function() {13var offscreenCanvas = new OffscreenCanvas(100, 50);14var ctx = offscreenCanvas.getContext('2d');15var offscreenCanvas2 = new OffscreenCanvas(100, 50);16_assertDifferent(offscreenCanvas2.getContext('2d', false, {}, [], 1, "2"), null, "offscreenCanvas2.getContext('2d', false, {}, [], 1, \"2\")", "null");17_assertDifferent(offscreenCanvas2.getContext('2d', 123), null, "offscreenCanvas2.getContext('2d', 123)", "null");18_assertDifferent(offscreenCanvas2.getContext('2d', "test"), null, "offscreenCanvas2.getContext('2d', \"test\")", "null");19_assertDifferent(offscreenCanvas2.getContext('2d', undefined), null, "offscreenCanvas2.getContext('2d', undefined)", "null");20_assertDifferent(offscreenCanvas2.getContext('2d', null), null, "offscreenCanvas2.getContext('2d', null)", "null");21_assertDifferent(offscreenCanvas2.getContext('2d', Symbol.hasInstance), null, "offscreenCanvas2.getContext('2d', Symbol.hasInstance)", "null");22t.done();23});...

Full Screen

Full Screen

canvas-getContext-invalid.js

Source:canvas-getContext-invalid.js Github

copy

Full Screen

1description("Test that invalid canvas getContext() requests return null.");2canvas = document.createElement('canvas');3shouldBe("canvas.getContext('')", "null");4shouldBe("canvas.getContext('2d#')", "null");5shouldBe("canvas.getContext('This is clearly not a valid context name.')", "null");6shouldBe("canvas.getContext('2d\0')", "null");7shouldBe("canvas.getContext('2\uFF44')", "null");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const differencify = require('differencify');2const differencifyExpect = require('differencify-expect');3const { setDefaultOptions } = differencify;4const { toMatchImageSnapshot } = differencifyExpect;5expect.extend({ toMatchImageSnapshot });6setDefaultOptions({7});8const { getContext } = differencify;9const context = getContext();10const page = await context.newPage();11await page.screenshot({ path: 'example.png' });12await expect(page).toMatchImageSnapshot({13});14await context.close();15await differencify.cleanup();16module.exports = {17 testMatch: ['**/__tests__/**/*.js?(x)', '**/?(*.)+(spec|test).js?(x)'],18};19{20 "scripts": {21 },22 "devDependencies": {23 }24}

Full Screen

Using AI Code Generation

copy

Full Screen

1const differencify = require('differencify');2const differencifyConfig = {3 diffOptions: {4 },5};6differencify.init(differencifyConfig);7const { browser } = require('protractor');8const { setDefaultTimeout } = require('cucumber');9setDefaultTimeout(60 * 1000);10const { expect } = require('chai');11const { Given, When, Then } = require('cucumber');12const { By } = require('protractor');13const { protractor } = require('protractor/built/ptor');14const { element } = require('protractor');15const { browser } = require('protractor');16const { setDefaultTimeout } = require('cucumber');17setDefaultTimeout(60 * 1000);18const { expect } = require('chai');19const { Given, When, Then } = require('cucumber');20const { By } = require('protractor');21const { protractor } = require('protractor/built/ptor');22const { element } = require('protractor');23const { browser } = require('protractor');24const { setDefaultTimeout } = require('cucumber');25setDefaultTimeout(60 * 1000);26const { expect } = require('chai');27const { Given, When, Then } = require('cucumber');28const { By } = require('protractor');29const { protractor } = require('protractor/built/ptor');30const { element } = require('protractor');31const { browser } = require('protractor');32const { setDefaultTimeout } = require('cucumber');33setDefaultTimeout(60 * 1000);34const { expect } = require('chai');35const { Given, When, Then } = require('cucumber');36const { By } = require('protractor');37const { protractor } = require('protractor/built/ptor');38const { element } = require('protractor');39const { browser } = require('protractor');40const { setDefaultTimeout } = require('cucumber');41setDefaultTimeout(60 * 1000);42const { expect } = require('chai');43const { Given, When, Then } = require('cucumber');44const { By } = require('protractor');45const { protractor } = require('protractor/built/ptor');

Full Screen

Using AI Code Generation

copy

Full Screen

1const differencify = require('differencify');2const { getContext } = differencify;3const context = getContext({4 viewport: { width: 1280, height: 720 },5 output: {6 errorColor: {7 },8 },9});10describe('test', () => {11 it('test', async () => {12 await context.init();13 await context.takeScreenshot('google');14 await context.close();15 });16});17const differencify = require('differencify');18const { getContext } = differencify;19const context = getContext({20 viewport: { width: 1280, height: 720 },21 output: {22 errorColor: {23 },24 },25});26describe('test', () => {27 it('test', async () => {28 await context.init();29 await context.takeScreenshot('google');30 await context.close();31 });32});33const differencify = require('differencify');34const { getContext } = differencify;35const context = getContext({36 viewport: { width: 1280, height: 720 },37 output: {38 errorColor: {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getContext } = require('differencify');2const context = getContext();3const page = context.page;4const element = page.getElement('hello');5element.click();6### `getContext()`7### `page.getElement(name)`8### `element.click()`9### `element.type(text)`10### `element.hover()`11### `element.select(text)`12### `element.clear()`13### `element.check()`14### `element.uncheck()`15### `element.waitForSelector()`16### `element.waitForXPath()`17### `element.waitForFunction()`18### `element.waitForTimeout()`19### `element.waitForNavigation()`20### `element.waitForRequest()`21### `element.waitForResponse()`22### `element.waitForEvent()`23### `element.waitFor()`24### `element.focus()`25### `element.tap()`26### `element.doubleTap()`27### `element.press(key, options)`28### `element.check(options)`29### `element.uncheck(options)`

Full Screen

Using AI Code Generation

copy

Full Screen

1var differencify = require("differencify");2var differencify = require("differencify").default;3var differencify = new Differencify({4 diffOptions: {5 },6});7var differencify = new Differencify({8 diffOptions: {9 },10});11var differencify = new Differencify({12 diffOptions: {13 },14});15var differencify = new Differencify({16 diffOptions: {17 },18});19describe("Google", () => {20 it("should look the same", async () => {21 await differencify.init();22 await differencify.takeScreenshot("google");23 await differencify.assertScreenshot("google");24 });25});26var differencify = require("differencify");27var differencify = require("differencify").default;28var differencify = new Differencify({29 diffOptions: {30 },31});32var differencify = new Differencify({33 diffOptions: {

Full Screen

Using AI Code Generation

copy

Full Screen

1const differencify = require('differencify');2const differencifyConfig = {3 formatImageName: '{tag}-{logName}-{width}x{height}',4 formatImageDiffName: '{tag}-{logName}-{width}x{height}',5 {6 },7};8const differencify = require('differencify');9const differencifyConfig = {10 formatImageName: '{tag}-{logName}-{width}x{height}',11 formatImageDiffName: '{tag}-{logName}-{width}x{height}',12 {13 },14};

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run differencify automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful