- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我通过 js 模拟了标签区域悬停,并为每个区域创建了 js 函数。因此,正如您所看到的,矩形区域( bool 什维克主义)被绘制成 incide,而保利区域(乌托邦社会主义)只有一个轮廓。
var hdc;
// shorthand func
function byId(e){return document.getElementById(e);}
// takes a string that contains coords eg - "227,307,261,309, 339,354, 328,371, 240,331"
// draws a line from each co-ord pair to the next - assumes starting point needs to be repeated as ending point.
function drawPoly(coOrdStr)
{
var mCoords = coOrdStr.split(',');
var i, n;
n = mCoords.length;
hdc.beginPath();
hdc.moveTo(mCoords[0], mCoords[1]);
for (i=2; i<n; i+=2)
{
hdc.lineTo(mCoords[i], mCoords[i+1]);
}
hdc.lineTo(mCoords[0], mCoords[1]);
hdc.stroke();
}
function drawRect(coOrdStr)
{
var mCoords = coOrdStr.split(',');
var top, left, bot, right;
left = mCoords[0];
top = mCoords[1];
right = mCoords[2];
bot = mCoords[3];
hdc.fillRect(left,top,right-left,bot-top);
}
function myHover(element)
{
var hoveredElement = element;
var coordStr = element.getAttribute('coords');
var areaType = element.getAttribute('shape');
switch (areaType)
{
case 'polygon':
case 'poly':
drawPoly(coordStr);
break;
case 'rect':
drawRect(coordStr);
break;
}
}
function myLeave()
{
var canvas = byId('myCanvas');
hdc.clearRect(0, 0, canvas.width, canvas.height);
}
function myInit()
{
// get the target image
var img = byId('main');
var x,y, w,h;
// get it's position and width+height
x = img.offsetLeft;
y = img.offsetTop;
w = img.clientWidth;
h = img.clientHeight;
//alert(x + " " + y + " " + w + " " + h);
// move the canvas, so it's contained by the same parent as the image
var imgParent = img.parentNode;
var can = byId('myCanvas');
imgParent.appendChild(can);
// place the canvas in front of the image
can.style.zIndex = 1;
// position it over the image
can.style.left = x+'px';
can.style.top = y+'px';
// make same size as the image
can.setAttribute('width', w+'px');
can.setAttribute('height', h+'px');
// get it's context
hdc = can.getContext('2d');
// set the 'default' values for the colour/width of fill/stroke operations
hdc.fillStyle = "rgba(230,236,247,0.5)";
hdc.strokeStyle = "rgba(230,236,247,0.5)";
hdc.lineWidth = 2;
}
.menu {
position: fixed; /* Фиксированное положение */
right: 50px; /* Расстояние от правого края окна браузера */
top: 90%; /* Расстояние сверху */
}
#back_1 {
background-color: #cecece;
height: 720px;
margin: 0px auto;
text-align: center;
}
#main {
width: 700px;
height: 700px;
line-height: 0;
border: none;
}
#bolshevism {
height: 300px;
background-color: #b30106;
}
.text_1 {
width: 1200px;
padding-top: 70px;
margin: 0px auto;
text-align: left;
}
.text_2 {
width: 1200px;
padding-top: 70px;
margin: 0px auto;
text-align: right;
}
#utopian_socialism {
background-color: #eb3913;height: 330px;
}
#myCanvas {
position: absolute;
pointer-events:none;
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Political Spectrum</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="css/font-awesome.min.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.scrollTo.min.js"></script>
<script type="text/javascript" src="js/jquery.localScroll.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body onload="myInit()">
<canvas id='myCanvas'></canvas>
<div id="back_1">
<map name="map"><a id="picture"></a>
<img src="http://i.imgur.com/Vk1e2hW.png" id="main" usemap="#map"ismap>
<div>
<area href="#bolshevism_1" onmouseover='myHover(this);' onmouseout='myLeave();' shape="rect" coords="59,55,105,130" alt="Bolshevism">
<area href="#utopian_socialism_1" onmouseover='myHover(this);' onmouseout='myLeave();' shape="poly" coords="59,466,172,466,172,590,139,590,139,599,59,599" alt="Social Democracy">
<div id="bolshevism" class="authoritarian">
<div class="text_1">
<a id="bolshevism_1"><p class="head">BOLSHEVISM</p></a>
<img src="images/line.png"class="line"/>
<p class="descriprion">Bolshevism is the term used to describe the beliefs and practices of the Bolsheviks, the members of a political movement in Russia during the early 20th century. Bolsheviks were a faction of the Marxist Russian Social Democratic Labour Party (RSDLP) which split apart from the Menshevik faction at the Second Party Congress in 1903. The RSDLP was a revolutionary socialist political party formed in 1898 in Minsk in Belarus to unite the various revolutionary organisations of the Russian Empire into one party.</p>
<p class="link"><i class="fa fa-wikipedia-w" aria-hidden="true"></i><span><a href="https://en.wikipedia.org/wiki/Bolsheviks" target="_blank">Bolshevism</a></span></p>
</div>
</div>
<div id="utopian_socialism" class="authoritarian">
<div class="text_1">
<a id="utopian_socialism_1"><p class="head">UTOPIAN SOCIALISM</p></a>
<img src="images/line.png"class="line"/>
<p class="descriprion">Utopian socialism is a label used to define the first currents of modern socialist thought as exemplified by the work of Henri de Saint-Simon, Charles Fourier, Étienne Cabet, and Robert Owen. Utopian socialism is often described as the presentation of visions and outlines for imaginary or futuristic ideal societies, with positive ideals being the main reason for moving society in such a direction. Later socialists and critics of utopian socialism viewed "utopian socialism" as not being grounded in actual material conditions of existing society, and in some cases, as reactionary. These visions of ideal societies competed with Marxist-inspired revolutionary social democratic movements.<span class="link"><a href="https://en.wikipedia.org/wiki/Utopian_socialism" target="_blank">[wiki]</a></span></p>
<p class="link"><i class="fa fa-wikipedia-w" aria-hidden="true"></i><span><a href="https://en.wikipedia.org/wiki/Utopian_socialism" target="_blank">Utopian Socialism</a></span></p>
</div>
</div>
</body>
</html>
最佳答案
之后
hdc.stroke();
您应该添加以下行:
hdc.fill();
因此您的多边形将被颜色填充。
关于javascript - Canvas Poly 区域未绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44252700/
我正在尝试在客户端/前端上对图像进行多边形剪辑。一旦我获得积分,是否有办法吸引客户(即无需往返客户)? 据我所知,canvas 只能剪切矩形。也许有一种我不知道的方法?有没有我可以使用的轻量级 Can
我正在尝试使用 shapeless 创建一个可以采用余积的 poly2 函数: case class IndexedItem( item1: Item1, item2: Item2, it
是否可以使用 Poly/ML 构建共享库? 我希望能够创建一个 C Poly/ML 库的 API,并从不同的编程语言(例如 Python)调用/加载它。有人尝试这样做吗? 我知道这可以在 OCaml
我通过 js 模拟了标签区域悬停,并为每个区域创建了 js 函数。因此,正如您所看到的,矩形区域( bool 什维克主义)被绘制成 incide,而保利区域(乌托邦社会主义)只有一个轮廓。 var h
R 中的函数 poly() 用于生成正交向量,有助于解释系数的重要性。但是,我不认为将其用于预测的意义。在我看来,以下两个模型(model_1 和 model_2)应该产生相同的预测。 q=1:11
我已经通读了手册页?poly(我承认我没有完全理解),并且还阅读了书Introduction to Statistical Learning中该函数的描述。 。 我目前的理解是,调用poly(hors
到目前为止,我一直在使用 Poly/ML 进行几个所有源代码文件都在同一目录中的小项目。要构建这些项目,我所要做的就是在 REPL 中运行以下命令: > PolyML.make "Main"; 但现在
在 Poly/ML 中,可以通过以下方式获取全局值的名称: map #1 ((#allVal PolyML.globalNameSpace) ()); 可以使用#allStruct 类似地获得顶级结构
我正在尝试编译一串源代码并使用 Poly/ML 打印解析树。以下代码可以编译,但解析树为空: fun main () = let val stream = TextIO.ope
到目前为止,我一直在使用 Poly/ML 进行几个所有源代码文件都在同一目录中的小项目。要构建这些项目,我所要做的就是在 REPL 中运行以下命令: > PolyML.make "Main"; 但现在
这个问题已经有答案了: Fitting polynomial model to data in R (5 个回答) 已关闭10 年前。 我正在尝试使用 lm(poly) 获得某些点的多项式回归,但对它
我想将多项式系数附加到 data.frame,如下所示: df1 % dplyr::mutate( Linear = poly(x = Y, degree = 3, raw = TR
如何在 Cocos2D 框架中绘制填充多边形? 下面的代码绘制多边形但没有抗锯齿。我应该更改什么? void ccFillPoly( CGPoint *poli, int points, BOOL c
我在 svg 上绘制了人体部位图并将其集成到我的 html 中: .st0{stroke:#010101;stroke-width:0.4;stroke-miterlimit:10;}
我正在尝试了解如何使用 scikit-learn(或其他模块)在 R 中复制 poly() 函数。 例如,假设我在 R 中有一个向量: a <- c(1:10) 我想生成三次多项式: polynomi
我有一个关于公式和用户定义函数的问题: 情况1: clotting 这是coef=的地方添加属性。但还要注意,它会检查调用是否来自“poly”函数本身。由于您的函数名为“xpoly”但返回一个“
如果我有一个像这样的空间线对象: require(sp) x <- c(18.25721, 18.25763,18.25808,18.25846,18.25864,18.25886,18.25892,
我注意到大多数 3d 游戏/渲染环境将实体表示为(通常是三角形)3d 多边形的网格。但是一些示例,例如 Second Life , 或 PovRay使用由一组 3d 图元(立方体、球体、圆锥体、环面等
我正在使用 GeoDjango 查找多边形内的所有点,但它似乎使用边界(NMW、NME、SME、SMW)来查找点。因此,它会返回原始形状之外的结果。 polygon = Polygon((18.382
来自Tiltbrush section的多边形动画无法在 Linux 中为我渲染(在 Chrome 或 Firefox 下):https://poly.google.com/tiltbrush (但是
我是一名优秀的程序员,十分优秀!