Is there a way to turn off anti aliasing with embedded fonts? I'm using the following code, but sadly I don't see any options in the Actionscript 3 reference, where I can achieve the same results when using a dynamic text field with the Bitmap text [no anti-alias] option selected under Aliasing.
TF = new TextField();
TF.embedFonts = true;
TF.selectable = false;
TF.defaultTextFormat = new TextFormat(_font, _fontSize, _fontColor);
TF.autoSize = TextFieldAutoSize.LEFT;
TF.height = _maskHeight;
TF.x = _maskWidth;
TF.text = getNextMessage();
TF.antiAliasType = AntiAliasType.ADVANCED;
addChild(TF);
Any ideas?
Based on the document provided by Adobe, you can't turn off anti-aliasing for embedded font: "Embedded fonts are anti-aliased, which means that their edges are smoothed for easier readability. This is especially apparent when the text size is large." You can see it in more detailed here: http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_04.html
I've been looking to do this too as I have a weird problem with Japanese text not rendering in Myriad Pro unless the 'anti-alias' drop down is set to 'Bitmap text [no anti-alias]' in the CS6 TextField property inspector - but there doesn't seem any way to choose this setting via ActionScript...!
Interestingly tried creating two TextFields on the stage that were identical other than the instance name and this setting, then did test movie > debug > list variables and got the following output:
For the TextField with 'Bitmap text' as the anti-alias setting:
Edit Text: Target="_level0.bitmaptext_txt"
textColor = 0, multiline = true, scroll = 1,
antiAliasType = "normal",
mouseWheelEnabled = true, variable = null, restrict = null,
gridFitType = "pixel",
selectable = false, bottomScroll = 1, filters = [object #1, class 'Array'] [], background = false,
maxhscroll = 0, styleSheet = undefined,
type = "dynamic",
autoSize = "none",
textWidth = 98, wordWrap = true, maxChars = null, hscroll = 0,
thickness = 0, borderColor = 0, html = false, backgroundColor = 16777215,
condenseWhite = false,
text = "hello world",
htmlText = "hello world",
sharpness = 0, textHeight = 26, border = false, password = false,
embedFonts = true, length = 11, tabIndex = undefined, maxscroll = 1
For the TextField with 'Anti-alias for animation' as the anti-alias setting:
Edit Text: Target="_level0.antialiasanimation_txt"
textColor = 0, multiline = true, scroll = 1,
antiAliasType = "normal",
mouseWheelEnabled = true, variable = null, restrict = null,
gridFitType = "pixel",
selectable = false, bottomScroll = 1, filters = [object #2, class 'Array'] [], background = false,
maxhscroll = 0, styleSheet = undefined,
type = "dynamic",
autoSize = "none",
textWidth = 93, wordWrap = true, maxChars = null, hscroll = 0,
thickness = 0, borderColor = 0, html = false, backgroundColor = 16777215,
condenseWhite = false,
text = "hello world",
htmlText = "hello world",
sharpness = 0, textHeight = 26, border = false, password = false,
embedFonts = true, length = 11, tabIndex = undefined, maxscroll = 1
As you can see, there's no tangible difference between the two other than the 'object #1', 'object #2' properties - I can't believe that's really doing anything?
Related
I am making an online game using Phaser and I need to make buttons with text on them for it that can change based on the text because the text can be different each time. I tried checking the API document but when I put in the get size function to try to get the bounds of the text my button disappears or the code will stop working with the error saying cannot read properties of undefined (reading getBounds) and it will swap between the two every time I reload the page.
count = Phaser.Math.Between(1,4)
for(let i = 50;i <= 750;i = i +200){
bingus = this.add.text(i, 400, quiz[category][difficulty][quest][count])
answs.push(bingus)
gorp.push(count)
count++
}
if(count > 4){
count = 1
}
}
this.butt1.setDisplaySize(Phaser.Geom.Rectangle.GetSize(answs[gorp[0]].getBounds()))
You could use the Phaser.GameObjects.Text and it's displayWidth and / or displayHeight properties, together with the global Phaser.Display.Align.In.Center function.
Maybe this works also for your UseCase.
Basically:
set the text of the text Object with setText
get the current displayWidth and displayHeight of the text Object
update/adjust the size of the button Object, also with displayWidth and displayHeight properties
Center the text Object inside of the button Object, with the Phaser.Display.Align.In.Center function
Here a small working Demo:
document.body.style = 'margin:0;';
var config = {
type: Phaser.AUTO,
width: 500,
height: 180,
scene: {
create
},
banner: false
};
let text;
let button;
let texts = ['first Text', 'Next', 'Second Text', 'Last', 'multiline1.\nmultiline2..\nmultiline3...' ];
let padding = 20;
let currentTextIdx = 0;
function create () {
this.add.text(10, 10, 'Text cycles about every second.')
button = this.add.rectangle(250, 90, 100, 40, 0xff0000 )
.setOrigin(.5);
text = this.add.text(250, 90, texts[currentTextIdx])
.setOrigin(.5);
this.time.addEvent({ delay: 1000, startAt:999, loop: true , callback: _ => {
currentTextIdx++;
if(currentTextIdx >= texts.length){
currentTextIdx = 0;
}
let newText = texts[currentTextIdx];
text.setText(newText);
button.displayWidth = padding * 2 + text.displayWidth;
button.displayHeight = padding * 2 + text.displayHeight;
Phaser.Display.Align.In.Center(text, button);
}});
}
new Phaser.Game(config);
<script src="//cdn.jsdelivr.net/npm/phaser#3.55.2/dist/phaser.js"></script>
I'm able to export a DT table generated in R/RStudio to HTML using the htmlWidget:saveWidget method. However, the FixedColumns feature is not preserved and becomes very narrow when a term is entered in the search bar.
xyz_search_dt <- datatable(
xyz_search_table_d,
rownames = FALSE, extensions = 'Buttons',
options = list(autoWidth = TRUE,
extensions = 'FixedColumns',
options = list(dom = 't',scrollX = TRUE,
fixedColumns = TRUE),
columnDefs = list(list(width= '200px',
targets = "feedback")),
dom=('Bfrtip'), buttons = c('excel'),
pageLength = table_rows,
searchHighlight = TRUE),
filter = list(position="top"))
htmlwidgets::saveWidget(xyz_search_dt, "xyz_search_dt.html")
The solution that I found and seems to work well is to address the widget sizing policy after the fact.
dow_search_dt[["sizingPolicy"]][["defaultWidth"]] <- "100%"
htmlwidgets::saveWidget(dow_search_dt, "dow_search_dt.html")
Reference:
How to resize HTML widget using saveWidget in htmlwidgets R (reopened question)?
You can try this. I use the mtcars dataset and everything works well.
xyz_search_dt <- DT::datatable((mtcars),
rownames = FALSE,
extensions = 'Buttons',
options = list(autoWidth = TRUE,
extensions = 'FixedColumns',
options = list(dom = 't',
scrollX = TRUE,
fixedColumns = TRUE),
columnDefs = list(list(width= '200px',
targets = "feedback")),
dom=('Bfrtip'),
buttons = c('excel'),
#pageLength = table_rows,
searchHighlight = TRUE),
filter=list(position="top"))
htmlwidgets::saveWidget(xyz_search_dt, "xyz_search_dt.html")
OUTPUT:
Original question
I would like to create a new learner for the quantile regression neural network. It is not in the lists for the learning methods already integrated with "mlr". Its format must be like this "RLearner_regr_QRNN.R"
Added after answer was accepted
I would like to define the "quantile regression neural network" as a new type of learner that has special properties and does not fit into one of the existing schemes. My code is below. Code is working but when I use it as a learner for my data, it gives an error that 'qrnn' is not an exported object from 'namespace:qrnn'. I do in advance thank you so much and look forward to hearing from you soon.
makeRLearner.regr.qrnn = function() {
makeRLearnerRegr(
cl = "regr.qrnn",
package = "qrnn",
par.set = makeParamSet(
makeIntegerLearnerParam(id = "n.hidden", default = 2L, lower = 1L),
makeUntypedLearnerParam(id = "n.hidden2", default = NULL),
makeUntypedLearnerParam(id = "w", default = NULL),
makeNumericVectorLearnerParam(id = "tau", default = c(0.1, 0.5, 0.9)),
makeIntegerLearnerParam(id = "iter.max", default = 5000L),
makeIntegerLearnerParam(id = "n.trials", default = 5L),
makeNumericLearnerParam(id = "lower", default = 0),
makeNumericVectorLearnerParam(id = "init.range", default = c(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)),
makeUntypedLearnerParam(id = "monotone", default = NULL),
makeNumericVectorLearnerParam(id = "eps.seq", default =c(2^(-8),2^(-12),2^(-16),2^(-20),2^(-24),2^(-28),2^(-32))),
makeDiscreteLearnerParam(id = "Th", values =c("sigmoid", "elu", "softplus"),default = "sigmoid"),
makeDiscreteLearnerParam(id = "Th.prime", values=c("sigmoid.prime", "elu.prime","softplus.prime", default = "sigmoid.prime")),
makeNumericLearnerParam(id = "penalty", default = 0),
makeIntegerLearnerParam(id = "n.errors.max", default = 10),
makeLogicalLearnerParam(id = "trace", default = TRUE),
makeDiscreteLearnerParam(id = "method", values =c("nlm","adam"), default = "nlm")
),
par.vals = list(n.hidden=5L, penalty=0),
properties = c("numerics", "factors", "ordered", "oobpreds", "featimp", "se", "weights"),
name = "QRNN",
short.name = "qrnn",
callees = "qrnn"
)
}
#' #export
trainLearner.regr.qrnn = function(.learner, .task, .subset, .weights = NULL, ...) {
if (is.null(.weights)) {
f = getTaskFormula(.task)
qrnn::qrnn(f, data = getTaskData(.task, .subset), linout = TRUE, ...)
} else {
f = getTaskFormula(.task)
qrnn::qrnn(f, data = getTaskData(.task, .subset), linout = TRUE, weights = .weights, ...)
}
}
#' #export
predictLearner.regr.qrnn = function(.learner, .model, .newdata, ...) {
predict(.model$learner.model, newdata = .newdata, ...)[, 1L]
}
You can find instructions on how to create a custom learner on our website.
Also, you might want to think over creating that learner for the new mlr3 package instead. Instructions are here.
I'm noob at Phaser 3 and trying to add a group (2 sprites) in a follower. The code works when I use a sprite at 'add.follower'.
function create () {
var bola = this.add.group();
bola.create(0, 0, 'bola15');
bola.create(0, 0, 'bolasombra');
var line1 = new Phaser.Curves.Line([ 100, 100, 500, 100 ]);
var line2 = new Phaser.Curves.Line([ 500, 100, 500, 500 ]);
path1 = this.add.path();
path1.add(line1);
path1.add(line2);
var mover = this.add.follower(path1, 0, 0, bola);
mover.startFollow({
positionOnPath: true,
duration: 3000,
yoyo: false,
repeat: 0,
rotateToPath: false,
verticalAdjust: true
});
}
That's what I got:
Any solution for that, or other way to make something like that?
Edit:
Have tried with 'container' and got the same result:
bola = this.add.container(0,0);
bola1 = this.add.sprite(0,0,'bola15');
bola2 = this.add.sprite(0,0,'bolasombra');
bola.add(bola1);
bola.add(bola2);
At current state, PathFollower is set up to take in only a single GameObject. Unfortunately, this means you'll have to add your group items to a follower one by one. You can set up a loop to run through your group items and create the path followers like this:
for (var i = 0; i < bola.children.entries.length; i++) {
var mover = this.add.follower(path1, 0, 0, bola.children.entries[i].texture.key);
mover.startFollow({
positionOnPath: true,
duration: 3000,
yoyo: false,
repeat: 0,
rotateToPath: false,
verticalAdjust: true
});
}
Check this example from the Phaser 3 labs to see another example of how you can use multiple items with the same path if the group structure isn't important to your game.
I'm building Asp.net MVC website, and I'm trying to show multiple charts on the same page, but when I add second chart it covers the first one, so they never appear below each other, and they seem to be stacked over each other instead.
I tried adding table and add each chart to a table row but this didn't work also, not sure what I'm missing.
#(Html.Highsoft().Highcharts(
new Highcharts
{
Chart = new Highsoft.Web.Mvc.Charts.Chart
{
Type = ChartType.Line
},
Title = new Title
{
Text = ""
},
XAxis = new List<XAxis>
{
new XAxis
{
Type = XAxisType.Datetime,
Categories = ViewData["xValues"] as List<string>,
//Type = XAxisType.Datetime,
//TickInterval = 7 * 24 * 3600 * 1000, // one week
//TickWidth = 0,
//GridLineWidth = 1,
Labels = new XAxisLabels
{
Align = XAxisLabelsAlign.Left,
X = 3,
Y = 40
},
Crosshair = new XAxisCrosshair
{
Width = 2
}
}
},
YAxis = new List<YAxis>
{
new YAxis
{
Labels = new YAxisLabels
{
Align = YAxisLabelsAlign.Left,
X = 3,
Y = 16,
Format = "{value:.,0f}"
},
ShowFirstLabel = false
},
},
Legend = new Legend
{
Align = LegendAlign.Left,
VerticalAlign = LegendVerticalAlign.Top,
Y = 20,
Floating = true,
BorderWidth = 0
},
PlotOptions = new PlotOptions
{
Series = new PlotOptionsSeries
{
Cursor = PlotOptionsSeriesCursor.Pointer,
Events = new PlotOptionsSeriesEvents
{
Click = "handleClick"
},
Marker = new PlotOptionsSeriesMarker
{
LineWidth = 1
}
}
},
Series = new List<Series>
{
new LineSeries
{
Name = "Error Page Count",
Data = #ViewData["Count"] as List<LineSeriesData>
},
new LineSeries
{
Color = "blue",
Name = "Error Page Rate",
Data = #ViewData["Values"] as List<LineSeriesData>
},
new LineSeries
{
Color = "black",
Name = "Error Page Rate (Users)",
Data = #ViewData["Rate"] as List<LineSeriesData>
}
}
}
, "chart"))
<script type="text/javascript">
function formatToolTip() {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;
}
#(Html.Highsoft().Highcharts(
new Highcharts
{
Title = new Title
{
Text = "Stacked bar chart"
},
XAxis = new List<XAxis>
{
new XAxis
{
Categories = new List<string> { "Apples", "Oranges", "Pears", "Grapes", "Bananas" }
}
},
YAxis = new List<YAxis>
{
new YAxis
{
Min = 0,
Title = new YAxisTitle
{
Text = "Total fruit consumption"
},
StackLabels = new YAxisStackLabels
{
Enabled = true,
Style = new Hashtable
{
{ "fontWeght", "bold" }
}
}
}
},
//Legend = new Legend
//{
// Align = LegendAlign.Right,
// X = -30,
// VerticalAlign = LegendVerticalAlign.Top,
// Y = 25,
// Floating = true,
// BorderColor = "#CCC",
// BorderWidth = 1,
// BackgroundColor = "white"
//},
Tooltip = new Tooltip
{
Formatter = "formatToolTip"
},
PlotOptions = new PlotOptions
{
Column = new PlotOptionsColumn
{
Stacking = PlotOptionsColumnStacking.Normal,
DataLabels = new PlotOptionsColumnDataLabels
{
Enabled = true,
Color = "#FFFFFF",
Shadow = new Shadow()
{
Enabled = true,
Color = "black",
Width = 10,
OffsetX = 0,
OffsetY = 0
}
}
}
},
Series = new List<Series>
{
new ColumnSeries
{
Name = "John",
Data = #ViewData["johnData"] as List<ColumnSeriesData>
},
new ColumnSeries
{
Name = "Jane",
Data = #ViewData["janeData"] as List<ColumnSeriesData>
},
new ColumnSeries
{
Name = "Joe",
Data = #ViewData["joeData"] as List<ColumnSeriesData>
}
}
}
, "chart")
)
I found the problem.
I was using the same chart id for both charts, when I renamed one of the charts both appeared with no problem.