From 18c290174f95837ceda2e6dc385318863d54521d Mon Sep 17 00:00:00 2001 From: rsesek Date: Sat, 11 Dec 2010 18:30:43 +0000 Subject: [PATCH] Draw a black gradient when the back side is showing. git-svn-id: svn://depot/macosx/RGBConverter/trunk@635 ad1dcce9-c9fe-0310-b82b-83ea1733dbb0 --- RGB Converter.wdgt/Widget.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/RGB Converter.wdgt/Widget.js b/RGB Converter.wdgt/Widget.js index 3697027..246a958 100644 --- a/RGB Converter.wdgt/Widget.js +++ b/RGB Converter.wdgt/Widget.js @@ -25,6 +25,8 @@ var colors_ = { hex : '3C3C3C' }; +var backShowing_ = false; + // ################################################################### // widget init function setup() @@ -89,6 +91,19 @@ function Draw() var center = [canvas.width / 2, canvas.height / 2]; context.strokeStyle = 'black'; + if (backShowing_) { + // Draw the sheen gradient. + context.beginPath(); + context.arc(center[0], center[1], radius, 0, Math.PI * 2, true); + var gradient = context.createLinearGradient(0, 0, 0, canvas.height); + gradient.addColorStop(0, 'rgb(200, 200, 200)'); + gradient.addColorStop(1, 'rgb(0, 0, 0)'); + context.fillStyle = gradient; + context.fill(); + context.closePath(); + return; + } + // Draw the individual components. Start with red. context.beginPath(); context.moveTo(center[0], center[1]); @@ -269,6 +284,8 @@ function hex2dec(hex) function show_back() { + backShowing_ = true; + var front = document.getElementById("front"); var back = document.getElementById("back"); @@ -286,10 +303,14 @@ function show_back() } document.getElementById("fliprollie").style.display = "none"; + + Draw(); } function hide_back() { + backShowing_ = false; + var front = document.getElementById("front"); var back = document.getElementById("back"); @@ -305,6 +326,8 @@ function hide_back() { setTimeout("widget.performTransition();", 0); } + + Draw(); } var flipShown = false; -- 2.22.5