As the title indicates, I am looking at creating a label for a player Gui in Roblox using only code. Under the folder StarterGui, I have a ScreenGui, and as a child of ScreenGui I have a local script with the following code:
local ScreenGui = script.Parent
local label = Instance.new("TextLabel", ScreenGui)
label.Size = UDim2.new({0, 200},{0, 100})
label.Text = "label"
label.TextColor3 = Color3.new (0,0,0)
label.TextSize = 36
label.Font = "Arial"
label.TextScaled = true
I am pretty sure I should be seeing a label with the word ''label'' by now, but nothing. What am I missing?
The line that says
label.Size = UDim2.new({0, 200},{0, 100})
Should be
label.Size = UDim2.new(0, 200, 0, 100)
This is because UDim2.new accepts 4 arguments, not 2 arrays.
Hope I could help!
Related
I’m trying to modify the color of the dot inside a radio button with Resource Hacker. I managed to change the color of the circle/frame but not the dot inside. I looked everywhere online and found similar examples but doesn’t exactly suit me with my situation. I guess all I need is the right syntax format. I tried so many different code combinations to no avail since I’m a newbie in coding. I’d really appreciate if you could help me out. The exact code I’m fiddling is below. Many thanks in advance.
object ScanCandidateGrp: TRzRadioGroup
Left = 103
Top = 34
Width = 64
Height = 66
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Tahoma'
Font.Style = []
TextShadowColor = clActiveBorder
GroupStyle = gsCustom
ItemFrameColor = clRed << I managed to change the circle color with this
ItemHotTrack = True
ItemHighlightColor = clBlue
ItemHotTrackColor = clGreen
ItemIndex = 0
Items.Strings = (
'Bob'
'Alex'
'Sue')
ParentFont = False
StartXPos = 2
StartYPos = 0
TabOrder = 0
Transparent = True
VerticalSpacing = 5
OnClick = ScanCandidateGrpClick
end
In VBS script, I have created a simple message box application. It currently stays in front of all windows until the user responds and uses very simple coding
X=MsgBox("Test Text" ,1+4069, "Test Title")
But it always appears in the same place. Is there any way of making it appear in a random place on the screen? Please help!
There is one type of box which allows you to position it on the screen: InputBox
Title = "Hello"
DefaultValueText = "Hello Stackoverflow !"
message = "Type something here"
XPos = 0
YPos = 0
Text = InputBox(message,Title,DefaultValueText,XPos,YPos)
XPos = 3000
YPos = 800
Text = InputBox(message,Title,DefaultValueText,XPos,YPos)
#Hackoo was almost there,
I used his and here is what I made out of it.
dim r
randomize
r = int(rnd*500) + 1
r2 = int(rnd*1500) + 1
Title = "Hello"
DefaultValueText = "Hello!"
message = "Type something here!"
XPos = r
YPos = r2
Text = InputBox(message,Title,DefaultValueText,XPos,YPos)
Im trying to get a sprite sheet to run through the 4 images so it plays an animation, although Corona SDK is giving me an error saying
"main.lua40: bad argument #2 to 'newImageSheet' (table (options)expected)
stack traceback: [C]: in function 'newImageSheet' main.lua 40: in main chunk"
exclamationMarkAnimations = graphics.newImageSheet("exclamationMarkAnimated.png", sheetOptions)
exclamationMarkAnimated =
{
width = 12,
height = 12,
numFrames = 4
}
animation = {
{
name = "bobbing",
start = 1,
count = 4,
time = 800,
loopCount = 0, -- "0" means always
loopDirection = "forward"
}
}
exclamationMarkVars = display.newSprite(exclamationMarkAnimations, exclamationMarkAnimated)
exclamationMarkVars:addEventListener("sprite", spriteListener)
Thank you for any and all help.
That project is saved under Corona samples as you can see in the picture below:
and also in this folder: C:\Program Files (x86)\Corona Labs\Corona SDK\Sample Code\Animation
You can use that as the base so save you some time.
Good day all! I have a very tricky for me question.
In my application I have button with image inside. All properties of this button:
Me.cmdSelectAll.BackColor = System.Drawing.SystemColors.Control
Me.cmdSelectAll.Image = CType(resources.GetObject("cmdSelectAll.BackgroundImage"), System.Drawing.Image)
Me.cmdSelectAll.ImageAlign = Drawing.ContentAlignment.BottomRight
Me.cmdSelectAll.Cursor = System.Windows.Forms.Cursors.Default
Me.cmdSelectAll.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdSelectAll.ForeColor = System.Drawing.SystemColors.ControlText
Me.cmdSelectAll.Location = New System.Drawing.Point(0, 282)
Me.cmdSelectAll.Name = "cmdSelectAll"
Me.cmdSelectAll.Padding = New System.Windows.Forms.Padding(0, 0, 0, 0)
Me.cmdSelectAll.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.cmdSelectAll.Size = New System.Drawing.Size(22, 22)
Me.cmdSelectAll.TabIndex = 11
Me.cmdSelectAll.TabStop = False
Me.ToolTip1.SetToolTip(Me.cmdSelectAll, "Select All Channels")
Me.cmdSelectAll.UseVisualStyleBackColor = False
When I run it with default text size of win7, the image appears in the center, it's all ok. But when I set some custom value of text size (115%) my image suddenly goes more right and down. It occurs with all of my button's images. Could you please answer me why does this happen and how can i fix this issue? Thanks
I need to create a caption for a picture using two colors, all the words are in black except one in other color...
I've been reading the docs of RMagick I can't find a way of doing this... What I'm using right now to create the text is:
txt_name = Draw.new
image.annotate(txt_name, 0,0,0,0, "This RED has to be in red") do
self.gravity = Magick::NorthGravity
self.pointsize = 20
self.fill = '#000000'
txt_name.font_weight = 100
self.font_family = 'Arial'
end
Any idea?? Or something to read so I can make this work??
Thanks!
Something like the following should work for you. (Please note that this is just to show you the process; I wouldn't recommend putting code like this into production. This is begging to be put in its own class EDIT: see below):
draw = Magick::Draw.new
Set all of the text attributes on the draw object:
draw.pointsize = 20
draw.fill = '#000000'
draw.gravity = Magick::NorthGravity
draw.font_weight = 100
draw.font_family = "Arial"
draw.font_style = Magick::NormalStyle
Get your image object (this one is just a new blank image):
image = Magick::Image.new(300,200)
Set up the strings and measure them with get_type_metrics:
black_text = "This "
red_text = "RED"
remainder = " has to be in red"
black_text_metrics = draw.get_type_metrics(black_text)
red_text_metrics = draw.get_type_metrics(red_text)
remainder_metrics = draw.get_type_metrics(remainder)
Annotate with the black text:
draw.annotate(image,
black_text_metrics.width,
black_text_metrics.height,
10,10,black_text)
Change the color to red and add the red text:
draw.fill = "#ff0000"
draw.annotate(image,
red_text_metrics.width,
red_text_metrics.height,
10 + black_text_metrics.width, # x value set to the initial offset plus the width of the black text
10, red_text)
Change the color back to black and add the remainder of the text:
draw.fill = "#000000"
draw.annotate(image,
remainder_metrics.width,
remainder_metrics.height,
10 + black_text_metrics.width + red_text_metrics.width,
10, remainder)
Edit: This may give you an idea of how you could structure this a bit nicer:
TextFragment = Struct.new(:string, :color)
class Annotator
attr_reader :text_fragments
attr_accessor :current_color
def initialize(color = nil)
#current_color = color || "#000000"
#text_fragments = []
end
def add_string(string, color = nil)
text_fragments << TextFragment.new(string, color || current_color)
end
end
class Magick::Draw
def annotate_multiple(image, annotator, x, y)
annotator.text_fragments.each do |fragment|
metrics = get_type_metrics(fragment.string)
self.fill = fragment.color
annotate(image, metrics.width, metrics.height, x, y, fragment.string)
x += metrics.width
end
end
end
and a usage example:
image = Magick::Image.new(300,200)
draw = Magic::Draw.new
draw.pointsize = 24
draw.font_family = "Arial"
draw.gravity = Magick::NorthGravity
annotator = Annotator.new #using the default color (black)
annotator.add_string "Hello "
annotator.add_string "World", "#ff0000"
annotator.add_string "!"
draw.annotate_multiple(image, annotator, 10, 10)