我有部分View Preview.cshtml
@model MonitoreoIntegrado.Models.Figuras
@Html.DisplayFor(model => model.tipo)
@Html.DisplayFor(model => model.nombre)
@Html.DisplayFor(model => model.size)
@Html.DisplayFor(model => model.color)
@Html.DisplayFor(model => model.borde)
@Html.DisplayFor(model => model.colorBorde)
@Html.DisplayFor(model => model.rotacion)
model.size数据类型很短。我需要获得model.size的值来做这样的事情
<div style="width:@(model.size*2); height:@(model.size*3)"></div>
提前致谢。
答案 0 :(得分:0)
@{
int largo = (Model.size-Model.borde).Value;
double centro = Model.size*1.42/2;
short x1, x2, x3, x4, y1, y2, y3, y4, deg;
deg = Model.rotacion.Value;
x1=(short)Math.Round(centro + (largo*1.42/2) * Funciones.coseno(225 - deg));
y1 = (short)Math.Round(centro + (largo*1.42/2) * Funciones.seno(225 - deg));
x2 = (short)Math.Round(x1 + largo * Funciones.coseno(90 - deg));
y2 = (short)Math.Round(y1 + largo * Funciones.seno(90 - deg));
x3 = (short)Math.Round(x2 + largo * Funciones.coseno(0 - deg));
y3 = (short)Math.Round(y2 + largo * Funciones.seno(0 - deg));
x4 = (short)Math.Round(x3 + largo * Funciones.coseno(270 - deg));
y4 = (short)Math.Round(y3 + largo * Funciones.seno(270 - deg));
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="@(Model.size*1*42)" height="@(Model.size*1.42)">
<polygon points="@x1,@y1 @x2,@y2 @x3,@y3 @x4,@y4"
fill="#@Model.color" stroke-width="@Model.borde" stroke="@Model.colorBorde" />
</svg>
}
Funciones.coseno就像Math.cos,但它适用于度数而不是弧度。