2d

2d.png

+ Metalでデバイス座標=ローカル座標にするには

- (void)_reshape
{
    NSLog(@"width:%f height:%f", self.view.bounds.size.width, self.view.bounds.size.height);
    _projectionMatrix =scaleMatrix(2.0/self.view.bounds.size.width,2.0/self.view.bounds.size.height,1.0f);
    _viewMatrix = matrix_from_translation(-self.view.bounds.size.width*0.5,-self.view.bounds.size.height*0.5,0);
}

Pixi.jsで2Dグラフの座標軸を描く

[[html]]
<script src="http://miffysora.wikidot.com/local--files/webgl/pixi.min.js" type="text/javascript"></script>
</script>
<script type='text/javascript' >
// 初期化関数は`new PIXI.WebGLRenderer`か, `new PIXI.CanvasRenderer`, か`PIXI.autoDetectRenderer`です
var winWidth=200;
var winHeight=200;
var renderer = new PIXI.WebGLRenderer(winWidth, winHeight, {transparent:true});
document.body.appendChild(renderer.view);
 
var stage = new PIXI.Container();
//y原点を下にします
stage.scale.y=-1;
stage.position.y+=winHeight;
 
var xBase=20;
var yBase=20;
var xLine = new PIXI.Graphics();
xLine.lineStyle(2, 0x533E25,0.6);//枠線の太さと色を指定
xLine.moveTo(10,yBase);
xLine.lineTo(180,yBase);
stage.addChild(xLine);
var xText = new PIXI.Text("x", {font:'bold 12pt Arial', fill:'#533E25D'});
xText.position.x = 180;
xText.position.y = yBase;
stage.addChild(xText);
 
var yLine = new PIXI.Graphics();
yLine.lineStyle(2, 0x533E25,0.6);//枠線の太さと色を指定
yLine.moveTo(20,0);
yLine.lineTo(20,190);
stage.addChild(yLine);
var yText = new PIXI.Text("y", {font:'bold 12pt Arial', fill:'#533E25D'});
yText.position.x = xBase;
yText.position.y = 190;
yText.scale.y=-1;
stage.addChild(yText);
 
renderer.render(stage);
</script>
<body>
</body>
[[/html]]

サポートサイト Wikidot.com