Home › Forums › General › Programming › How to use createDashedStroke
- This topic has 18 replies, 2 voices, and was last updated 9 years, 7 months ago by atom.
-
AuthorPosts
-
August 4, 2014 at 11:16 am #27051
Hi
I’m trying to create a dashed path, but I don’t know how to use it, I’ve tried several ways but all fail.
This is what I have:
pathRing3 = Path()
strokeRing3 = PathStrokeType(2, PathStrokeType.square, PathStrokeType.square)
transformRing3 = AffineTransform()This is the function I’m trying to use:
void createDashedStroke(PathStrokeType const&,Path&,Path const&,custom [float] const*,int,AffineTransform const&,custom [float])
August 4, 2014 at 1:01 pm #27054This seems impossible at the moment, i have no idea how to pass a const float * type in Lua, i’ll write a wrapper to simplify this process asap and post an example. To draw a path that’s a line:
drawPanel = function(canvas,g) p = Path() p:startNewSubPath (0.0, 0.0); p:lineTo (100, 100); stroke = PathStrokeType (5.0, PathStrokeType.mitered, PathStrokeType.butt) trans = AffineTransform() g:strokePath (p, stroke, trans) end
August 4, 2014 at 2:03 pm #27055Ok, thanks.
August 4, 2014 at 2:14 pm #27056This should look something like that, it will be in the next build.
Attachments:
You must be logged in to view attached files.August 4, 2014 at 2:49 pm #27058Yeah, that’s cool. Thx!
August 6, 2014 at 1:25 pm #27155More graphics issues, it seems drawEllipse () function is not registered.
August 6, 2014 at 2:53 pm #27156yes i can see i removed it for some reason, i’ve put it back now.
August 7, 2014 at 1:25 pm #27193Should be fixed in all builds now.
August 7, 2014 at 4:46 pm #27198Yep, all working good.
August 8, 2014 at 3:40 pm #27241Atom, I see there are built-in fonts in Ctrlr, but I don’t know how to access them in Lua, if I use this it doesn’t work.
font = Font("LCD",16,0)
August 8, 2014 at 4:01 pm #27243Yeah i didn’t get the chance to add embedded fonts as resources to Lua, but you access them as resources, i’ll add the needed methods now and post builds today, you can use that like so (in any paint callback) assuming your font is a resource named “MyCustomFontName”
f = resources:getResourceAsFont ("MyCustomFontName") g:setFont (f) j = Justification (Justification.centred) g:drawText ("Bleh Meh 0123", 0, 0, 100, 100, j, false)
August 8, 2014 at 4:21 pm #27245Cool, thanks
August 11, 2014 at 11:47 pm #27389the fix is in.
August 12, 2014 at 12:42 pm #27410It works with fonts imported as resources, but not with embedded fonts inside Ctrlr, I don’t know how to import embedded fonts as a resource.
August 12, 2014 at 12:46 pm #27411It won’t work, those embedded fonts inside Ctrlr are in a special crappy format (old Font implementation), i hope to drop them soon. Use any TTF/OTF fonts instead and don’t base anything on those old fonts inside CTRLR.
August 12, 2014 at 12:53 pm #27412Ok, thanks
August 12, 2014 at 1:13 pm #27413I get an assertion failure when drawing text centred. Not too problematic as it works fine with horizontallyCentred:
JUCE Assertion failure in contexts/juce_GraphicsContext.cpp:238
g:drawSingleLineText(string.format(“%s”, “TEXT”), 10 , 10, Justification (Justification.centred))
August 12, 2014 at 1:24 pm #27414That might be due to some OS specific stuff, i get that a lot, for example on Windows when using JUCE i can’t center vertically anything because i get assertion from JUCE, since i bound those JUCE methods directly you might be getting those too.
August 12, 2014 at 1:34 pm #27415Here is the comment from Jules that’s inside the library code:
//============================================================================== void Graphics::drawSingleLineText (const String& text, const int startX, const int baselineY, Justification justification) const { if (text.isNotEmpty()) { // Don't pass any vertical placement flags to this method - they'll be ignored. jassert (justification.getOnlyVerticalFlags() == 0); const int flags = justification.getOnlyHorizontalFlags();
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.