-
This commit is contained in:
@@ -121,7 +121,7 @@ class View<C:Content> implements IView<C> {
|
|||||||
private function set_w(value:Float):Float {
|
private function set_w(value:Float):Float {
|
||||||
if (w != value) {
|
if (w != value) {
|
||||||
w = value;
|
w = value;
|
||||||
if (!Math.isNaN(r)) h = w / r;
|
if (!Math.isNaN(r) && r > 0) h = w / r;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
@@ -129,7 +129,7 @@ class View<C:Content> implements IView<C> {
|
|||||||
private function set_h(value:Float):Float {
|
private function set_h(value:Float):Float {
|
||||||
if (h != value) {
|
if (h != value) {
|
||||||
h = value;
|
h = value;
|
||||||
if (!Math.isNaN(r)) w = h * r;
|
if (!Math.isNaN(r) && r > 0) w = h * r;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
return h;
|
return h;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import flash.display.Graphics;
|
|||||||
COVER;
|
COVER;
|
||||||
CONTAIN;
|
CONTAIN;
|
||||||
REPEAT;
|
REPEAT;
|
||||||
|
STRETCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DrawUtil {
|
class DrawUtil {
|
||||||
@@ -24,7 +25,8 @@ class DrawUtil {
|
|||||||
graphics.endFill();
|
graphics.endFill();
|
||||||
}
|
}
|
||||||
var m:Matrix = new Matrix();
|
var m:Matrix = new Matrix();
|
||||||
var s:Float = 1.0;
|
var sx:Float = 1.0;
|
||||||
|
var sy:Float = 1.0;
|
||||||
switch (fillType) {
|
switch (fillType) {
|
||||||
case FillType.REPEAT:
|
case FillType.REPEAT:
|
||||||
graphics.beginBitmapFill(image, m, true, false);
|
graphics.beginBitmapFill(image, m, true, false);
|
||||||
@@ -38,19 +40,22 @@ class DrawUtil {
|
|||||||
return;
|
return;
|
||||||
case FillType.DEFAULT:
|
case FillType.DEFAULT:
|
||||||
case FillType.CONTAIN:
|
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:
|
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);
|
m.scale(sx, sy);
|
||||||
var dx:Float = (rect.width - image.width * s) / 2;
|
var dx:Float = (rect.width - image.width * sx) / 2;
|
||||||
var dy:Float = (rect.height - image.height * s) / 2;
|
var dy:Float = (rect.height - image.height * sy) / 2;
|
||||||
m.translate(dx, dy);
|
m.translate(dx, dy);
|
||||||
graphics.beginBitmapFill(image, m, false, true);
|
graphics.beginBitmapFill(image, m, false, true);
|
||||||
rect.x = Math.max(rect.x, m.tx);
|
rect.x = Math.max(rect.x, m.tx);
|
||||||
rect.y = Math.max(rect.y, m.ty);
|
rect.y = Math.max(rect.y, m.ty);
|
||||||
rect.width = Math.min(rect.width, image.width * s);
|
rect.width = Math.min(rect.width, image.width * sx);
|
||||||
rect.height = Math.min(rect.height, image.height * s);
|
rect.height = Math.min(rect.height, image.height * sy);
|
||||||
graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
|
graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
|
||||||
graphics.endFill();
|
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