-
This commit is contained in:
@@ -121,7 +121,7 @@ class View<C:Content> implements IView<C> {
|
||||
private function set_w(value:Float):Float {
|
||||
if (w != value) {
|
||||
w = value;
|
||||
if (!Math.isNaN(r)) h = w / r;
|
||||
if (!Math.isNaN(r) && r > 0) h = w / r;
|
||||
invalidate();
|
||||
}
|
||||
return w;
|
||||
@@ -129,7 +129,7 @@ class View<C:Content> implements IView<C> {
|
||||
private function set_h(value:Float):Float {
|
||||
if (h != value) {
|
||||
h = value;
|
||||
if (!Math.isNaN(r)) w = h * r;
|
||||
if (!Math.isNaN(r) && r > 0) w = h * r;
|
||||
invalidate();
|
||||
}
|
||||
return h;
|
||||
|
||||
@@ -11,6 +11,7 @@ import flash.display.Graphics;
|
||||
COVER;
|
||||
CONTAIN;
|
||||
REPEAT;
|
||||
STRETCH;
|
||||
}
|
||||
|
||||
class DrawUtil {
|
||||
@@ -24,7 +25,8 @@ class DrawUtil {
|
||||
graphics.endFill();
|
||||
}
|
||||
var m:Matrix = new Matrix();
|
||||
var s:Float = 1.0;
|
||||
var sx:Float = 1.0;
|
||||
var sy:Float = 1.0;
|
||||
switch (fillType) {
|
||||
case FillType.REPEAT:
|
||||
graphics.beginBitmapFill(image, m, true, false);
|
||||
@@ -38,19 +40,22 @@ class DrawUtil {
|
||||
return;
|
||||
case FillType.DEFAULT:
|
||||
case FillType.CONTAIN:
|
||||
s = Math.min(rect.width / image.width, rect.height / image.height);
|
||||
sx = sy = Math.min(rect.width / image.width, rect.height / image.height);
|
||||
case FillType.COVER:
|
||||
s = Math.max(rect.width / image.width, rect.height / image.height);
|
||||
sx = sy = Math.max(rect.width / image.width, rect.height / image.height);
|
||||
case FillType.STRETCH:
|
||||
sx = rect.width / image.width;
|
||||
sy = rect.height / image.height;
|
||||
}
|
||||
m.scale(s, s);
|
||||
var dx:Float = (rect.width - image.width * s) / 2;
|
||||
var dy:Float = (rect.height - image.height * s) / 2;
|
||||
m.scale(sx, sy);
|
||||
var dx:Float = (rect.width - image.width * sx) / 2;
|
||||
var dy:Float = (rect.height - image.height * sy) / 2;
|
||||
m.translate(dx, dy);
|
||||
graphics.beginBitmapFill(image, m, false, true);
|
||||
rect.x = Math.max(rect.x, m.tx);
|
||||
rect.y = Math.max(rect.y, m.ty);
|
||||
rect.width = Math.min(rect.width, image.width * s);
|
||||
rect.height = Math.min(rect.height, image.height * s);
|
||||
rect.width = Math.min(rect.width, image.width * sx);
|
||||
rect.height = Math.min(rect.height, image.height * sy);
|
||||
graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
|
||||
graphics.endFill();
|
||||
}
|
||||
|
||||
44
haxework/log/SocketLogger.hx
Executable file
44
haxework/log/SocketLogger.hx
Executable file
@@ -0,0 +1,44 @@
|
||||
package haxework.log;
|
||||
|
||||
import haxework.log.BaseLogger;
|
||||
#if flash
|
||||
import flash.net.Socket;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
#else
|
||||
import sys.net.Host;
|
||||
import sys.net.Socket;
|
||||
#end
|
||||
|
||||
class SocketLogger extends BaseLogger {
|
||||
|
||||
private var socket:Socket;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
socket = new Socket();
|
||||
#if flash
|
||||
socket.addEventListener(IOErrorEvent.IO_ERROR, function(error):Void {
|
||||
L.e("SocketLogger", "", error);
|
||||
});
|
||||
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(error):Void {
|
||||
L.e("SocketLogger", "", error);
|
||||
});
|
||||
socket.connect(CompilationOption.get("debug.address"), Std.parseInt(CompilationOption.get("debug.port")));
|
||||
#else
|
||||
socket.connect(new Host(CompilationOption.get("debug.address")), Std.parseInt(CompilationOption.get("debug.port")));
|
||||
#end
|
||||
}
|
||||
|
||||
override private function write(text:String, ?p:haxe.PosInfos):Void {
|
||||
try {
|
||||
var s:String = p.fileName + ":" + p.lineNumber + ":" + text + "\n";
|
||||
#if flash
|
||||
socket.writeUTF(s);
|
||||
socket.flush();
|
||||
#else
|
||||
socket.write(s);
|
||||
#end
|
||||
} catch (error:Dynamic) {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user